@openclaw/vydra-provider 0.0.0 → 2026.8.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # @openclaw/vydra-provider
1
+ # OpenClaw Vydra Provider
2
2
 
3
- Reserved placeholder for the official OpenClaw plugin package. Use a published release version instead.
3
+ Official OpenClaw provider plugin for Vydra image, video, and speech generation.
4
+
5
+ Install from OpenClaw:
6
+
7
+ ```bash
8
+ openclaw plugins install @openclaw/vydra-provider
9
+ openclaw gateway restart
10
+ ```
11
+
12
+ Set `VYDRA_API_KEY`, then configure an image, video, or speech model. See
13
+ <https://docs.openclaw.ai/providers/vydra> for capability details and examples.
@@ -0,0 +1,98 @@
1
+ import { DEFAULT_VYDRA_IMAGE_MODEL, downloadVydraAsset, extractVydraResultUrls, resolveCompletedVydraPayload, resolveVydraRequestContext, resolveVydraResponseJobId, resolveVydraResponseStatus } from "./shared.js";
2
+ import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
3
+ import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
4
+ import { assertOkOrThrowHttpError, postJsonRequest, readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
5
+ //#region extensions/vydra/image-generation-provider.ts
6
+ function buildVydraImageGenerationProvider() {
7
+ return {
8
+ id: "vydra",
9
+ label: "Vydra",
10
+ defaultModel: DEFAULT_VYDRA_IMAGE_MODEL,
11
+ models: [DEFAULT_VYDRA_IMAGE_MODEL],
12
+ isConfigured: (ctx) => isProviderApiKeyConfigured({
13
+ provider: "vydra",
14
+ ...ctx
15
+ }),
16
+ capabilities: {
17
+ generate: {
18
+ maxCount: 1,
19
+ supportsSize: false,
20
+ supportsAspectRatio: false,
21
+ supportsResolution: false
22
+ },
23
+ edit: {
24
+ enabled: false,
25
+ maxCount: 1,
26
+ maxInputImages: 0,
27
+ supportsSize: false,
28
+ supportsAspectRatio: false,
29
+ supportsResolution: false
30
+ }
31
+ },
32
+ async generateImage(req) {
33
+ if ((req.inputImages?.length ?? 0) > 0) throw new Error("Vydra image generation currently supports text-to-image only in the Vydra plugin.");
34
+ if ((req.count ?? 1) > 1) throw new Error("Vydra image generation supports at most one image per request.");
35
+ const { fetchFn, baseUrl, requestPolicy } = await resolveVydraRequestContext({
36
+ cfg: req.cfg,
37
+ agentDir: req.agentDir,
38
+ authStore: req.authStore,
39
+ capability: "image",
40
+ ssrfPolicy: req.ssrfPolicy
41
+ });
42
+ const model = req.model?.trim() || "grok-imagine";
43
+ const { response, release } = await postJsonRequest({
44
+ url: `${baseUrl}/models/${model}`,
45
+ headers: requestPolicy.headers,
46
+ body: {
47
+ prompt: req.prompt,
48
+ model: "text-to-image"
49
+ },
50
+ timeoutMs: req.timeoutMs,
51
+ fetchFn,
52
+ allowPrivateNetwork: requestPolicy.allowPrivateNetwork,
53
+ ssrfPolicy: requestPolicy.ssrfPolicy,
54
+ dispatcherPolicy: requestPolicy.dispatcherPolicy
55
+ });
56
+ try {
57
+ await assertOkOrThrowHttpError(response, "Vydra image generation failed");
58
+ const submitted = await readProviderJsonResponse(response, "vydra.image-generation");
59
+ const completedPayload = await resolveCompletedVydraPayload({
60
+ submitted,
61
+ baseUrl,
62
+ timeoutMs: req.timeoutMs,
63
+ fetchFn,
64
+ kind: "image",
65
+ missingJobIdMessage: "Vydra image generation response missing job id",
66
+ requestPolicy
67
+ });
68
+ const imageUrl = extractVydraResultUrls(completedPayload, "image")[0];
69
+ if (!imageUrl) throw new Error("Vydra image generation completed without an image URL");
70
+ const image = await downloadVydraAsset({
71
+ url: imageUrl,
72
+ kind: "image",
73
+ timeoutMs: req.timeoutMs,
74
+ fetchFn,
75
+ maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "image"),
76
+ requestPolicy
77
+ });
78
+ return {
79
+ images: [{
80
+ buffer: image.buffer,
81
+ mimeType: image.mimeType,
82
+ fileName: image.fileName
83
+ }],
84
+ model,
85
+ metadata: {
86
+ jobId: resolveVydraResponseJobId(completedPayload) ?? resolveVydraResponseJobId(submitted),
87
+ imageUrl,
88
+ status: resolveVydraResponseStatus(completedPayload) ?? "completed"
89
+ }
90
+ };
91
+ } finally {
92
+ await release();
93
+ }
94
+ }
95
+ };
96
+ }
97
+ //#endregion
98
+ export { buildVydraImageGenerationProvider };
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import { buildVydraImageGenerationProvider } from "./image-generation-provider.js";
2
+ import { VYDRA_DEFAULT_IMAGE_MODEL_REF, applyVydraConfig } from "./onboard.js";
3
+ import { buildVydraSpeechProvider } from "./speech-provider.js";
4
+ import { buildVydraVideoGenerationProvider } from "./video-generation-provider.js";
5
+ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
6
+ import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
7
+ //#region extensions/vydra/index.ts
8
+ const PROVIDER_ID = "vydra";
9
+ var vydra_default = definePluginEntry({
10
+ id: PROVIDER_ID,
11
+ name: "Vydra Provider",
12
+ description: "Vydra image, video, and speech provider",
13
+ register(api) {
14
+ api.registerProvider({
15
+ id: PROVIDER_ID,
16
+ label: "Vydra",
17
+ docsPath: "/providers/vydra",
18
+ envVars: ["VYDRA_API_KEY"],
19
+ auth: [createProviderApiKeyAuthMethod({
20
+ providerId: PROVIDER_ID,
21
+ methodId: "api-key",
22
+ label: "Vydra API key",
23
+ hint: "Image, video, and speech API key",
24
+ optionKey: "vydraApiKey",
25
+ flagName: "--vydra-api-key",
26
+ envVar: "VYDRA_API_KEY",
27
+ promptMessage: "Enter Vydra API key",
28
+ defaultModel: VYDRA_DEFAULT_IMAGE_MODEL_REF,
29
+ expectedProviders: [PROVIDER_ID],
30
+ applyConfig: (cfg) => applyVydraConfig(cfg),
31
+ wizard: {
32
+ choiceId: "vydra-api-key",
33
+ choiceLabel: "Vydra API key",
34
+ choiceHint: "Image, video, and speech API key",
35
+ groupId: "vydra",
36
+ groupLabel: "Vydra",
37
+ groupHint: "Image, video, and speech",
38
+ onboardingScopes: ["image-generation"]
39
+ }
40
+ })]
41
+ });
42
+ api.registerSpeechProvider(buildVydraSpeechProvider());
43
+ api.registerImageGenerationProvider(buildVydraImageGenerationProvider());
44
+ api.registerVideoGenerationProvider(buildVydraVideoGenerationProvider());
45
+ }
46
+ });
47
+ //#endregion
48
+ export { vydra_default as default };
@@ -0,0 +1,20 @@
1
+ //#region extensions/vydra/onboard.ts
2
+ const VYDRA_DEFAULT_IMAGE_MODEL_REF = "vydra/grok-imagine";
3
+ function applyVydraConfig(cfg) {
4
+ if (cfg.agents?.defaults?.mediaModels?.image) return cfg;
5
+ return {
6
+ ...cfg,
7
+ agents: {
8
+ ...cfg.agents,
9
+ defaults: {
10
+ ...cfg.agents?.defaults,
11
+ mediaModels: {
12
+ ...cfg.agents?.defaults?.mediaModels,
13
+ image: { primary: VYDRA_DEFAULT_IMAGE_MODEL_REF }
14
+ }
15
+ }
16
+ }
17
+ };
18
+ }
19
+ //#endregion
20
+ export { VYDRA_DEFAULT_IMAGE_MODEL_REF, applyVydraConfig };
package/dist/shared.js ADDED
@@ -0,0 +1,235 @@
1
+ import { assertOkOrThrowHttpError, createProviderOperationDeadline, createProviderOperationTimeoutResolver, fetchWithTimeoutGuarded, pollProviderOperationJson, resolveProviderHttpRequestConfig, sanitizeConfiguredModelProviderRequest } from "openclaw/plugin-sdk/provider-http";
2
+ import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
3
+ import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
4
+ import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
5
+ import { asOptionalRecord, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
+ //#region extensions/vydra/shared.ts
7
+ const DEFAULT_VYDRA_BASE_URL = "https://www.vydra.ai/api/v1";
8
+ const DEFAULT_VYDRA_IMAGE_MODEL = "grok-imagine";
9
+ const DEFAULT_VYDRA_VIDEO_MODEL = "veo3";
10
+ const DEFAULT_VYDRA_SPEECH_MODEL = "elevenlabs/tts";
11
+ const DEFAULT_VYDRA_VOICE_ID = "21m00Tcm4TlvDq8ikWAM";
12
+ const DEFAULT_HTTP_TIMEOUT_MS = 12e4;
13
+ const POLL_INTERVAL_MS = 2500;
14
+ const MAX_POLL_ATTEMPTS = 120;
15
+ function addUrlValue(value, urls) {
16
+ const normalized = normalizeOptionalString(value);
17
+ if (normalized !== void 0) {
18
+ if (/^https?:\/\//iu.test(normalized)) urls.add(normalized);
19
+ return;
20
+ }
21
+ if (Array.isArray(value)) for (const entry of value) addUrlValue(entry, urls);
22
+ }
23
+ function normalizeVydraBaseUrl(value) {
24
+ const fallback = DEFAULT_VYDRA_BASE_URL;
25
+ const trimmed = normalizeOptionalString(value);
26
+ if (!trimmed) return fallback;
27
+ try {
28
+ const url = new URL(trimmed);
29
+ if (url.hostname === "vydra.ai") url.hostname = "www.vydra.ai";
30
+ const pathname = url.pathname.replace(/\/+$/u, "");
31
+ if (!pathname) url.pathname = "/api/v1";
32
+ else url.pathname = pathname;
33
+ return url.toString().replace(/\/$/u, "");
34
+ } catch {
35
+ return fallback;
36
+ }
37
+ }
38
+ function resolveVydraBaseUrlFromConfig(cfg) {
39
+ return normalizeVydraBaseUrl(normalizeOptionalString(asOptionalRecord(asOptionalRecord(asOptionalRecord(asOptionalRecord(cfg)?.models)?.providers)?.vydra)?.baseUrl));
40
+ }
41
+ async function resolveVydraRequestContext(params) {
42
+ const auth = await resolveApiKeyForProvider({
43
+ provider: "vydra",
44
+ cfg: params.cfg,
45
+ agentDir: params.agentDir,
46
+ store: params.authStore
47
+ });
48
+ if (!auth.apiKey) throw new Error("Vydra API key missing");
49
+ const fetchFn = fetch;
50
+ const providerConfig = params.cfg.models?.providers?.vydra;
51
+ const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = resolveProviderHttpRequestConfig({
52
+ baseUrl: resolveVydraBaseUrlFromConfig(params.cfg),
53
+ defaultBaseUrl: DEFAULT_VYDRA_BASE_URL,
54
+ defaultHeaders: {
55
+ Authorization: `Bearer ${auth.apiKey}`,
56
+ "Content-Type": "application/json"
57
+ },
58
+ provider: "vydra",
59
+ capability: params.capability,
60
+ transport: "http",
61
+ request: sanitizeConfiguredModelProviderRequest(providerConfig?.request)
62
+ });
63
+ return {
64
+ fetchFn,
65
+ baseUrl,
66
+ requestPolicy: {
67
+ allowPrivateNetwork,
68
+ dispatcherPolicy,
69
+ headers,
70
+ headerOrigin: new URL(baseUrl).origin,
71
+ ...params.ssrfPolicy ? { ssrfPolicy: params.ssrfPolicy } : {}
72
+ }
73
+ };
74
+ }
75
+ function resolveVydraResponseJobId(payload) {
76
+ const object = asOptionalRecord(payload);
77
+ return normalizeOptionalString(object?.jobId) ?? normalizeOptionalString(object?.id);
78
+ }
79
+ function resolveVydraResponseStatus(payload) {
80
+ return normalizeOptionalLowercaseString(normalizeOptionalString(asOptionalRecord(payload)?.status));
81
+ }
82
+ function resolveVydraErrorMessage(payload) {
83
+ const object = asOptionalRecord(payload);
84
+ const error = object?.error;
85
+ if (typeof error === "string" && error.trim()) return error.trim();
86
+ const errorObject = asOptionalRecord(error);
87
+ return normalizeOptionalString(errorObject?.message) ?? normalizeOptionalString(errorObject?.detail) ?? normalizeOptionalString(object?.message);
88
+ }
89
+ function extractVydraResultUrls(payload, kind) {
90
+ const urls = /* @__PURE__ */ new Set();
91
+ const preferredKeys = kind === "audio" ? ["audioUrl", "audioUrls"] : kind === "image" ? ["imageUrl", "imageUrls"] : ["videoUrl", "videoUrls"];
92
+ const sharedKeys = [
93
+ "resultUrl",
94
+ "resultUrls",
95
+ "outputUrl",
96
+ "outputUrls",
97
+ "url",
98
+ "urls"
99
+ ];
100
+ const recurseKeys = [
101
+ "output",
102
+ "outputs",
103
+ "result",
104
+ "results",
105
+ "data",
106
+ "asset",
107
+ "assets"
108
+ ];
109
+ const visit = (value, depth = 0) => {
110
+ if (depth > 5) return;
111
+ if (Array.isArray(value)) {
112
+ for (const entry of value) visit(entry, depth + 1);
113
+ return;
114
+ }
115
+ const object = asOptionalRecord(value);
116
+ if (!object) return;
117
+ for (const key of [...preferredKeys, ...sharedKeys]) addUrlValue(object[key], urls);
118
+ for (const key of recurseKeys) if (key in object) visit(object[key], depth + 1);
119
+ };
120
+ visit(payload);
121
+ return [...urls];
122
+ }
123
+ function resolveVydraFileExtension(kind, mimeType) {
124
+ return extensionForMime(mimeType)?.slice(1) ?? (kind === "image" ? "png" : kind === "audio" ? "mp3" : "mp4");
125
+ }
126
+ function resolveVydraHttpTimeoutMs(timeoutMs) {
127
+ const resolved = typeof timeoutMs === "function" ? timeoutMs() : timeoutMs;
128
+ if (typeof resolved !== "number" || !Number.isFinite(resolved) || resolved <= 0) return DEFAULT_HTTP_TIMEOUT_MS;
129
+ return resolved;
130
+ }
131
+ function createVydraTimeoutError(deadline) {
132
+ const timeoutLabel = typeof deadline.timeoutMs === "number" ? ` after ${deadline.timeoutMs}ms` : "";
133
+ return /* @__PURE__ */ new Error(`${deadline.label} timed out${timeoutLabel}`);
134
+ }
135
+ function resolveVydraGuardedRequestOptions(policy) {
136
+ const ssrfPolicy = policy.allowPrivateNetwork ? {
137
+ ...policy.ssrfPolicy,
138
+ allowPrivateNetwork: true
139
+ } : policy.ssrfPolicy;
140
+ return {
141
+ ...ssrfPolicy ? { ssrfPolicy } : {},
142
+ ...policy.dispatcherPolicy ? { dispatcherPolicy: policy.dispatcherPolicy } : {},
143
+ auditContext: "vydra-media-download"
144
+ };
145
+ }
146
+ function resolveVydraAssetRequestHeaders(url, policy) {
147
+ try {
148
+ return new URL(url).origin === policy.headerOrigin ? policy.headers : void 0;
149
+ } catch {
150
+ return;
151
+ }
152
+ }
153
+ async function downloadVydraAsset(params) {
154
+ const timeoutMs = resolveVydraHttpTimeoutMs(params.timeoutMs);
155
+ const deadline = createProviderOperationDeadline({
156
+ timeoutMs,
157
+ label: `Vydra ${params.kind} download`
158
+ });
159
+ const resolveTimeoutMs = createProviderOperationTimeoutResolver({
160
+ deadline,
161
+ defaultTimeoutMs: timeoutMs
162
+ });
163
+ const headers = resolveVydraAssetRequestHeaders(params.url, params.requestPolicy);
164
+ const result = await fetchWithTimeoutGuarded(params.url, {
165
+ method: "GET",
166
+ ...headers ? { headers } : {}
167
+ }, resolveTimeoutMs(), params.fetchFn, resolveVydraGuardedRequestOptions(params.requestPolicy));
168
+ try {
169
+ try {
170
+ await assertOkOrThrowHttpError(result.response, `Vydra ${params.kind} download failed`, {
171
+ bodyTimeoutMs: resolveTimeoutMs,
172
+ onBodyTimeout: () => createVydraTimeoutError(deadline)
173
+ });
174
+ const mimeType = result.response.headers.get("content-type")?.trim() || (params.kind === "image" ? "image/png" : params.kind === "audio" ? "audio/mpeg" : "video/mp4");
175
+ const buffer = await readResponseWithLimit(result.response, params.maxBytes, {
176
+ timeoutMs: resolveTimeoutMs,
177
+ onTimeout: () => createVydraTimeoutError(deadline),
178
+ onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`Vydra ${params.kind} download exceeds ${maxBytes} bytes`)
179
+ });
180
+ const extension = resolveVydraFileExtension(params.kind, mimeType);
181
+ return {
182
+ buffer,
183
+ mimeType,
184
+ fileName: `${params.kind === "image" ? "image" : params.kind === "audio" ? "audio" : "video"}-1.${extension}`
185
+ };
186
+ } catch (error) {
187
+ if (typeof deadline.deadlineAtMs === "number" && Date.now() >= deadline.deadlineAtMs) throw createVydraTimeoutError(deadline);
188
+ throw error;
189
+ }
190
+ } finally {
191
+ await result.release();
192
+ }
193
+ }
194
+ async function waitForVydraJob(params) {
195
+ const deadline = params.deadline ?? createProviderOperationDeadline({
196
+ timeoutMs: params.timeoutMs,
197
+ label: `Vydra job ${params.jobId}`
198
+ });
199
+ return await pollProviderOperationJson({
200
+ url: `${params.baseUrl}/jobs/${params.jobId}`,
201
+ headers: params.requestPolicy.headers,
202
+ deadline,
203
+ defaultTimeoutMs: DEFAULT_HTTP_TIMEOUT_MS,
204
+ fetchFn: params.fetchFn,
205
+ maxAttempts: MAX_POLL_ATTEMPTS,
206
+ pollIntervalMs: POLL_INTERVAL_MS,
207
+ requestFailedMessage: "Vydra job status request failed",
208
+ timeoutMessage: `Vydra job ${params.jobId} did not finish in time`,
209
+ allowPrivateNetwork: params.requestPolicy.allowPrivateNetwork,
210
+ ssrfPolicy: params.requestPolicy.ssrfPolicy,
211
+ dispatcherPolicy: params.requestPolicy.dispatcherPolicy,
212
+ auditContext: "vydra-job-status",
213
+ isComplete: (payload) => resolveVydraResponseStatus(payload) === "completed" || extractVydraResultUrls(payload, params.kind).length > 0,
214
+ getFailureMessage: (payload) => {
215
+ const status = resolveVydraResponseStatus(payload);
216
+ return status === "failed" || status === "error" || status === "cancelled" ? resolveVydraErrorMessage(payload) ?? `Vydra job ${params.jobId} failed` : void 0;
217
+ }
218
+ });
219
+ }
220
+ async function resolveCompletedVydraPayload(params) {
221
+ if (resolveVydraResponseStatus(params.submitted) === "completed" || extractVydraResultUrls(params.submitted, params.kind).length > 0) return params.submitted;
222
+ const jobId = resolveVydraResponseJobId(params.submitted);
223
+ if (!jobId) throw new Error(resolveVydraErrorMessage(params.submitted) ?? params.missingJobIdMessage);
224
+ return waitForVydraJob({
225
+ baseUrl: params.baseUrl,
226
+ jobId,
227
+ timeoutMs: params.timeoutMs,
228
+ ...params.deadline ? { deadline: params.deadline } : {},
229
+ fetchFn: params.fetchFn,
230
+ kind: params.kind,
231
+ requestPolicy: params.requestPolicy
232
+ });
233
+ }
234
+ //#endregion
235
+ export { DEFAULT_VYDRA_BASE_URL, DEFAULT_VYDRA_IMAGE_MODEL, DEFAULT_VYDRA_SPEECH_MODEL, DEFAULT_VYDRA_VIDEO_MODEL, DEFAULT_VYDRA_VOICE_ID, downloadVydraAsset, extractVydraResultUrls, normalizeVydraBaseUrl, resolveCompletedVydraPayload, resolveVydraRequestContext, resolveVydraResponseJobId, resolveVydraResponseStatus };
@@ -0,0 +1,109 @@
1
+ import { DEFAULT_VYDRA_BASE_URL, DEFAULT_VYDRA_SPEECH_MODEL, DEFAULT_VYDRA_VOICE_ID, downloadVydraAsset, extractVydraResultUrls, normalizeVydraBaseUrl } from "./shared.js";
2
+ import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
3
+ import { assertOkOrThrowHttpError, postJsonRequest, readProviderJsonResponse, resolveProviderHttpRequestConfig } from "openclaw/plugin-sdk/provider-http";
4
+ import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
6
+ import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-core";
7
+ //#region extensions/vydra/speech-provider.ts
8
+ const VYDRA_SPEECH_VOICES = [{
9
+ id: DEFAULT_VYDRA_VOICE_ID,
10
+ name: "Rachel"
11
+ }];
12
+ function normalizeVydraSpeechConfig(rawConfig) {
13
+ const raw = asOptionalRecord(asOptionalRecord(rawConfig.providers)?.vydra) ?? asOptionalRecord(rawConfig.vydra);
14
+ return {
15
+ apiKey: normalizeResolvedSecretInputString({
16
+ value: raw?.apiKey,
17
+ path: "tts.providers.vydra.apiKey"
18
+ }),
19
+ baseUrl: normalizeVydraBaseUrl(normalizeOptionalString(raw?.baseUrl) ?? normalizeOptionalString(process.env.VYDRA_BASE_URL)),
20
+ model: normalizeOptionalString(raw?.model) ?? normalizeOptionalString(process.env.VYDRA_TTS_MODEL) ?? "elevenlabs/tts",
21
+ voiceId: normalizeOptionalString(raw?.voiceId) ?? normalizeOptionalString(process.env.VYDRA_TTS_VOICE_ID) ?? "21m00Tcm4TlvDq8ikWAM"
22
+ };
23
+ }
24
+ function readVydraSpeechConfig(config) {
25
+ const normalized = normalizeVydraSpeechConfig({});
26
+ return {
27
+ apiKey: normalizeOptionalString(config.apiKey) ?? normalized.apiKey,
28
+ baseUrl: normalizeVydraBaseUrl(normalizeOptionalString(config.baseUrl) ?? normalized.baseUrl),
29
+ model: normalizeOptionalString(config.model) ?? normalized.model,
30
+ voiceId: normalizeOptionalString(config.voiceId) ?? normalized.voiceId
31
+ };
32
+ }
33
+ function readVydraOverrides(overrides) {
34
+ if (!overrides) return {};
35
+ return {
36
+ model: normalizeOptionalString(overrides.model),
37
+ voiceId: normalizeOptionalString(overrides.voiceId)
38
+ };
39
+ }
40
+ function buildVydraSpeechProvider() {
41
+ return {
42
+ id: "vydra",
43
+ label: "Vydra",
44
+ models: [DEFAULT_VYDRA_SPEECH_MODEL],
45
+ voices: VYDRA_SPEECH_VOICES.map((voice) => voice.id),
46
+ resolveConfig: ({ rawConfig }) => normalizeVydraSpeechConfig(rawConfig),
47
+ listVoices: async () => VYDRA_SPEECH_VOICES.map((voice) => Object.assign({}, voice)),
48
+ isConfigured: ({ providerConfig }) => Boolean(resolveSpeechProviderApiKey(readVydraSpeechConfig(providerConfig).apiKey, process.env.VYDRA_API_KEY)),
49
+ synthesize: async (req) => {
50
+ const config = readVydraSpeechConfig(req.providerConfig);
51
+ const overrides = readVydraOverrides(req.providerOverrides);
52
+ const apiKey = resolveSpeechProviderApiKey(config.apiKey, process.env.VYDRA_API_KEY);
53
+ if (!apiKey) throw new Error("Vydra API key missing");
54
+ const fetchFn = fetch;
55
+ const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = resolveProviderHttpRequestConfig({
56
+ baseUrl: config.baseUrl,
57
+ defaultBaseUrl: DEFAULT_VYDRA_BASE_URL,
58
+ allowPrivateNetwork: false,
59
+ defaultHeaders: {
60
+ Authorization: `Bearer ${apiKey}`,
61
+ "Content-Type": "application/json"
62
+ },
63
+ provider: "vydra",
64
+ capability: "audio",
65
+ transport: "http"
66
+ });
67
+ const { response, release } = await postJsonRequest({
68
+ url: `${baseUrl}/models/${overrides.model ?? config.model}`,
69
+ headers,
70
+ body: {
71
+ text: req.text,
72
+ voice_id: overrides.voiceId ?? config.voiceId
73
+ },
74
+ timeoutMs: req.timeoutMs,
75
+ fetchFn,
76
+ allowPrivateNetwork,
77
+ dispatcherPolicy
78
+ });
79
+ try {
80
+ await assertOkOrThrowHttpError(response, "Vydra speech synthesis failed");
81
+ const audioUrl = extractVydraResultUrls(await readProviderJsonResponse(response, "Vydra speech synthesis"), "audio")[0];
82
+ if (!audioUrl) throw new Error("Vydra speech synthesis response missing audio URL");
83
+ const audio = await downloadVydraAsset({
84
+ url: audioUrl,
85
+ kind: "audio",
86
+ timeoutMs: req.timeoutMs,
87
+ fetchFn,
88
+ maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio"),
89
+ requestPolicy: {
90
+ allowPrivateNetwork,
91
+ dispatcherPolicy,
92
+ headers,
93
+ headerOrigin: new URL(baseUrl).origin
94
+ }
95
+ });
96
+ return {
97
+ audioBuffer: audio.buffer,
98
+ outputFormat: audio.mimeType.includes("wav") ? "wav" : "mp3",
99
+ fileExtension: audio.fileName.endsWith(".wav") ? ".wav" : ".mp3",
100
+ voiceCompatible: false
101
+ };
102
+ } finally {
103
+ await release();
104
+ }
105
+ }
106
+ };
107
+ }
108
+ //#endregion
109
+ export { buildVydraSpeechProvider };
@@ -0,0 +1,117 @@
1
+ import { DEFAULT_VYDRA_VIDEO_MODEL, downloadVydraAsset, extractVydraResultUrls, resolveCompletedVydraPayload, resolveVydraRequestContext, resolveVydraResponseJobId, resolveVydraResponseStatus } from "./shared.js";
2
+ import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
3
+ import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
4
+ import { assertOkOrThrowHttpError, createProviderOperationDeadline, createProviderOperationTimeoutResolver, postJsonRequest, readProviderJsonResponse, resolveProviderOperationTimeoutMs } from "openclaw/plugin-sdk/provider-http";
5
+ //#region extensions/vydra/video-generation-provider.ts
6
+ const VYDRA_KLING_MODEL = "kling";
7
+ const DEFAULT_VYDRA_VIDEO_TIMEOUT_MS = 12e4;
8
+ function resolveVydraVideoRequestBody(req) {
9
+ const model = req.model?.trim() || "veo3";
10
+ if (model === VYDRA_KLING_MODEL) {
11
+ const imageUrl = (req.inputImages?.[0])?.url?.trim();
12
+ if (!imageUrl) throw new Error("Vydra kling currently requires a remote image URL reference.");
13
+ return {
14
+ model,
15
+ body: {
16
+ prompt: req.prompt,
17
+ image_url: imageUrl,
18
+ video_url: imageUrl
19
+ }
20
+ };
21
+ }
22
+ if ((req.inputImages?.length ?? 0) > 0) throw new Error(`Vydra ${model} does not support image reference inputs in the Vydra plugin.`);
23
+ return {
24
+ model,
25
+ body: { prompt: req.prompt }
26
+ };
27
+ }
28
+ function buildVydraVideoGenerationProvider() {
29
+ return {
30
+ id: "vydra",
31
+ label: "Vydra",
32
+ defaultModel: DEFAULT_VYDRA_VIDEO_MODEL,
33
+ models: [DEFAULT_VYDRA_VIDEO_MODEL, VYDRA_KLING_MODEL],
34
+ isConfigured: (ctx) => isProviderApiKeyConfigured({
35
+ provider: "vydra",
36
+ ...ctx
37
+ }),
38
+ capabilities: {
39
+ generate: { maxVideos: 1 },
40
+ imageToVideo: {
41
+ enabled: true,
42
+ maxVideos: 1,
43
+ maxInputImages: 1
44
+ },
45
+ videoToVideo: { enabled: false }
46
+ },
47
+ async generateVideo(req) {
48
+ if ((req.inputVideos?.length ?? 0) > 0) throw new Error("Vydra video generation does not support video reference inputs.");
49
+ const { fetchFn, baseUrl, requestPolicy } = await resolveVydraRequestContext({
50
+ cfg: req.cfg,
51
+ agentDir: req.agentDir,
52
+ authStore: req.authStore,
53
+ capability: "video"
54
+ });
55
+ const deadline = createProviderOperationDeadline({
56
+ timeoutMs: req.timeoutMs ?? DEFAULT_VYDRA_VIDEO_TIMEOUT_MS,
57
+ label: "Vydra video generation"
58
+ });
59
+ const { model, body } = resolveVydraVideoRequestBody(req);
60
+ const { response, release } = await postJsonRequest({
61
+ url: `${baseUrl}/models/${model}`,
62
+ headers: requestPolicy.headers,
63
+ body,
64
+ timeoutMs: resolveProviderOperationTimeoutMs({
65
+ deadline,
66
+ defaultTimeoutMs: DEFAULT_VYDRA_VIDEO_TIMEOUT_MS
67
+ }),
68
+ fetchFn,
69
+ allowPrivateNetwork: requestPolicy.allowPrivateNetwork,
70
+ dispatcherPolicy: requestPolicy.dispatcherPolicy
71
+ });
72
+ try {
73
+ await assertOkOrThrowHttpError(response, "Vydra video generation failed");
74
+ const submitted = await readProviderJsonResponse(response, "Vydra video generation");
75
+ const completedPayload = await resolveCompletedVydraPayload({
76
+ submitted,
77
+ baseUrl,
78
+ deadline,
79
+ fetchFn,
80
+ kind: "video",
81
+ missingJobIdMessage: "Vydra video generation response missing job id",
82
+ requestPolicy
83
+ });
84
+ const videoUrl = extractVydraResultUrls(completedPayload, "video")[0];
85
+ if (!videoUrl) throw new Error("Vydra video generation completed without a video URL");
86
+ const video = await downloadVydraAsset({
87
+ url: videoUrl,
88
+ kind: "video",
89
+ timeoutMs: createProviderOperationTimeoutResolver({
90
+ deadline,
91
+ defaultTimeoutMs: DEFAULT_VYDRA_VIDEO_TIMEOUT_MS
92
+ }),
93
+ fetchFn,
94
+ maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "video"),
95
+ requestPolicy
96
+ });
97
+ return {
98
+ videos: [{
99
+ buffer: video.buffer,
100
+ mimeType: video.mimeType,
101
+ fileName: video.fileName
102
+ }],
103
+ model,
104
+ metadata: {
105
+ jobId: resolveVydraResponseJobId(completedPayload) ?? resolveVydraResponseJobId(submitted),
106
+ videoUrl,
107
+ status: resolveVydraResponseStatus(completedPayload) ?? "completed"
108
+ }
109
+ };
110
+ } finally {
111
+ await release();
112
+ }
113
+ }
114
+ };
115
+ }
116
+ //#endregion
117
+ export { buildVydraVideoGenerationProvider };
@@ -0,0 +1,42 @@
1
+ {
2
+ "id": "vydra",
3
+ "activation": {
4
+ "onStartup": false
5
+ },
6
+ "enabledByDefault": true,
7
+ "providers": ["vydra"],
8
+ "setup": {
9
+ "providers": [
10
+ {
11
+ "id": "vydra",
12
+ "envVars": ["VYDRA_API_KEY"]
13
+ }
14
+ ]
15
+ },
16
+ "providerAuthChoices": [
17
+ {
18
+ "provider": "vydra",
19
+ "method": "api-key",
20
+ "choiceId": "vydra-api-key",
21
+ "choiceLabel": "Vydra API key",
22
+ "groupId": "vydra",
23
+ "groupLabel": "Vydra",
24
+ "groupHint": "Image, video, and speech",
25
+ "onboardingScopes": ["image-generation"],
26
+ "optionKey": "vydraApiKey",
27
+ "cliFlag": "--vydra-api-key",
28
+ "cliOption": "--vydra-api-key <key>",
29
+ "cliDescription": "Vydra API key"
30
+ }
31
+ ],
32
+ "contracts": {
33
+ "speechProviders": ["vydra"],
34
+ "imageGenerationProviders": ["vydra"],
35
+ "videoGenerationProviders": ["vydra"]
36
+ },
37
+ "configSchema": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "properties": {}
41
+ }
42
+ }
package/package.json CHANGED
@@ -1,14 +1,49 @@
1
1
  {
2
2
  "name": "@openclaw/vydra-provider",
3
- "version": "0.0.0",
4
- "description": "Reserved package name for an official OpenClaw plugin.",
5
- "license": "MIT",
3
+ "version": "2026.8.1-beta.2",
4
+ "description": "OpenClaw Vydra media provider plugin.",
6
5
  "repository": {
7
6
  "type": "git",
8
- "url": "git+https://github.com/openclaw/openclaw.git"
7
+ "url": "https://github.com/openclaw/openclaw"
9
8
  },
10
- "publishConfig": {
11
- "access": "public",
12
- "tag": "placeholder"
13
- }
9
+ "type": "module",
10
+ "openclaw": {
11
+ "extensions": [
12
+ "./index.ts"
13
+ ],
14
+ "install": {
15
+ "clawhubSpec": "clawhub:@openclaw/vydra-provider",
16
+ "npmSpec": "@openclaw/vydra-provider",
17
+ "defaultChoice": "npm",
18
+ "minHostVersion": ">=2026.7.2"
19
+ },
20
+ "compat": {
21
+ "pluginApi": ">=2026.8.1-beta.2"
22
+ },
23
+ "build": {
24
+ "openclawVersion": "2026.8.1-beta.2",
25
+ "bundledDist": false
26
+ },
27
+ "release": {
28
+ "publishToClawHub": true,
29
+ "publishToNpm": true
30
+ },
31
+ "runtimeExtensions": [
32
+ "./dist/index.js"
33
+ ]
34
+ },
35
+ "files": [
36
+ "dist/**",
37
+ "openclaw.plugin.json",
38
+ "README.md"
39
+ ],
40
+ "peerDependencies": {
41
+ "openclaw": ">=2026.8.1-beta.2"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "openclaw": {
45
+ "optional": true
46
+ }
47
+ },
48
+ "bundledDependencies": []
14
49
  }