@openclaw/gradium-speech 2026.7.1 → 2026.7.2-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/dist/shared.js CHANGED
@@ -1,5 +1,6 @@
1
1
  //#region extensions/gradium/shared.ts
2
2
  const DEFAULT_GRADIUM_BASE_URL = "https://api.gradium.ai";
3
+ const GRADIUM_API_HOSTNAME = "api.gradium.ai";
3
4
  const DEFAULT_GRADIUM_VOICE_ID = "YTpq7expH9539ERJ";
4
5
  const GRADIUM_VOICES = [
5
6
  {
@@ -32,7 +33,20 @@ const GRADIUM_VOICES = [
32
33
  }
33
34
  ];
34
35
  function normalizeGradiumBaseUrl(baseUrl) {
35
- return (baseUrl?.trim())?.replace(/\/+$/, "") || DEFAULT_GRADIUM_BASE_URL;
36
+ const raw = baseUrl?.trim() || DEFAULT_GRADIUM_BASE_URL;
37
+ let url;
38
+ try {
39
+ url = new URL(raw);
40
+ } catch {
41
+ throw new Error("Gradium baseUrl must be a valid https URL");
42
+ }
43
+ url.username = "";
44
+ url.password = "";
45
+ url.search = "";
46
+ url.hash = "";
47
+ if (url.protocol !== "https:") throw new Error("Gradium baseUrl must use https");
48
+ if (url.hostname.toLowerCase() !== "api.gradium.ai") throw new Error("Gradium baseUrl must target api.gradium.ai");
49
+ return url.toString().replace(/\/+$/, "");
36
50
  }
37
51
  //#endregion
38
- export { DEFAULT_GRADIUM_VOICE_ID, GRADIUM_VOICES, normalizeGradiumBaseUrl };
52
+ export { DEFAULT_GRADIUM_VOICE_ID, GRADIUM_API_HOSTNAME, GRADIUM_VOICES, normalizeGradiumBaseUrl };
@@ -2,6 +2,7 @@ import { GRADIUM_VOICES, normalizeGradiumBaseUrl } from "./shared.js";
2
2
  import { gradiumTTS } from "./tts.js";
3
3
  import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
4
4
  import { asObject, trimToUndefined } from "openclaw/plugin-sdk/speech";
5
+ import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-core";
5
6
  //#region extensions/gradium/speech-provider.ts
6
7
  const DEFAULT_GENERATED_AUDIO_MAX_BYTES = 16 * 1024 * 1024;
7
8
  function normalizeGradiumProviderConfig(rawConfig) {
@@ -23,6 +24,18 @@ function readGradiumProviderConfig(config) {
23
24
  voiceId: trimToUndefined(config.voiceId) ?? defaults.voiceId
24
25
  };
25
26
  }
27
+ function resolveGradiumApiKey(configApiKey) {
28
+ return resolveSpeechProviderApiKey(trimToUndefined(configApiKey), process.env.GRADIUM_API_KEY);
29
+ }
30
+ function isGradiumProviderConfigured(config) {
31
+ if (!resolveGradiumApiKey(config.apiKey)) return false;
32
+ try {
33
+ normalizeGradiumBaseUrl(trimToUndefined(config.baseUrl));
34
+ return true;
35
+ } catch {
36
+ return false;
37
+ }
38
+ }
26
39
  function resolveGeneratedAudioMaxBytes(req) {
27
40
  const configured = req.cfg.agents?.defaults?.mediaMaxMb;
28
41
  if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) return Math.floor(configured * 1024 * 1024);
@@ -58,11 +71,11 @@ function buildGradiumSpeechProvider() {
58
71
  id: v.id,
59
72
  name: v.name
60
73
  })),
61
- isConfigured: ({ providerConfig }) => Boolean(readGradiumProviderConfig(providerConfig).apiKey || process.env.GRADIUM_API_KEY),
74
+ isConfigured: ({ providerConfig }) => isGradiumProviderConfigured(providerConfig),
62
75
  synthesize: async (req) => {
63
76
  const config = readGradiumProviderConfig(req.providerConfig);
64
77
  const overrides = req.providerOverrides ?? {};
65
- const apiKey = config.apiKey || process.env.GRADIUM_API_KEY;
78
+ const apiKey = resolveGradiumApiKey(config.apiKey);
66
79
  if (!apiKey) throw new Error("Gradium API key missing");
67
80
  const wantsVoiceNote = req.target === "voice-note";
68
81
  const outputFormat = wantsVoiceNote ? "opus" : "wav";
@@ -84,7 +97,7 @@ function buildGradiumSpeechProvider() {
84
97
  synthesizeTelephony: async (req) => {
85
98
  const config = readGradiumProviderConfig(req.providerConfig);
86
99
  const overrides = req.providerOverrides ?? {};
87
- const apiKey = config.apiKey || process.env.GRADIUM_API_KEY;
100
+ const apiKey = resolveGradiumApiKey(config.apiKey);
88
101
  if (!apiKey) throw new Error("Gradium API key missing");
89
102
  const outputFormat = "ulaw_8000";
90
103
  return {
package/dist/tts.js CHANGED
@@ -1,4 +1,4 @@
1
- import { normalizeGradiumBaseUrl } from "./shared.js";
1
+ import { GRADIUM_API_HOSTNAME, normalizeGradiumBaseUrl } from "./shared.js";
2
2
  import { assertOkOrThrowProviderError } from "openclaw/plugin-sdk/provider-http";
3
3
  import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
4
4
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
@@ -6,11 +6,8 @@ import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
6
6
  const DEFAULT_TTS_MAX_BYTES = 16 * 1024 * 1024;
7
7
  async function gradiumTTS(params) {
8
8
  const { text, apiKey, baseUrl, voiceId, outputFormat, timeoutMs, maxBytes = DEFAULT_TTS_MAX_BYTES } = params;
9
- const normalizedBaseUrl = normalizeGradiumBaseUrl(baseUrl);
10
- const url = `${normalizedBaseUrl}/api/post/speech/tts`;
11
- const hostname = new URL(normalizedBaseUrl).hostname;
12
9
  const { response, release } = await fetchWithSsrFGuard({
13
- url,
10
+ url: `${normalizeGradiumBaseUrl(baseUrl)}/api/post/speech/tts`,
14
11
  init: {
15
12
  method: "POST",
16
13
  headers: {
@@ -26,7 +23,8 @@ async function gradiumTTS(params) {
26
23
  })
27
24
  },
28
25
  timeoutMs,
29
- policy: { hostnameAllowlist: [hostname] },
26
+ requireHttps: true,
27
+ policy: { hostnameAllowlist: [GRADIUM_API_HOSTNAME] },
30
28
  auditContext: "gradium.tts"
31
29
  });
32
30
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/gradium-speech",
3
- "version": "2026.7.1",
3
+ "version": "2026.7.2-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/gradium-speech",
9
- "version": "2026.7.1"
9
+ "version": "2026.7.2-beta.2"
10
10
  }
11
11
  }
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/gradium-speech",
3
- "version": "2026.7.1",
3
+ "version": "2026.7.2-beta.2",
4
4
  "description": "OpenClaw Gradium speech plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.6.8"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.7.1"
21
+ "pluginApi": ">=2026.7.2-beta.2"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.7.1",
24
+ "openclawVersion": "2026.7.2-beta.2",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -39,7 +39,7 @@
39
39
  "README.md"
40
40
  ],
41
41
  "peerDependencies": {
42
- "openclaw": ">=2026.7.1"
42
+ "openclaw": ">=2026.7.2-beta.2"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "openclaw": {