@openclaw/vydra-provider 2026.9.1 → 2026.9.3

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.
@@ -0,0 +1,5 @@
1
+ import { buildVydraSpeechProvider } from "./speech-provider.js";
2
+ //#region extensions/vydra/capability-catalog.ts
3
+ var capability_catalog_default = { speechProviders: [buildVydraSpeechProvider()] };
4
+ //#endregion
5
+ export { capability_catalog_default as default };
@@ -0,0 +1,24 @@
1
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ //#region extensions/vydra/defaults.ts
3
+ const DEFAULT_VYDRA_BASE_URL = "https://www.vydra.ai/api/v1";
4
+ const DEFAULT_VYDRA_IMAGE_MODEL = "grok-imagine";
5
+ const DEFAULT_VYDRA_VIDEO_MODEL = "veo3";
6
+ const DEFAULT_VYDRA_SPEECH_MODEL = "elevenlabs/tts";
7
+ const DEFAULT_VYDRA_VOICE_ID = "21m00Tcm4TlvDq8ikWAM";
8
+ function normalizeVydraBaseUrl(value) {
9
+ const fallback = DEFAULT_VYDRA_BASE_URL;
10
+ const trimmed = normalizeOptionalString(value);
11
+ if (!trimmed) return fallback;
12
+ try {
13
+ const url = new URL(trimmed);
14
+ if (url.hostname === "vydra.ai") url.hostname = "www.vydra.ai";
15
+ const pathname = url.pathname.replace(/\/+$/u, "");
16
+ if (!pathname) url.pathname = "/api/v1";
17
+ else url.pathname = pathname;
18
+ return url.toString().replace(/\/$/u, "");
19
+ } catch {
20
+ return fallback;
21
+ }
22
+ }
23
+ //#endregion
24
+ export { DEFAULT_VYDRA_BASE_URL, DEFAULT_VYDRA_IMAGE_MODEL, DEFAULT_VYDRA_SPEECH_MODEL, DEFAULT_VYDRA_VIDEO_MODEL, DEFAULT_VYDRA_VOICE_ID, normalizeVydraBaseUrl };
@@ -1,4 +1,5 @@
1
- import { DEFAULT_VYDRA_IMAGE_MODEL, runVydraGeneration } from "./shared.js";
1
+ import { DEFAULT_VYDRA_IMAGE_MODEL } from "./defaults.js";
2
+ import { runVydraGeneration } from "./shared.js";
2
3
  import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
3
4
  //#region extensions/vydra/image-generation-provider.ts
