@openclaw/gradium-speech 2026.7.2-beta.5 → 2026.7.33

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,6 +1,5 @@
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";
4
3
  const DEFAULT_GRADIUM_VOICE_ID = "YTpq7expH9539ERJ";
5
4
  const GRADIUM_VOICES = [
6
5
  {
@@ -33,20 +32,7 @@ const GRADIUM_VOICES = [
33
32
  }
34
33
  ];
35
34
  function normalizeGradiumBaseUrl(baseUrl) {
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(/\/+$/, "");
35
+ return (baseUrl?.trim())?.replace(/\/+$/, "") || DEFAULT_GRADIUM_BASE_URL;
50
36
  }
51
37
  //#endregion
52
- export { DEFAULT_GRADIUM_VOICE_ID, GRADIUM_API_HOSTNAME, GRADIUM_VOICES, normalizeGradiumBaseUrl };
38
+ export { DEFAULT_GRADIUM_VOICE_ID, GRADIUM_VOICES, normalizeGradiumBaseUrl };
@@ -1,16 +1,16 @@
1
1
  import { GRADIUM_VOICES, normalizeGradiumBaseUrl } from "./shared.js";
2
2
  import { gradiumTTS } from "./tts.js";
3
- import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
4
3
  import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
5
4
  import { asObject, trimToUndefined } from "openclaw/plugin-sdk/speech";
6
- import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-core";
7
5
  //#region extensions/gradium/speech-provider.ts
6
+ const DEFAULT_GENERATED_AUDIO_MAX_BYTES = 16777216;
8
7
  function normalizeGradiumProviderConfig(rawConfig) {
9
- const raw = asObject(asObject(rawConfig.providers)?.gradium) ?? asObject(rawConfig.gradium);
8
+ const providers = asObject(rawConfig.providers);
9
+ const raw = asObject(providers?.gradium) ?? asObject(rawConfig.gradium);
10
10
  return {
11
11
  apiKey: normalizeResolvedSecretInputString({
12
12
  value: raw?.apiKey,
13
- path: "tts.providers.gradium.apiKey"
13
+ path: "messages.tts.providers.gradium.apiKey"
14
14
  }),
15
15
  baseUrl: normalizeGradiumBaseUrl(trimToUndefined(raw?.baseUrl)),
16
16
  voiceId: trimToUndefined(raw?.voiceId) ?? "YTpq7expH9539ERJ"
@@ -24,17 +24,10 @@ function readGradiumProviderConfig(config) {
24
24
  voiceId: trimToUndefined(config.voiceId) ?? defaults.voiceId
25
25
  };
26
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
- }
27
+ function resolveGeneratedAudioMaxBytes(req) {
28
+ const configured = req.cfg.agents?.defaults?.mediaMaxMb;
29
+ if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) return Math.floor(configured * 1024 * 1024);
30
+ return DEFAULT_GENERATED_AUDIO_MAX_BYTES;
38
31
  }
39
32
  function parseDirectiveToken(ctx) {
40
33
  switch (ctx.key) {
@@ -66,11 +59,11 @@ function buildGradiumSpeechProvider() {
66
59
  id: v.id,
67
60
  name: v.name
68
61
  })),
69
- isConfigured: ({ providerConfig }) => isGradiumProviderConfigured(providerConfig),
62
+ isConfigured: ({ providerConfig }) => Boolean(readGradiumProviderConfig(providerConfig).apiKey || process.env.GRADIUM_API_KEY),
70
63
  synthesize: async (req) => {
71
64
  const config = readGradiumProviderConfig(req.providerConfig);
72
65
  const overrides = req.providerOverrides ?? {};
73
- const apiKey = resolveGradiumApiKey(config.apiKey);
66
+ const apiKey = config.apiKey || process.env.GRADIUM_API_KEY;
74
67
  if (!apiKey) throw new Error("Gradium API key missing");
75
68
  const wantsVoiceNote = req.target === "voice-note";
76
69
  const outputFormat = wantsVoiceNote ? "opus" : "wav";
@@ -82,7 +75,7 @@ function buildGradiumSpeechProvider() {
82
75
  voiceId: trimToUndefined(overrides.voiceId) ?? config.voiceId,
83
76
  outputFormat,
84
77
  timeoutMs: req.timeoutMs,
85
- maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio")
78
+ maxBytes: resolveGeneratedAudioMaxBytes(req)
86
79
  }),
87
80
  outputFormat,
88
81
  fileExtension: wantsVoiceNote ? ".opus" : ".wav",
@@ -92,7 +85,7 @@ function buildGradiumSpeechProvider() {
92
85
  synthesizeTelephony: async (req) => {
93
86
  const config = readGradiumProviderConfig(req.providerConfig);
94
87
  const overrides = req.providerOverrides ?? {};
95
- const apiKey = resolveGradiumApiKey(config.apiKey);
88
+ const apiKey = config.apiKey || process.env.GRADIUM_API_KEY;
96
89
  if (!apiKey) throw new Error("Gradium API key missing");
97
90
  const outputFormat = "ulaw_8000";
98
91
  return {
@@ -103,7 +96,7 @@ function buildGradiumSpeechProvider() {
103
96
  voiceId: trimToUndefined(overrides.voiceId) ?? config.voiceId,
104
97
  outputFormat,
105
98
  timeoutMs: req.timeoutMs,
106
- maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio")
99
+ maxBytes: resolveGeneratedAudioMaxBytes(req)
107
100
  }),
108
101
  outputFormat,
109
102
  sampleRate: 8e3
package/dist/tts.js CHANGED
@@ -1,13 +1,16 @@
1
- import { GRADIUM_API_HOSTNAME, normalizeGradiumBaseUrl } from "./shared.js";
1
+ import { 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";
5
5
  //#region extensions/gradium/tts.ts
6
- const DEFAULT_TTS_MAX_BYTES = 16 * 1024 * 1024;
6
+ const DEFAULT_TTS_MAX_BYTES = 16777216;
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;
9
12
  const { response, release } = await fetchWithSsrFGuard({
10
- url: `${normalizeGradiumBaseUrl(baseUrl)}/api/post/speech/tts`,
13
+ url,
11
14
  init: {
12
15
  method: "POST",
13
16
  headers: {
@@ -23,8 +26,7 @@ async function gradiumTTS(params) {
23
26
  })
24
27
  },
25
28
  timeoutMs,
26
- requireHttps: true,
27
- policy: { hostnameAllowlist: [GRADIUM_API_HOSTNAME] },
29
+ policy: { hostnameAllowlist: [hostname] },
28
30
  auditContext: "gradium.tts"
29
31
  });
30
32
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/gradium-speech",
3
- "version": "2026.7.2-beta.5",
3
+ "version": "2026.7.33",
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.2-beta.5"
21
+ "pluginApi": ">=2026.7.33"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.7.2-beta.5",
24
+ "openclawVersion": "2026.7.33",
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.7.2-beta.5"
41
+ "openclaw": ">=2026.7.33"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "openclaw": {