@openclaw/vydra-provider 2026.9.6 → 2026.9.7

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/assets/icon.png CHANGED
Binary file
package/dist/shared.js CHANGED
@@ -16,12 +16,6 @@ function addUrlValue(value, urls) {
16
16
  }
17
17
  if (Array.isArray(value)) for (const entry of value) addUrlValue(entry, urls);
18
18
  }
19
- function resolveVydraBaseUrlFromConfig(cfg) {
20
- const models = asOptionalRecord(asOptionalRecord(cfg)?.models);
21
- const providers = asOptionalRecord(models?.providers);
22
- const vydra = asOptionalRecord(providers?.vydra);
23
- return normalizeVydraBaseUrl(normalizeOptionalString(vydra?.baseUrl));
24
- }
25
19
  async function resolveVydraRequestContext(params) {
26
20
  const auth = await resolveApiKeyForProvider({
27
21
  provider: "vydra",
@@ -33,7 +27,7 @@ async function resolveVydraRequestContext(params) {
33
27
  const fetchFn = fetch;
34
28
  const providerConfig = params.cfg.models?.providers?.vydra;
35
29
  const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = resolveProviderHttpRequestConfig({
36
- baseUrl: resolveVydraBaseUrlFromConfig(params.cfg),
30
+ baseUrl: normalizeVydraBaseUrl(providerConfig?.baseUrl),
37
31
  defaultBaseUrl: DEFAULT_VYDRA_BASE_URL,
38
32
  defaultHeaders: {
39
33
  Authorization: `Bearer ${auth.apiKey}`,
@@ -61,7 +55,7 @@ function resolveVydraResponseJobId(payload) {
61
55
  return normalizeOptionalString(object?.jobId) ?? normalizeOptionalString(object?.id);
62
56
  }
63
57
  function resolveVydraResponseStatus(payload) {
64
- return normalizeOptionalLowercaseString(normalizeOptionalString(asOptionalRecord(payload)?.status));
58
+ return normalizeOptionalLowercaseString(asOptionalRecord(payload)?.status);
65
59
  }
66
60
  function resolveVydraErrorMessage(payload) {
67
61
  const object = asOptionalRecord(payload);
@@ -72,8 +66,16 @@ function resolveVydraErrorMessage(payload) {
72
66
  }
73
67
  function extractVydraResultUrls(payload, kind) {
74
68
  const urls = /* @__PURE__ */ new Set();
75
- const urlKeys = kind === "audio" ? ["audioUrl", "audioUrls"] : kind === "image" ? ["imageUrl", "imageUrls"] : ["videoUrl", "videoUrls"];
76
- urlKeys.push("resultUrl", "resultUrls", "outputUrl", "outputUrls", "url", "urls");
69
+ const urlKeys = [
70
+ `${kind}Url`,
71
+ `${kind}Urls`,
72
+ "resultUrl",
73
+ "resultUrls",
74
+ "outputUrl",
75
+ "outputUrls",
76
+ "url",
77
+ "urls"
78
+ ];
77
79
  const recurseKeys = [
78
80
  "output",
79
81
  "outputs",
@@ -143,40 +145,41 @@ async function downloadVydraAsset(params) {
143
145
  ...headers ? { headers } : {}
144
146
  }, resolveTimeoutMs(), params.fetchFn, resolveVydraGuardedRequestOptions(params.requestPolicy));
145
147
  try {
146
- try {
147
- await assertOkOrThrowHttpError(result.response, `Vydra ${params.kind} download failed`, {
148
- bodyTimeoutMs: resolveTimeoutMs,
149
- onBodyTimeout: () => createVydraTimeoutError(deadline)
150
- });
151
- const mimeType = result.response.headers.get("content-type")?.trim() || (params.kind === "image" ? "image/png" : params.kind === "audio" ? "audio/mpeg" : "video/mp4");
152
- const buffer = await readProviderBinaryResponse(result.response, deadline.label, params.kind, {
153
- maxBytes: params.maxBytes,
154
- chunkTimeoutMs: 0,
155
- timeoutMs: resolveTimeoutMs,
156
- onTimeout: () => createVydraTimeoutError(deadline),
157
- onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`${deadline.label} exceeds ${maxBytes} bytes`)
158
- });
159
- const extension = resolveVydraFileExtension(params.kind, mimeType);
160
- return {
161
- buffer,
162
- mimeType,
163
- fileName: `${params.kind === "image" ? "image" : params.kind === "audio" ? "audio" : "video"}-1.${extension}`
164
- };
165
- } catch (error) {
166
- if (error instanceof Error && error.name === "TimeoutError") throw createVydraTimeoutError(deadline);
167
- throw error;
168
- }
148
+ await assertOkOrThrowHttpError(result.response, `Vydra ${params.kind} download failed`, {
149
+ bodyTimeoutMs: resolveTimeoutMs,
150
+ onBodyTimeout: () => createVydraTimeoutError(deadline)
151
+ });
152
+ const mimeType = result.response.headers.get("content-type")?.trim() || (params.kind === "image" ? "image/png" : params.kind === "audio" ? "audio/mpeg" : "video/mp4");
153
+ const buffer = await readProviderBinaryResponse(result.response, deadline.label, params.kind, {
154
+ maxBytes: params.maxBytes,
155
+ chunkTimeoutMs: 0,
156
+ timeoutMs: resolveTimeoutMs,
157
+ onTimeout: () => createVydraTimeoutError(deadline),
158
+ onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`${deadline.label} exceeds ${maxBytes} bytes`)
159
+ });
160
+ const extension = resolveVydraFileExtension(params.kind, mimeType);
161
+ return {
162
+ buffer,
163
+ mimeType,
164
+ fileName: `${params.kind}-1.${extension}`
165
+ };
166
+ } catch (error) {
167
+ if (error instanceof Error && error.name === "TimeoutError") throw createVydraTimeoutError(deadline);
168
+ throw error;
169
169
  } finally {
170
170
  await result.release();
171
171
  }
172
172
  }
173
- async function waitForVydraJob(params) {
173
+ async function resolveCompletedVydraPayload(params) {
174
+ if (resolveVydraResponseStatus(params.submitted) === "completed" || extractVydraResultUrls(params.submitted, params.kind).length > 0) return params.submitted;
175
+ const jobId = resolveVydraResponseJobId(params.submitted);
176
+ if (!jobId) throw new Error(resolveVydraErrorMessage(params.submitted) ?? params.missingJobIdMessage);
174
177
  const deadline = params.deadline ?? createProviderOperationDeadline({
175
178
  timeoutMs: params.timeoutMs,
176
- label: `Vydra job ${params.jobId}`
179
+ label: `Vydra job ${jobId}`
177
180
  });
178
181
  return await pollProviderOperationJson({
179
- url: `${params.baseUrl}/jobs/${params.jobId}`,
182
+ url: `${params.baseUrl}/jobs/${jobId}`,
180
183
  headers: params.requestPolicy.headers,
181
184
  deadline,
182
185
  defaultTimeoutMs: DEFAULT_HTTP_TIMEOUT_MS,
@@ -184,7 +187,7 @@ async function waitForVydraJob(params) {
184
187
  maxAttempts: MAX_POLL_ATTEMPTS,
185
188
  pollIntervalMs: POLL_INTERVAL_MS,
186
189
  requestFailedMessage: "Vydra job status request failed",
187
- timeoutMessage: `Vydra job ${params.jobId} did not finish in time`,
190
+ timeoutMessage: `Vydra job ${jobId} did not finish in time`,
188
191
  allowPrivateNetwork: params.requestPolicy.allowPrivateNetwork,
189
192
  ssrfPolicy: params.requestPolicy.ssrfPolicy,
190
193
  dispatcherPolicy: params.requestPolicy.dispatcherPolicy,
@@ -192,24 +195,10 @@ async function waitForVydraJob(params) {
192
195
  isComplete: (payload) => resolveVydraResponseStatus(payload) === "completed" || extractVydraResultUrls(payload, params.kind).length > 0,
193
196
  getFailureMessage: (payload) => {
194
197
  const status = resolveVydraResponseStatus(payload);
195
- return status === "failed" || status === "error" || status === "cancelled" ? resolveVydraErrorMessage(payload) ?? `Vydra job ${params.jobId} failed` : void 0;
198
+ return status === "failed" || status === "error" || status === "cancelled" ? resolveVydraErrorMessage(payload) ?? `Vydra job ${jobId} failed` : void 0;
196
199
  }
197
200
  });
198
201
  }
199
- async function resolveCompletedVydraPayload(params) {
200
- if (resolveVydraResponseStatus(params.submitted) === "completed" || extractVydraResultUrls(params.submitted, params.kind).length > 0) return params.submitted;
201
- const jobId = resolveVydraResponseJobId(params.submitted);
202
- if (!jobId) throw new Error(resolveVydraErrorMessage(params.submitted) ?? params.missingJobIdMessage);
203
- return waitForVydraJob({
204
- baseUrl: params.baseUrl,
205
- jobId,
206
- timeoutMs: params.timeoutMs,
207
- ...params.deadline ? { deadline: params.deadline } : {},
208
- fetchFn: params.fetchFn,
209
- kind: params.kind,
210
- requestPolicy: params.requestPolicy
211
- });
212
- }
213
202
  async function runVydraGeneration(params) {
214
203
  const { fetchFn, baseUrl, requestPolicy } = await resolveVydraRequestContext({
215
204
  cfg: params.cfg,
@@ -29,13 +29,6 @@ function readVydraSpeechConfig(config) {
29
29
  voiceId: normalizeOptionalString(config.voiceId) ?? normalized.voiceId
30
30
  };
31
31
  }
32
- function readVydraOverrides(overrides) {
33
- if (!overrides) return {};
34
- return {
35
- model: normalizeOptionalString(overrides.model),
36
- voiceId: normalizeOptionalString(overrides.voiceId)
37
- };
38
- }
39
32
  function buildVydraSpeechProvider() {
40
33
  return {
41
34
  id: "vydra",
@@ -48,7 +41,7 @@ function buildVydraSpeechProvider() {
48
41
  synthesize: async (req) => {
49
42
  const { downloadVydraAsset, extractVydraResultUrls } = await import("./shared.js");
50
43
  const config = readVydraSpeechConfig(req.providerConfig);
51
- const overrides = readVydraOverrides(req.providerOverrides);
44
+ const overrides = req.providerOverrides;
52
45
  const apiKey = resolveSpeechProviderApiKey(config.apiKey, process.env.VYDRA_API_KEY);
53
46
  if (!apiKey) throw new Error("Vydra API key missing");
54
47
  const { resolveGeneratedMediaMaxBytes } = await import("openclaw/plugin-sdk/media-generation-runtime");
@@ -67,11 +60,11 @@ function buildVydraSpeechProvider() {
67
60
  transport: "http"
68
61
  });
69
62
  const { response, release } = await postJsonRequest({
70
- url: `${baseUrl}/models/${overrides.model ?? config.model}`,
63
+ url: `${baseUrl}/models/${normalizeOptionalString(overrides?.model) ?? config.model}`,
71
64
  headers,
72
65
  body: {
73
66
  text: req.text,
74
- voice_id: overrides.voiceId ?? config.voiceId
67
+ voice_id: normalizeOptionalString(overrides?.voiceId) ?? config.voiceId
75
68
  },
76
69
  timeoutMs: req.timeoutMs,
77
70
  fetchFn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/vydra-provider",
3
- "version": "2026.9.6",
3
+ "version": "2026.9.7",
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.6"
21
+ "pluginApi": ">=2026.9.7"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.6",
24
+ "openclawVersion": "2026.9.7",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -40,7 +40,7 @@
40
40
  "assets/activity.svg"
41
41
  ],
42
42
  "peerDependencies": {
43
- "openclaw": ">=2026.9.6"
43
+ "openclaw": ">=2026.9.7"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {