@openclaw/gradium-speech 2026.11.3 → 2026.11.5-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.
@@ -0,0 +1 @@
1
+ {"version":3,"entries":[{"output":"capability-catalog.js","source":"extensions/gradium/capability-catalog.ts"},{"output":"index.js","source":"extensions/gradium/index.ts"},{"output":"speech-provider.js","source":"extensions/gradium/speech-provider.ts"}],"chunks":[{"output":"capability-catalog.js","sha256":"1278a115b88deea97ccacd2fea928197628bf3d95a00d476bf5c38504f3d8ac1","facadeSource":"extensions/gradium/capability-catalog.ts","sources":["extensions/gradium/capability-catalog.ts"]},{"output":"index.js","sha256":"f8dccfc96a366e970f9a70e86931f70c56c2d3455cdbcbb1a560c373113f6f40","facadeSource":"extensions/gradium/index.ts","sources":["extensions/gradium/index.ts"]},{"output":"speech-provider.js","sha256":"b7ecac8532d65cfb1834a9b73902cead7b6a7411509b939e901d385c8735ee9d","facadeSource":"extensions/gradium/speech-provider.ts","sources":["extensions/gradium/speech-provider.ts"]}],"unrenderedSources":[]}
@@ -1,26 +1,69 @@
1
- import { GRADIUM_VOICES, normalizeGradiumBaseUrl } from "./shared.js";
2
- import { gradiumTTS } from "./tts.js";
3
1
  import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
4
- import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-provider";
2
+ import { createSpeechDirectiveParser, resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-provider";
5
3
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
4
  //#region extensions/gradium/speech-provider.ts
5
+ const DEFAULT_GRADIUM_BASE_URL = "https://api.gradium.ai";
6
+ const GRADIUM_API_HOSTNAME = "api.gradium.ai";
7
+ const DEFAULT_GRADIUM_VOICE_ID = "YTpq7expH9539ERJ";
8
+ const GRADIUM_VOICES = [
9
+ {
10
+ id: "YTpq7expH9539ERJ",
11
+ name: "Emma"
12
+ },
13
+ {
14
+ id: "LFZvm12tW_z0xfGo",
15
+ name: "Kent"
16
+ },
17
+ {
18
+ id: "Eu9iL_CYe8N-Gkx_",
19
+ name: "Tiffany"
20
+ },
21
+ {
22
+ id: "2H4HY2CBNyJHBCrP",
23
+ name: "Christina"
24
+ },
25
+ {
26
+ id: "jtEKaLYNn6iif5PR",
27
+ name: "Sydney"
28
+ },
29
+ {
30
+ id: "KWJiFWu2O9nMPYcR",
31
+ name: "John"
32
+ },
33
+ {
34
+ id: "3jUdJyOi9pgbxBTK",
35
+ name: "Arthur"
36
+ }
37
+ ];
38
+ function normalizeGradiumBaseUrl(baseUrl) {
39
+ const raw = baseUrl?.trim() || DEFAULT_GRADIUM_BASE_URL;
40
+ const url = URL.parse(raw);
41
+ if (!url) throw new Error("Gradium baseUrl must be a valid https URL");
42
+ url.username = "";
43
+ url.password = "";
44
+ url.search = "";
45
+ url.hash = "";
46
+ if (url.protocol !== "https:") throw new Error("Gradium baseUrl must use https");
47
+ if (url.hostname.toLowerCase() !== GRADIUM_API_HOSTNAME) throw new Error("Gradium baseUrl must target api.gradium.ai");
48
+ return url.toString().replace(/\/+$/, "");
49
+ }
7
50
  function normalizeGradiumProviderConfig(rawConfig) {
8
51
  const providers = asOptionalRecord(rawConfig.providers);
9
- const raw = asOptionalRecord(providers?.gradium) ?? asOptionalRecord(rawConfig.gradium);
52
+ const raw = asOptionalRecord(providers?.gradium);
10
53
  return {
11
54
  apiKey: normalizeResolvedSecretInputString({
12
55
  value: raw?.apiKey,
13
56
  path: "tts.providers.gradium.apiKey"
14
57
  }),
15
58
  baseUrl: normalizeGradiumBaseUrl(normalizeOptionalString(raw?.baseUrl)),
16
- voiceId: normalizeOptionalString(raw?.voiceId) ?? "YTpq7expH9539ERJ"
59
+ voiceId: normalizeOptionalString(raw?.voiceId) ?? DEFAULT_GRADIUM_VOICE_ID
17
60
  };
18
61
  }
19
62
  function readGradiumProviderConfig(config) {
20
- return normalizeGradiumProviderConfig({ gradium: {
63
+ return normalizeGradiumProviderConfig({ providers: { gradium: {
21
64
  ...config,
22
65
  apiKey: normalizeOptionalString(config.apiKey)
23
- } });
66
+ } } });
24
67
  }
25
68
  function resolveGradiumApiKey(configApiKey) {
26
69
  return resolveSpeechProviderApiKey(normalizeOptionalString(configApiKey), process.env.GRADIUM_API_KEY);
@@ -30,15 +73,43 @@ async function synthesizeGradium(req, outputFormat) {
30
73
  const apiKey = resolveGradiumApiKey(config.apiKey);
31
74
  if (!apiKey) throw new Error("Gradium API key missing");
32
75
  const { resolveGeneratedMediaMaxBytes } = await import("openclaw/plugin-sdk/media-generation-runtime");
33
- return await gradiumTTS({
34
- text: req.text,
35
- apiKey,
36
- baseUrl: config.baseUrl,
37
- voiceId: normalizeOptionalString(req.providerOverrides?.voiceId) ?? config.voiceId,
38
- outputFormat,
39
- timeoutMs: req.timeoutMs,
40
- maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio")
76
+ const text = req.text;
77
+ const voiceId = normalizeOptionalString(req.providerOverrides?.voiceId) ?? config.voiceId;
78
+ const timeoutMs = req.timeoutMs;
79
+ const maxBytes = resolveGeneratedMediaMaxBytes(req.cfg, "audio");
80
+ const url = `${config.baseUrl}/api/post/speech/tts`;
81
+ const { assertOkOrThrowProviderError, readProviderBinaryResponse } = await import("openclaw/plugin-sdk/provider-http");
82
+ const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
83
+ const { response, release } = await fetchWithSsrFGuard({
84
+ url,
85
+ init: {
86
+ method: "POST",
87
+ headers: {
88
+ "x-api-key": apiKey,
89
+ "Content-Type": "application/json"
90
+ },
91
+ body: JSON.stringify({
92
+ text,
93
+ voice_id: voiceId,
94
+ only_audio: true,
95
+ output_format: outputFormat,
96
+ json_config: JSON.stringify({ padding_bonus: 0 })
97
+ })
98
+ },
99
+ timeoutMs,
100
+ requireHttps: true,
101
+ policy: { hostnameAllowlist: [GRADIUM_API_HOSTNAME] },
102
+ auditContext: "gradium.tts"
41
103
  });
104
+ try {
105
+ await assertOkOrThrowProviderError(response, "Gradium API error", { requestHeaders: { "x-api-key": apiKey } });
106
+ return await readProviderBinaryResponse(response, "Gradium API error", "audio", {
107
+ maxBytes,
108
+ onOverflow: ({ maxBytes: maxBytesLocal }) => /* @__PURE__ */ new Error(`Gradium TTS audio response exceeds ${maxBytesLocal} bytes`)
109
+ });
110
+ } finally {
111
+ await release();
112
+ }
42
113
  }
43
114
  function isGradiumProviderConfigured(config) {
44
115
  if (!resolveGradiumApiKey(config.apiKey)) return false;
@@ -49,22 +120,13 @@ function isGradiumProviderConfigured(config) {
49
120
  return false;
50
121
  }
51
122
  }
52
- function parseDirectiveToken(ctx) {
53
- if (![
54
- "voice",
55
- "voice_id",
56
- "voiceid",
57
- "gradium_voice",
58
- "gradiumvoice"
59
- ].includes(ctx.key)) return { handled: false };
60
- return ctx.policy.allowVoice ? {
61
- handled: true,
62
- overrides: {
63
- ...ctx.currentOverrides,
64
- voiceId: ctx.value
65
- }
66
- } : { handled: true };
67
- }
123
+ const parseDirectiveToken = createSpeechDirectiveParser({ voiceId: ["allowVoice", [
124
+ "voice",
125
+ "voice_id",
126
+ "voiceid",
127
+ "gradium_voice",
128
+ "gradiumvoice"
129
+ ]] });
68
130
  function buildGradiumSpeechProvider() {
69
131
  const isConfigured = ({ providerConfig }) => isGradiumProviderConfigured(providerConfig);
70
132
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/gradium-speech",
3
- "version": "2026.11.3",
3
+ "version": "2026.11.5-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.11.3"
21
+ "pluginApi": ">=2026.11.5-beta.2"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.11.3",
24
+ "openclawVersion": "2026.11.5-beta.2",
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.11.3"
43
+ "openclaw": ">=2026.11.5-beta.2"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {
package/dist/shared.js DELETED
@@ -1,48 +0,0 @@
1
- //#region extensions/gradium/shared.ts
2
- const DEFAULT_GRADIUM_BASE_URL = "https://api.gradium.ai";
3
- const GRADIUM_API_HOSTNAME = "api.gradium.ai";
4
- const DEFAULT_GRADIUM_VOICE_ID = "YTpq7expH9539ERJ";
5
- const GRADIUM_VOICES = [
6
- {
7
- id: "YTpq7expH9539ERJ",
8
- name: "Emma"
9
- },
10
- {
11
- id: "LFZvm12tW_z0xfGo",
12
- name: "Kent"
13
- },
14
- {
15
- id: "Eu9iL_CYe8N-Gkx_",
16
- name: "Tiffany"
17
- },
18
- {
19
- id: "2H4HY2CBNyJHBCrP",
20
- name: "Christina"
21
- },
22
- {
23
- id: "jtEKaLYNn6iif5PR",
24
- name: "Sydney"
25
- },
26
- {
27
- id: "KWJiFWu2O9nMPYcR",
28
- name: "John"
29
- },
30
- {
31
- id: "3jUdJyOi9pgbxBTK",
32
- name: "Arthur"
33
- }
34
- ];
35
- function normalizeGradiumBaseUrl(baseUrl) {
36
- const raw = baseUrl?.trim() || DEFAULT_GRADIUM_BASE_URL;
37
- const url = URL.parse(raw);
38
- if (!url) throw new Error("Gradium baseUrl must be a valid https URL");
39
- url.username = "";
40
- url.password = "";
41
- url.search = "";
42
- url.hash = "";
43
- if (url.protocol !== "https:") throw new Error("Gradium baseUrl must use https");
44
- if (url.hostname.toLowerCase() !== "api.gradium.ai") throw new Error("Gradium baseUrl must target api.gradium.ai");
45
- return url.toString().replace(/\/+$/, "");
46
- }
47
- //#endregion
48
- export { DEFAULT_GRADIUM_VOICE_ID, GRADIUM_API_HOSTNAME, GRADIUM_VOICES, normalizeGradiumBaseUrl };
package/dist/tts.js DELETED
@@ -1,41 +0,0 @@
1
- import { GRADIUM_API_HOSTNAME, normalizeGradiumBaseUrl } from "./shared.js";
2
- //#region extensions/gradium/tts.ts
3
- const DEFAULT_TTS_MAX_BYTES = 16777216;
4
- async function gradiumTTS(params) {
5
- const { text, apiKey, baseUrl, voiceId, outputFormat, timeoutMs, maxBytes = DEFAULT_TTS_MAX_BYTES } = params;
6
- const url = `${normalizeGradiumBaseUrl(baseUrl)}/api/post/speech/tts`;
7
- const { assertOkOrThrowProviderError, readProviderBinaryResponse } = await import("openclaw/plugin-sdk/provider-http");
8
- const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
9
- const { response, release } = await fetchWithSsrFGuard({
10
- url,
11
- init: {
12
- method: "POST",
13
- headers: {
14
- "x-api-key": apiKey,
15
- "Content-Type": "application/json"
16
- },
17
- body: JSON.stringify({
18
- text,
19
- voice_id: voiceId,
20
- only_audio: true,
21
- output_format: outputFormat,
22
- json_config: JSON.stringify({ padding_bonus: 0 })
23
- })
24
- },
25
- timeoutMs,
26
- requireHttps: true,
27
- policy: { hostnameAllowlist: [GRADIUM_API_HOSTNAME] },
28
- auditContext: "gradium.tts"
29
- });
30
- try {
31
- await assertOkOrThrowProviderError(response, "Gradium API error", { requestHeaders: { "x-api-key": apiKey } });
32
- return await readProviderBinaryResponse(response, "Gradium API error", "audio", {
33
- maxBytes,
34
- onOverflow: ({ maxBytes: maxBytesLocal }) => /* @__PURE__ */ new Error(`Gradium TTS audio response exceeds ${maxBytesLocal} bytes`)
35
- });
36
- } finally {
37
- await release();
38
- }
39
- }
40
- //#endregion
41
- export { gradiumTTS };