4
5
  function buildVydraImageGenerationProvider() {
package/dist/shared.js CHANGED
@@ -1,15 +1,10 @@
1
+ import { DEFAULT_VYDRA_BASE_URL, DEFAULT_VYDRA_IMAGE_MODEL, DEFAULT_VYDRA_VIDEO_MODEL, normalizeVydraBaseUrl } from "./defaults.js";
1
2
  import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
2
3
  import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
3
4
  import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
4
- import { assertOkOrThrowHttpError, createProviderOperationDeadline, createProviderOperationTimeoutResolver, fetchWithTimeoutGuarded, pollProviderOperationJson, postJsonRequest, readProviderJsonResponse, resolveProviderHttpRequestConfig, resolveProviderOperationTimeoutMs, sanitizeConfiguredModelProviderRequest } from "openclaw/plugin-sdk/provider-http";
5
- import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
5
+ import { assertOkOrThrowHttpError, createProviderOperationDeadline, createProviderOperationTimeoutResolver, fetchWithTimeoutGuarded, pollProviderOperationJson, postJsonRequest, readProviderBinaryResponse, readProviderJsonResponse, resolveProviderHttpRequestConfig, resolveProviderOperationTimeoutMs, sanitizeConfiguredModelProviderRequest } from "openclaw/plugin-sdk/provider-http";
6
6
  import { asOptionalRecord, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  //#region extensions/vydra/shared.ts
8
- const DEFAULT_VYDRA_BASE_URL = "https://www.vydra.ai/api/v1";
9
- const DEFAULT_VYDRA_IMAGE_MODEL = "grok-imagine";
10
- const DEFAULT_VYDRA_VIDEO_MODEL = "veo3";
11
- const DEFAULT_VYDRA_SPEECH_MODEL = "elevenlabs/tts";
12
- const DEFAULT_VYDRA_VOICE_ID = "21m00Tcm4TlvDq8ikWAM";
13
8
  const DEFAULT_HTTP_TIMEOUT_MS = 12e4;
14
9
  const POLL_INTERVAL_MS = 2500;
15
10
  const MAX_POLL_ATTEMPTS = 120;
@@ -21,21 +16,6 @@ function addUrlValue(value, urls) {
21
16
  }
22
17
  if (Array.isArray(value)) for (const entry of value) addUrlValue(entry, urls);
23
18
  }
24
- function normalizeVydraBaseUrl(value) {
25
- const fallback = DEFAULT_VYDRA_BASE_URL;
26
- const trimmed = normalizeOptionalString(value);
27
- if (!trimmed) return fallback;
28
- try {
29
- const url = new URL(trimmed);
30
- if (url.hostname === "vydra.ai") url.hostname = "www.vydra.ai";
31
- const pathname = url.pathname.replace(/\/+$/u, "");
32
- if (!pathname) url.pathname = "/api/v1";
33
- else url.pathname = pathname;
34
- return url.toString().replace(/\/$/u, "");
35
- } catch {
36
- return fallback;
37
- }
38
- }
39
19
  function resolveVydraBaseUrlFromConfig(cfg) {
40
20
  const models = asOptionalRecord(asOptionalRecord(cfg)?.models);
41
21
  const providers = asOptionalRecord(models?.providers);
@@ -92,15 +72,8 @@ function resolveVydraErrorMessage(payload) {
92
72
  }
93
73
  function extractVydraResultUrls(payload, kind) {
94
74
  const urls = /* @__PURE__ */ new Set();
95
- const preferredKeys = kind === "audio" ? ["audioUrl", "audioUrls"] : kind === "image" ? ["imageUrl", "imageUrls"] : ["videoUrl", "videoUrls"];
96
- const sharedKeys = [
97
- "resultUrl",
98
- "resultUrls",
99
- "outputUrl",
100
- "outputUrls",
101
- "url",
102
- "urls"
103
- ];
75
+ const urlKeys = kind === "audio" ? ["audioUrl", "audioUrls"] : kind === "image" ? ["imageUrl", "imageUrls"] : ["videoUrl", "videoUrls"];
76
+ urlKeys.push("resultUrl", "resultUrls", "outputUrl", "outputUrls", "url", "urls");
104
77
  const recurseKeys = [
105
78
  "output",
106
79
  "outputs",
@@ -118,7 +91,7 @@ function extractVydraResultUrls(payload, kind) {
118
91
  }
119
92
  const object = asOptionalRecord(value);
120
93
  if (!object) return;
121
- for (const key of [...preferredKeys, ...sharedKeys]) addUrlValue(object[key], urls);
94
+ for (const key of urlKeys) addUrlValue(object[key], urls);
122
95
  for (const key of recurseKeys) if (key in object) visit(object[key], depth + 1);
123
96
  };
124
97
  visit(payload);
@@ -176,10 +149,12 @@ async function downloadVydraAsset(params) {
176
149
  onBodyTimeout: () => createVydraTimeoutError(deadline)
177
150
  });
178
151
  const mimeType = result.response.headers.get("content-type")?.trim() || (params.kind === "image" ? "image/png" : params.kind === "audio" ? "audio/mpeg" : "video/mp4");
179
- const buffer = await readResponseWithLimit(result.response, params.maxBytes, {
152
+ const buffer = await readProviderBinaryResponse(result.response, deadline.label, params.kind, {
153
+ maxBytes: params.maxBytes,
154
+ chunkTimeoutMs: 0,
180
155
  timeoutMs: resolveTimeoutMs,
181
156
  onTimeout: () => createVydraTimeoutError(deadline),
182
- onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`Vydra ${params.kind} download exceeds ${maxBytes} bytes`)
157
+ onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`${deadline.label} exceeds ${maxBytes} bytes`)
183
158
  });
184
159
  const extension = resolveVydraFileExtension(params.kind, mimeType);
185
160
  return {
@@ -188,7 +163,7 @@ async function downloadVydraAsset(params) {
188
163
  fileName: `${params.kind === "image" ? "image" : params.kind === "audio" ? "audio" : "video"}-1.${extension}`
189
164
  };
190
165
  } catch (error) {
191
- if (typeof deadline.deadlineAtMs === "number" && Date.now() >= deadline.deadlineAtMs) throw createVydraTimeoutError(deadline);
166
+ if (error instanceof Error && error.name === "TimeoutError") throw createVydraTimeoutError(deadline);
192
167
  throw error;
193
168
  }
194
169
  } finally {
@@ -299,4 +274,4 @@ async function runVydraGeneration(params) {
299
274
  }
300
275
  }
301
276
  //#endregion
302
- export { DEFAULT_VYDRA_BASE_URL, DEFAULT_VYDRA_IMAGE_MODEL, DEFAULT_VYDRA_SPEECH_MODEL, DEFAULT_VYDRA_VIDEO_MODEL, DEFAULT_VYDRA_VOICE_ID, downloadVydraAsset, extractVydraResultUrls, normalizeVydraBaseUrl, runVydraGeneration };
277
+ export { DEFAULT_VYDRA_IMAGE_MODEL, DEFAULT_VYDRA_VIDEO_MODEL, downloadVydraAsset, extractVydraResultUrls, runVydraGeneration };
@@ -1,9 +1,7 @@
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";
1
+ import { DEFAULT_VYDRA_BASE_URL, DEFAULT_VYDRA_SPEECH_MODEL, DEFAULT_VYDRA_VOICE_ID, normalizeVydraBaseUrl } from "./defaults.js";
4
2
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
3
  import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
6
- import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-core";
4
+ import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-provider";
7
5
  //#region extensions/vydra/speech-provider.ts
8
6
  const VYDRA_SPEECH_VOICES = [{
9
7
  id: DEFAULT_VYDRA_VOICE_ID,
@@ -48,10 +46,13 @@ function buildVydraSpeechProvider() {
48
46
  listVoices: async () => VYDRA_SPEECH_VOICES.map((voice) => Object.assign({}, voice)),
49
47
  isConfigured: ({ providerConfig }) => Boolean(resolveSpeechProviderApiKey(readVydraSpeechConfig(providerConfig).apiKey, process.env.VYDRA_API_KEY)),
50
48
  synthesize: async (req) => {
49
+ const { downloadVydraAsset, extractVydraResultUrls } = await import("./shared.js");
51
50
  const config = readVydraSpeechConfig(req.providerConfig);
52
51
  const overrides = readVydraOverrides(req.providerOverrides);
53
52
  const apiKey = resolveSpeechProviderApiKey(config.apiKey, process.env.VYDRA_API_KEY);
54
53
  if (!apiKey) throw new Error("Vydra API key missing");
54
+ const { resolveGeneratedMediaMaxBytes } = await import("openclaw/plugin-sdk/media-generation-runtime");
55
+ const { assertOkOrThrowHttpError, postJsonRequest, readProviderJsonResponse, resolveProviderHttpRequestConfig } = await import("openclaw/plugin-sdk/provider-http");
55
56
  const fetchFn = fetch;
56
57
  const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = resolveProviderHttpRequestConfig({
57
58
  baseUrl: config.baseUrl,
@@ -79,8 +80,7 @@ function buildVydraSpeechProvider() {
79
80
  });
80
81
  try {
81
82
  await assertOkOrThrowHttpError(response, "Vydra speech synthesis failed");
82
- const payload = await readProviderJsonResponse(response, "Vydra speech synthesis");
83
- const audioUrl = extractVydraResultUrls(payload, "audio")[0];
83
+ const audioUrl = extractVydraResultUrls(await readProviderJsonResponse(response, "Vydra speech synthesis"), "audio")[0];
84
84
  if (!audioUrl) throw new Error("Vydra speech synthesis response missing audio URL");
85
85
  const audio = await downloadVydraAsset({
86
86
  url: audioUrl,
@@ -1,4 +1,5 @@
1
- import { DEFAULT_VYDRA_VIDEO_MODEL, runVydraGeneration } from "./shared.js";
1
+ import { DEFAULT_VYDRA_VIDEO_MODEL } from "./defaults.js";
2
+ import { runVydraGeneration } from "./shared.js";
2
3
  import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
3
4
  //#region extensions/vydra/video-generation-provider.ts
4
5
  const VYDRA_KLING_MODEL = "kling";
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "id": "vydra",
3
+ "capabilityCatalogEntry": "./dist/capability-catalog.js",
3
4
  "activation": {
4
5
  "onStartup": false
5
6
  },
6
7
  "enabledByDefault": true,
7
- "providers": ["vydra"],
8
+ "providers": [
9
+ "vydra"
10
+ ],
8
11
  "setup": {
9
12
  "providers": [
10
13
  {
11
14
  "id": "vydra",
12
- "envVars": ["VYDRA_API_KEY"]
15
+ "envVars": [
16
+ "VYDRA_API_KEY"
17
+ ]
13
18
  }
14
19
  ]
15
20
  },
@@ -22,7 +27,9 @@
22
27
  "groupId": "vydra",
23
28
  "groupLabel": "Vydra",
24
29
  "groupHint": "Image, video, and speech",
25
- "onboardingScopes": ["image-generation"],
30
+ "onboardingScopes": [
31
+ "image-generation"
32
+ ],
26
33
  "optionKey": "vydraApiKey",
27
34
  "cliFlag": "--vydra-api-key",
28
35
  "cliOption": "--vydra-api-key <key>",
@@ -30,9 +37,15 @@
30
37
  }
31
38
  ],
32
39
  "contracts": {
33
- "speechProviders": ["vydra"],
34
- "imageGenerationProviders": ["vydra"],
35
- "videoGenerationProviders": ["vydra"]
40
+ "speechProviders": [
41
+ "vydra"
42
+ ],
43
+ "imageGenerationProviders": [
44
+ "vydra"
45
+ ],
46
+ "videoGenerationProviders": [
47
+ "vydra"
48
+ ]
36
49
  },
37
50
  "configSchema": {
38
51
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/vydra-provider",
3
- "version": "2026.9.1",
3
+ "version": "2026.9.3",
4
4
  "description": "OpenClaw Vydra media provider plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.7.2"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.9.1"
21
+ "pluginApi": ">=2026.9.3"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.1",
24
+ "openclawVersion": "2026.9.3",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "peerDependencies": {
41
- "openclaw": ">=2026.9.1"
41
+ "openclaw": ">=2026.9.3"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "openclaw": {