@openclaw/volcengine-provider 2026.10.10-beta.5 → 2026.11.5-beta.1
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/.setup/{models-BWaO4fQH.mjs → models-CT4qD0X8.mjs} +2 -4
- package/dist/.source-module-urls/b21119036d01a9f12806295d4328fff880271fe0a59c3ada3caae74242b72100.json +1 -0
- package/dist/api.js +5 -8
- package/dist/capability-catalog.js +1 -2
- package/dist/index.js +2 -3
- package/dist/models.js +1 -1
- package/dist/provider-discovery.js +2 -3
- package/dist/speech-provider.js +155 -55
- package/package.json +4 -4
- package/dist/.source-module-urls/e5c7ffb6d1a333c1e9d751c6e738cbbc69208abfacd3082da7ce6b181b2d0fa0.json +0 -1
- package/dist/tts.js +0 -135
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildManifestProviderCatalogFamily } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
2
|
-
|
|
2
|
+
// extensions/volcengine/openclaw.plugin.json
|
|
3
3
|
var openclaw_plugin_default = {
|
|
4
4
|
id: "volcengine",
|
|
5
5
|
categories: ["models"],
|
|
@@ -291,8 +291,7 @@ var openclaw_plugin_default = {
|
|
|
291
291
|
"doubao"
|
|
292
292
|
] }
|
|
293
293
|
};
|
|
294
|
-
|
|
295
|
-
//#region extensions/volcengine/models.ts
|
|
294
|
+
// extensions/volcengine/models.ts
|
|
296
295
|
const VOLCENGINE_PROVIDER_CATALOG = buildManifestProviderCatalogFamily({ surfaces: [{
|
|
297
296
|
id: "volcengine",
|
|
298
297
|
label: "Volcengine",
|
|
@@ -308,5 +307,4 @@ const DOUBAO_BASE_URL = DOUBAO_PROVIDER.baseUrl;
|
|
|
308
307
|
const DOUBAO_CODING_BASE_URL = DOUBAO_CODING_PROVIDER.baseUrl;
|
|
309
308
|
const DOUBAO_MODEL_CATALOG = DOUBAO_PROVIDER.models;
|
|
310
309
|
const DOUBAO_CODING_MODEL_CATALOG = DOUBAO_CODING_PROVIDER.models;
|
|
311
|
-
//#endregion
|
|
312
310
|
export { VOLCENGINE_PROVIDER_CATALOG as a, DOUBAO_MODEL_CATALOG as i, DOUBAO_CODING_BASE_URL as n, openclaw_plugin_default as o, DOUBAO_CODING_MODEL_CATALOG as r, DOUBAO_BASE_URL as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"entries":[{"output":"api.js","source":"extensions/volcengine/api.ts"},{"output":"capability-catalog.js","source":"extensions/volcengine/capability-catalog.ts"},{"output":"index.js","source":"extensions/volcengine/index.ts"},{"output":"models.js","source":"extensions/volcengine/models.ts"},{"output":"provider-discovery.js","source":"extensions/volcengine/provider-discovery.ts"},{"output":"speech-provider.js","source":"extensions/volcengine/speech-provider.ts"}],"chunks":[{"output":".setup/models-CT4qD0X8.mjs","sha256":"0f1b74480a577b09af812db9e575cb021ece18996106abbd37eab9219532da68","facadeSource":null,"sources":["extensions/volcengine/models.ts","extensions/volcengine/openclaw.plugin.json"]},{"output":"api.js","sha256":"1865df28bc95e4b03ce2bb1dcb5bbde5b15deb31efd169c1a18c78f5c5986eb4","facadeSource":"extensions/volcengine/api.ts","sources":["extensions/volcengine/api.ts"]},{"output":"capability-catalog.js","sha256":"c0d9017f49c93ae1115beea4112a4e31f7f61a196376660115018cd9292dacca","facadeSource":"extensions/volcengine/capability-catalog.ts","sources":["extensions/volcengine/capability-catalog.ts"]},{"output":"index.js","sha256":"1f61ba1466d39b86a315d8fd8857bacfda080a1dcc032277870ec2f87cce7abb","facadeSource":"extensions/volcengine/index.ts","sources":["extensions/volcengine/index.ts"]},{"output":"models.js","sha256":"ec1d449dcf78ced7b4d2cb5eebb86c6ba70fd5f5ce4221fcad32cbadf419dcae","facadeSource":"extensions/volcengine/models.ts","sources":[]},{"output":"provider-discovery.js","sha256":"02ee0d2c4cd7fdad002d39b1b9e8522c707f14fde58a135993f971e0adcaaef6","facadeSource":"extensions/volcengine/provider-discovery.ts","sources":["extensions/volcengine/provider-discovery.ts"]},{"output":"speech-provider.js","sha256":"93e357c3dfcaa8d8a2e1ac121e0c2c9f3d87417a166eb03186780daad4f58f59","facadeSource":"extensions/volcengine/speech-provider.ts","sources":["extensions/volcengine/speech-provider.ts"]}],"unrenderedSources":[]}
|
package/dist/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as DOUBAO_MODEL_CATALOG, n as DOUBAO_CODING_BASE_URL, r as DOUBAO_CODING_MODEL_CATALOG, t as DOUBAO_BASE_URL } from "./.setup/models-
|
|
1
|
+
import { i as DOUBAO_MODEL_CATALOG, n as DOUBAO_CODING_BASE_URL, r as DOUBAO_CODING_MODEL_CATALOG, t as DOUBAO_BASE_URL } from "./.setup/models-CT4qD0X8.mjs";
|
|
2
2
|
import { applyModelCompatPatch } from "openclaw/plugin-sdk/provider-model-shared";
|
|
3
3
|
import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
|
|
4
|
+
// extensions/volcengine/api.ts
|
|
5
5
|
const VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS = [
|
|
6
6
|
"minLength",
|
|
7
7
|
"maxLength",
|
|
@@ -10,12 +10,9 @@ const VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS = [
|
|
|
10
10
|
"minContains",
|
|
11
11
|
"maxContains"
|
|
12
12
|
];
|
|
13
|
-
function mergeUnsupportedToolSchemaKeywords(existing) {
|
|
14
|
-
const merged = uniqueStrings([...existing ?? [], ...VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS]);
|
|
15
|
-
return existing?.length === merged.length && existing.every((value, index) => value === merged[index]) ? existing : merged;
|
|
16
|
-
}
|
|
17
13
|
function applyVolcengineToolSchemaCompat(model) {
|
|
18
|
-
|
|
14
|
+
const existing = model.compat?.unsupportedToolSchemaKeywords;
|
|
15
|
+
const merged = uniqueStrings([...existing ?? [], ...VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS]);
|
|
16
|
+
return applyModelCompatPatch(model, { unsupportedToolSchemaKeywords: existing?.length === merged.length && existing.every((value, index) => value === merged[index]) ? existing : merged });
|
|
19
17
|
}
|
|
20
|
-
//#endregion
|
|
21
18
|
export { DOUBAO_BASE_URL, DOUBAO_CODING_BASE_URL, DOUBAO_CODING_MODEL_CATALOG, DOUBAO_MODEL_CATALOG, VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS, applyVolcengineToolSchemaCompat };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { buildVolcengineSpeechProvider } from "./speech-provider.js";
|
|
2
|
-
|
|
2
|
+
// extensions/volcengine/capability-catalog.ts
|
|
3
3
|
var capability_catalog_default = { speechProviders: [buildVolcengineSpeechProvider()] };
|
|
4
|
-
//#endregion
|
|
5
4
|
export { capability_catalog_default as default };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as VOLCENGINE_PROVIDER_CATALOG, o as openclaw_plugin_default } from "./.setup/models-
|
|
1
|
+
import { a as VOLCENGINE_PROVIDER_CATALOG, o as openclaw_plugin_default } from "./.setup/models-CT4qD0X8.mjs";
|
|
2
2
|
import { applyVolcengineToolSchemaCompat } from "./api.js";
|
|
3
3
|
import { buildVolcengineSpeechProvider } from "./speech-provider.js";
|
|
4
4
|
import { buildOpenAICompatibleProviderFamilyCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
5
5
|
import { readManifestProviderDefaultModelRef } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
6
6
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
7
7
|
import { ensureModelAllowlistEntry } from "openclaw/plugin-sdk/provider-onboard";
|
|
8
|
-
|
|
8
|
+
// extensions/volcengine/index.ts
|
|
9
9
|
const PROVIDER_ID = "volcengine";
|
|
10
10
|
const VOLCENGINE_DEFAULT_MODEL_REF = readManifestProviderDefaultModelRef(openclaw_plugin_default, "volcengine-plan");
|
|
11
11
|
var volcengine_default = defineSingleProviderPluginEntry({
|
|
@@ -37,5 +37,4 @@ var volcengine_default = defineSingleProviderPluginEntry({
|
|
|
37
37
|
api.registerSpeechProvider(buildVolcengineSpeechProvider());
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
//#endregion
|
|
41
40
|
export { volcengine_default as default };
|
package/dist/models.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as DOUBAO_BASE_URL, n as DOUBAO_CODING_BASE_URL, r as DOUBAO_CODING_MODEL_CATALOG, i as DOUBAO_MODEL_CATALOG, a as VOLCENGINE_PROVIDER_CATALOG } from "./.setup/models-
|
|
1
|
+
export { t as DOUBAO_BASE_URL, n as DOUBAO_CODING_BASE_URL, r as DOUBAO_CODING_MODEL_CATALOG, i as DOUBAO_MODEL_CATALOG, a as VOLCENGINE_PROVIDER_CATALOG } from "./.setup/models-CT4qD0X8.mjs";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as VOLCENGINE_PROVIDER_CATALOG } from "./.setup/models-
|
|
2
|
-
|
|
1
|
+
import { a as VOLCENGINE_PROVIDER_CATALOG } from "./.setup/models-CT4qD0X8.mjs";
|
|
2
|
+
// extensions/volcengine/provider-discovery.ts
|
|
3
3
|
var provider_discovery_default = VOLCENGINE_PROVIDER_CATALOG.staticDiscovery;
|
|
4
|
-
//#endregion
|
|
5
4
|
export { provider_discovery_default as default };
|
package/dist/speech-provider.js
CHANGED
|
@@ -1,12 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { asFiniteNumberInRange, asOptionalRecord, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
import * as crypto from "node:crypto";
|
|
3
3
|
import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { createSpeechDirectiveParser, resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-provider";
|
|
5
|
+
// extensions/volcengine/speech-provider.ts
|
|
6
6
|
const DEFAULT_VOICE = "en_female_anna_mars_bigtts";
|
|
7
7
|
const DEFAULT_CLUSTER = "volcano_tts";
|
|
8
8
|
const DEFAULT_RESOURCE_ID = "seed-tts-1.0";
|
|
9
9
|
const DEFAULT_APP_KEY = "aGjiRDfUWi";
|
|
10
|
+
const VOLCENGINE_TTS_RESPONSE_MAX_BYTES = 16777216;
|
|
11
|
+
const BYTEPLUS_SEED_TTS_URL = "https://voice.ap-southeast-1.bytepluses.com/api/v3/tts/unidirectional";
|
|
12
|
+
const VOLCENGINE_LEGACY_TTS_URL = "https://openspeech.bytedance.com/api/v1/tts";
|
|
13
|
+
function parseJsonObject(text, providerName) {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(text);
|
|
16
|
+
if (!isRecord(parsed)) throw new Error("expected JSON object");
|
|
17
|
+
return parsed;
|
|
18
|
+
} catch (err) {
|
|
19
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
20
|
+
throw new Error(`${providerName} TTS: failed to parse response JSON: ${detail}`, { cause: err });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function toTtsResponse(parsed) {
|
|
24
|
+
const header = asOptionalRecord(parsed.header);
|
|
25
|
+
return {
|
|
26
|
+
code: typeof parsed.code === "number" ? parsed.code : typeof header?.code === "number" ? header.code : void 0,
|
|
27
|
+
message: typeof parsed.message === "string" ? parsed.message : typeof header?.message === "string" ? header.message : void 0,
|
|
28
|
+
data: typeof parsed.data === "string" ? parsed.data : void 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function parseSeedTtsFrames(text) {
|
|
32
|
+
const trimmed = text.trim();
|
|
33
|
+
if (!trimmed) return [];
|
|
34
|
+
try {
|
|
35
|
+
return [toTtsResponse(parseJsonObject(trimmed, "BytePlus Seed Speech"))];
|
|
36
|
+
} catch {}
|
|
37
|
+
const frames = [];
|
|
38
|
+
for (const line of trimmed.split(/\r?\n/)) {
|
|
39
|
+
const item = line.trim();
|
|
40
|
+
if (!item) continue;
|
|
41
|
+
const json = item.startsWith("data:") ? item.slice(5).trim() : item;
|
|
42
|
+
frames.push(toTtsResponse(parseJsonObject(json, "BytePlus Seed Speech")));
|
|
43
|
+
}
|
|
44
|
+
return frames;
|
|
45
|
+
}
|
|
10
46
|
const VOLCENGINE_VOICES = [
|
|
11
47
|
"en_female_anna_mars_bigtts",
|
|
12
48
|
"en_male_adam_mars_bigtts",
|
|
@@ -27,7 +63,7 @@ function normalizeSpeedRatio(value) {
|
|
|
27
63
|
}
|
|
28
64
|
function normalizeVolcengineProviderConfig(rawConfig) {
|
|
29
65
|
const providers = asOptionalRecord(rawConfig.providers);
|
|
30
|
-
const raw = asOptionalRecord(providers?.volcengine)
|
|
66
|
+
const raw = asOptionalRecord(providers?.volcengine);
|
|
31
67
|
return {
|
|
32
68
|
apiKey: normalizeResolvedSecretInputString({
|
|
33
69
|
value: raw?.apiKey,
|
|
@@ -57,48 +93,34 @@ function resolveLegacyVolcengineCredentials(config) {
|
|
|
57
93
|
};
|
|
58
94
|
}
|
|
59
95
|
function readProviderConfig(config) {
|
|
60
|
-
return normalizeVolcengineProviderConfig({ volcengine: {
|
|
96
|
+
return normalizeVolcengineProviderConfig({ providers: { volcengine: {
|
|
61
97
|
...config,
|
|
62
98
|
token: normalizeOptionalString(config.token)
|
|
63
|
-
} });
|
|
99
|
+
} } });
|
|
64
100
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case "speedratio":
|
|
80
|
-
case "speed_ratio": return parseSpeechDirectiveNumberOverride({
|
|
81
|
-
ctx,
|
|
82
|
-
overrideKey: "speedRatio",
|
|
101
|
+
const parseDirectiveToken = createSpeechDirectiveParser({
|
|
102
|
+
voice: ["allowVoice", [
|
|
103
|
+
"voice",
|
|
104
|
+
"volcengine_voice",
|
|
105
|
+
"volcenginevoice"
|
|
106
|
+
]],
|
|
107
|
+
speedRatio: [
|
|
108
|
+
"allowVoiceSettings",
|
|
109
|
+
[
|
|
110
|
+
"speed",
|
|
111
|
+
"speedratio",
|
|
112
|
+
"speed_ratio"
|
|
113
|
+
],
|
|
114
|
+
{ number: {
|
|
83
115
|
range: {
|
|
84
116
|
min: .2,
|
|
85
117
|
max: 3
|
|
86
118
|
},
|
|
87
|
-
warning: (value) => `invalid Volcengine speedRatio "${value}"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
handled: true,
|
|
94
|
-
overrides: {
|
|
95
|
-
...ctx.currentOverrides,
|
|
96
|
-
emotion: ctx.value
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
default: return { handled: false };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
119
|
+
warning: (value) => `invalid Volcengine speedRatio "${value}"`
|
|
120
|
+
} }
|
|
121
|
+
],
|
|
122
|
+
emotion: ["allowVoiceSettings", ["emotion"]]
|
|
123
|
+
});
|
|
102
124
|
function buildVolcengineSpeechProvider() {
|
|
103
125
|
const isConfigured = ({ providerConfig }) => {
|
|
104
126
|
const cfg = readProviderConfig(providerConfig);
|
|
@@ -129,22 +151,101 @@ function buildVolcengineSpeechProvider() {
|
|
|
129
151
|
if (!apiKey && (!appId || !token)) throw new Error("Volcengine TTS credentials missing. Set VOLCENGINE_TTS_API_KEY, BYTEPLUS_SEED_SPEECH_API_KEY, or legacy VOLCENGINE_TTS_APPID and VOLCENGINE_TTS_TOKEN.");
|
|
130
152
|
const isVoiceNote = req.target === "voice-note";
|
|
131
153
|
const encoding = isVoiceNote ? "ogg_opus" : "mp3";
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
154
|
+
const voice = normalizeOptionalString(overrides?.voice) ?? cfg.voice;
|
|
155
|
+
const { cluster, resourceId, appKey } = cfg;
|
|
156
|
+
const baseUrl = cfg.baseUrl ?? (apiKey ? BYTEPLUS_SEED_TTS_URL : VOLCENGINE_LEGACY_TTS_URL);
|
|
157
|
+
const speedRatio = normalizeSpeedRatio(overrides?.speedRatio) ?? cfg.speedRatio ?? 1;
|
|
158
|
+
const emotion = normalizeOptionalString(overrides?.emotion) ?? cfg.emotion;
|
|
159
|
+
const { text, timeoutMs } = req;
|
|
160
|
+
const { canonicalizeBase64 } = await import("openclaw/plugin-sdk/media-runtime");
|
|
161
|
+
const { readResponseWithLimit } = await import("openclaw/plugin-sdk/response-limit-runtime");
|
|
162
|
+
const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
|
|
163
|
+
const providerName = apiKey ? "BytePlus Seed Speech" : "Volcengine";
|
|
164
|
+
const payload = apiKey ? {
|
|
165
|
+
user: { uid: "openclaw" },
|
|
166
|
+
req_params: {
|
|
167
|
+
text,
|
|
168
|
+
speaker: voice,
|
|
169
|
+
audio_params: {
|
|
170
|
+
format: encoding,
|
|
171
|
+
sample_rate: 24e3
|
|
172
|
+
},
|
|
173
|
+
...speedRatio !== 1 ? { speed_ratio: speedRatio } : {},
|
|
174
|
+
...emotion ? { emotion } : {}
|
|
175
|
+
}
|
|
176
|
+
} : {
|
|
177
|
+
app: {
|
|
178
|
+
appid: appId,
|
|
137
179
|
token,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
speedRatio: normalizeSpeedRatio(overrides?.speedRatio) ?? cfg.speedRatio,
|
|
144
|
-
emotion: normalizeOptionalString(overrides?.emotion) ?? cfg.emotion,
|
|
180
|
+
cluster
|
|
181
|
+
},
|
|
182
|
+
user: { uid: "openclaw" },
|
|
183
|
+
audio: {
|
|
184
|
+
voice_type: voice,
|
|
145
185
|
encoding,
|
|
146
|
-
|
|
147
|
-
|
|
186
|
+
speed_ratio: speedRatio,
|
|
187
|
+
volume_ratio: 1,
|
|
188
|
+
pitch_ratio: 1,
|
|
189
|
+
...emotion ? { emotion } : {}
|
|
190
|
+
},
|
|
191
|
+
request: {
|
|
192
|
+
reqid: crypto.randomUUID(),
|
|
193
|
+
text,
|
|
194
|
+
text_type: "plain",
|
|
195
|
+
operation: "query"
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const { response, release } = await fetchWithSsrFGuard({
|
|
199
|
+
url: baseUrl,
|
|
200
|
+
init: {
|
|
201
|
+
method: "POST",
|
|
202
|
+
headers: {
|
|
203
|
+
"Content-Type": "application/json",
|
|
204
|
+
...apiKey ? {
|
|
205
|
+
Connection: "keep-alive",
|
|
206
|
+
"X-Api-Key": apiKey,
|
|
207
|
+
"X-Api-Resource-Id": resourceId,
|
|
208
|
+
"X-Api-App-Key": appKey
|
|
209
|
+
} : { Authorization: `Bearer;${token}` }
|
|
210
|
+
},
|
|
211
|
+
body: JSON.stringify(payload)
|
|
212
|
+
},
|
|
213
|
+
timeoutMs,
|
|
214
|
+
policy: { hostnameAllowlist: [new URL(baseUrl).hostname] },
|
|
215
|
+
auditContext: "volcengine.tts"
|
|
216
|
+
});
|
|
217
|
+
let audioBuffer;
|
|
218
|
+
try {
|
|
219
|
+
const responseText = new TextDecoder("utf-8", { fatal: true }).decode(await readResponseWithLimit(response, VOLCENGINE_TTS_RESPONSE_MAX_BYTES, { onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`${providerName} TTS response exceeds ${maxBytes} bytes`) }));
|
|
220
|
+
if (!apiKey) {
|
|
221
|
+
const body = toTtsResponse(parseJsonObject(responseText, providerName));
|
|
222
|
+
if (!response.ok || body.code !== 3e3 || !body.data) throw new Error(`Volcengine TTS error ${body.code ?? response.status}: ${body.message ?? "unknown"}`);
|
|
223
|
+
const canonicalAudio = canonicalizeBase64(body.data);
|
|
224
|
+
if (!canonicalAudio) throw new Error("Volcengine TTS returned malformed base64 audio data");
|
|
225
|
+
audioBuffer = Buffer.from(canonicalAudio, "base64");
|
|
226
|
+
} else {
|
|
227
|
+
const frames = parseSeedTtsFrames(responseText);
|
|
228
|
+
const chunks = [];
|
|
229
|
+
for (const frame of frames) {
|
|
230
|
+
if (frame.code === 0) {
|
|
231
|
+
if (frame.data) {
|
|
232
|
+
const canonicalAudio = canonicalizeBase64(frame.data);
|
|
233
|
+
if (!canonicalAudio) throw new Error("BytePlus Seed Speech TTS returned malformed base64 audio data");
|
|
234
|
+
chunks.push(Buffer.from(canonicalAudio, "base64"));
|
|
235
|
+
}
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (frame.code === 2e7) continue;
|
|
239
|
+
throw new Error(`BytePlus Seed Speech TTS error ${frame.code ?? response.status}: ${frame.message ?? "unknown"}`);
|
|
240
|
+
}
|
|
241
|
+
if (!response.ok || chunks.length === 0) throw new Error(`BytePlus Seed Speech TTS error ${response.status}: no audio data`);
|
|
242
|
+
audioBuffer = Buffer.concat(chunks);
|
|
243
|
+
}
|
|
244
|
+
} finally {
|
|
245
|
+
await release();
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
audioBuffer,
|
|
148
249
|
outputFormat: encoding === "ogg_opus" ? "opus" : "mp3",
|
|
149
250
|
fileExtension: encoding === "ogg_opus" ? ".opus" : ".mp3",
|
|
150
251
|
voiceCompatible: isVoiceNote
|
|
@@ -152,5 +253,4 @@ function buildVolcengineSpeechProvider() {
|
|
|
152
253
|
}
|
|
153
254
|
};
|
|
154
255
|
}
|
|
155
|
-
//#endregion
|
|
156
256
|
export { buildVolcengineSpeechProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/volcengine-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.5-beta.1",
|
|
4
4
|
"description": "OpenClaw Volcengine 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.
|
|
21
|
+
"pluginApi": ">=2026.11.5-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.11.5-beta.1",
|
|
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.
|
|
43
|
+
"openclaw": ">=2026.11.5-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"entries":[{"output":"api.js","source":"extensions/volcengine/api.ts"},{"output":"capability-catalog.js","source":"extensions/volcengine/capability-catalog.ts"},{"output":"index.js","source":"extensions/volcengine/index.ts"},{"output":"models.js","source":"extensions/volcengine/models.ts"},{"output":"provider-discovery.js","source":"extensions/volcengine/provider-discovery.ts"},{"output":"speech-provider.js","source":"extensions/volcengine/speech-provider.ts"},{"output":"tts.js","source":"extensions/volcengine/tts.ts"}],"chunks":[{"output":".setup/models-BWaO4fQH.mjs","sha256":"91c11c620900aa1ccbd38618faa10dc230e8ec005480ca0e0cf08424fc51c492","facadeSource":null,"sources":["extensions/volcengine/models.ts","extensions/volcengine/openclaw.plugin.json"]},{"output":"api.js","sha256":"54880f60a8e8099f3f770767f61663741779d4bd70e5249cec4596e8305fd473","facadeSource":"extensions/volcengine/api.ts","sources":["extensions/volcengine/api.ts"]},{"output":"capability-catalog.js","sha256":"4debdfb60fc3de183c072f5fdc3d5273b71d5bddd2b5f7621b76a351afa4aaec","facadeSource":"extensions/volcengine/capability-catalog.ts","sources":["extensions/volcengine/capability-catalog.ts"]},{"output":"index.js","sha256":"67c75790410474d035c824b840a1b166122141d175fb4d1a822666a63a4e7710","facadeSource":"extensions/volcengine/index.ts","sources":["extensions/volcengine/index.ts"]},{"output":"models.js","sha256":"1c2a4a7c23ba4f5b1c3e98784671dbf9ff2b3aa53519c250d9aa2707e5e0733a","facadeSource":"extensions/volcengine/models.ts","sources":[]},{"output":"provider-discovery.js","sha256":"91f92d813fe903d85217aca5deecf5a6b7bc66f10ee4816c4dcc25b3bbfd2248","facadeSource":"extensions/volcengine/provider-discovery.ts","sources":["extensions/volcengine/provider-discovery.ts"]},{"output":"speech-provider.js","sha256":"f17b48a4eb4ec2c193a3768b0aa3440654bf9bc6c624a94fbee65bc51a212ef4","facadeSource":"extensions/volcengine/speech-provider.ts","sources":["extensions/volcengine/speech-provider.ts"]},{"output":"tts.js","sha256":"a49a0e10728eceb61209991f2b7775b39403ad654f744762346e5e739f2ebe28","facadeSource":"extensions/volcengine/tts.ts","sources":["extensions/volcengine/tts.ts"]}],"unrenderedSources":[]}
|
package/dist/tts.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
-
import * as crypto from "node:crypto";
|
|
3
|
-
//#region extensions/volcengine/tts.ts
|
|
4
|
-
const DEFAULT_SEED_VOICE = "en_female_anna_mars_bigtts";
|
|
5
|
-
const DEFAULT_LEGACY_VOICE = "zh_female_xiaohe_uranus_bigtts";
|
|
6
|
-
const DEFAULT_CLUSTER = "volcano_tts";
|
|
7
|
-
const DEFAULT_SEED_TTS_RESOURCE_ID = "seed-tts-1.0";
|
|
8
|
-
const DEFAULT_SEED_TTS_APP_KEY = "aGjiRDfUWi";
|
|
9
|
-
const VOLCENGINE_TTS_RESPONSE_MAX_BYTES = 16777216;
|
|
10
|
-
const BYTEPLUS_SEED_TTS_URL = "https://voice.ap-southeast-1.bytepluses.com/api/v3/tts/unidirectional";
|
|
11
|
-
const VOLCENGINE_LEGACY_TTS_URL = "https://openspeech.bytedance.com/api/v1/tts";
|
|
12
|
-
function parseJsonObject(text, providerName) {
|
|
13
|
-
try {
|
|
14
|
-
const parsed = JSON.parse(text);
|
|
15
|
-
if (!isRecord(parsed)) throw new Error("expected JSON object");
|
|
16
|
-
return parsed;
|
|
17
|
-
} catch (err) {
|
|
18
|
-
const detail = err instanceof Error ? err.message : String(err);
|
|
19
|
-
throw new Error(`${providerName} TTS: failed to parse response JSON: ${detail}`, { cause: err });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function toTtsResponse(parsed) {
|
|
23
|
-
const header = asOptionalRecord(parsed.header);
|
|
24
|
-
return {
|
|
25
|
-
code: typeof parsed.code === "number" ? parsed.code : typeof header?.code === "number" ? header.code : void 0,
|
|
26
|
-
message: typeof parsed.message === "string" ? parsed.message : typeof header?.message === "string" ? header.message : void 0,
|
|
27
|
-
data: typeof parsed.data === "string" ? parsed.data : void 0
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function parseSeedTtsFrames(text) {
|
|
31
|
-
const trimmed = text.trim();
|
|
32
|
-
if (!trimmed) return [];
|
|
33
|
-
try {
|
|
34
|
-
return [toTtsResponse(parseJsonObject(trimmed, "BytePlus Seed Speech"))];
|
|
35
|
-
} catch {}
|
|
36
|
-
const frames = [];
|
|
37
|
-
for (const line of trimmed.split(/\r?\n/)) {
|
|
38
|
-
const item = line.trim();
|
|
39
|
-
if (!item) continue;
|
|
40
|
-
const json = item.startsWith("data:") ? item.slice(5).trim() : item;
|
|
41
|
-
frames.push(toTtsResponse(parseJsonObject(json, "BytePlus Seed Speech")));
|
|
42
|
-
}
|
|
43
|
-
return frames;
|
|
44
|
-
}
|
|
45
|
-
async function volcengineTTS(params) {
|
|
46
|
-
if (!params.apiKey && (!params.appId || !params.token)) throw new Error("Volcengine TTS credentials missing. Set a BytePlus Seed Speech API key or legacy AppID/token.");
|
|
47
|
-
const { text, apiKey, appId, token, voice = apiKey ? DEFAULT_SEED_VOICE : DEFAULT_LEGACY_VOICE, cluster = DEFAULT_CLUSTER, resourceId = DEFAULT_SEED_TTS_RESOURCE_ID, appKey = DEFAULT_SEED_TTS_APP_KEY, baseUrl = apiKey ? BYTEPLUS_SEED_TTS_URL : VOLCENGINE_LEGACY_TTS_URL, speedRatio = 1, emotion, encoding = "ogg_opus", timeoutMs = 3e4 } = params;
|
|
48
|
-
const { canonicalizeBase64 } = await import("openclaw/plugin-sdk/media-runtime");
|
|
49
|
-
const { readResponseWithLimit } = await import("openclaw/plugin-sdk/response-limit-runtime");
|
|
50
|
-
const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
|
|
51
|
-
const providerName = apiKey ? "BytePlus Seed Speech" : "Volcengine";
|
|
52
|
-
const payload = apiKey ? {
|
|
53
|
-
user: { uid: "openclaw" },
|
|
54
|
-
req_params: {
|
|
55
|
-
text,
|
|
56
|
-
speaker: voice,
|
|
57
|
-
audio_params: {
|
|
58
|
-
format: encoding === "wav" ? "pcm" : encoding,
|
|
59
|
-
sample_rate: 24e3
|
|
60
|
-
},
|
|
61
|
-
...speedRatio !== 1 ? { speed_ratio: speedRatio } : {},
|
|
62
|
-
...emotion ? { emotion } : {}
|
|
63
|
-
}
|
|
64
|
-
} : {
|
|
65
|
-
app: {
|
|
66
|
-
appid: appId,
|
|
67
|
-
token,
|
|
68
|
-
cluster
|
|
69
|
-
},
|
|
70
|
-
user: { uid: "openclaw" },
|
|
71
|
-
audio: {
|
|
72
|
-
voice_type: voice,
|
|
73
|
-
encoding,
|
|
74
|
-
speed_ratio: speedRatio,
|
|
75
|
-
volume_ratio: 1,
|
|
76
|
-
pitch_ratio: 1,
|
|
77
|
-
...emotion ? { emotion } : {}
|
|
78
|
-
},
|
|
79
|
-
request: {
|
|
80
|
-
reqid: crypto.randomUUID(),
|
|
81
|
-
text,
|
|
82
|
-
text_type: "plain",
|
|
83
|
-
operation: "query"
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const { response, release } = await fetchWithSsrFGuard({
|
|
87
|
-
url: baseUrl,
|
|
88
|
-
init: {
|
|
89
|
-
method: "POST",
|
|
90
|
-
headers: {
|
|
91
|
-
"Content-Type": "application/json",
|
|
92
|
-
...apiKey ? {
|
|
93
|
-
Connection: "keep-alive",
|
|
94
|
-
"X-Api-Key": apiKey,
|
|
95
|
-
"X-Api-Resource-Id": resourceId,
|
|
96
|
-
"X-Api-App-Key": appKey
|
|
97
|
-
} : { Authorization: `Bearer;${token}` }
|
|
98
|
-
},
|
|
99
|
-
body: JSON.stringify(payload)
|
|
100
|
-
},
|
|
101
|
-
timeoutMs,
|
|
102
|
-
policy: { hostnameAllowlist: [new URL(baseUrl).hostname] },
|
|
103
|
-
auditContext: "volcengine.tts"
|
|
104
|
-
});
|
|
105
|
-
try {
|
|
106
|
-
const responseText = new TextDecoder("utf-8", { fatal: true }).decode(await readResponseWithLimit(response, VOLCENGINE_TTS_RESPONSE_MAX_BYTES, { onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`${providerName} TTS response exceeds ${maxBytes} bytes`) }));
|
|
107
|
-
if (!apiKey) {
|
|
108
|
-
const body = toTtsResponse(parseJsonObject(responseText, providerName));
|
|
109
|
-
if (!response.ok || body.code !== 3e3 || !body.data) throw new Error(`Volcengine TTS error ${body.code ?? response.status}: ${body.message ?? "unknown"}`);
|
|
110
|
-
const canonicalAudio = canonicalizeBase64(body.data);
|
|
111
|
-
if (!canonicalAudio) throw new Error("Volcengine TTS returned malformed base64 audio data");
|
|
112
|
-
return Buffer.from(canonicalAudio, "base64");
|
|
113
|
-
}
|
|
114
|
-
const frames = parseSeedTtsFrames(responseText);
|
|
115
|
-
const chunks = [];
|
|
116
|
-
for (const frame of frames) {
|
|
117
|
-
if (frame.code === 0) {
|
|
118
|
-
if (frame.data) {
|
|
119
|
-
const canonicalAudio = canonicalizeBase64(frame.data);
|
|
120
|
-
if (!canonicalAudio) throw new Error("BytePlus Seed Speech TTS returned malformed base64 audio data");
|
|
121
|
-
chunks.push(Buffer.from(canonicalAudio, "base64"));
|
|
122
|
-
}
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
if (frame.code === 2e7) continue;
|
|
126
|
-
throw new Error(`BytePlus Seed Speech TTS error ${frame.code ?? response.status}: ${frame.message ?? "unknown"}`);
|
|
127
|
-
}
|
|
128
|
-
if (!response.ok || chunks.length === 0) throw new Error(`BytePlus Seed Speech TTS error ${response.status}: no audio data`);
|
|
129
|
-
return Buffer.concat(chunks);
|
|
130
|
-
} finally {
|
|
131
|
-
await release();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
export { volcengineTTS };
|