@openclaw/volcengine-provider 0.0.0 → 2026.8.1-beta.3

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/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # @openclaw/volcengine-provider
1
+ # OpenClaw Volcengine Provider
2
2
 
3
- Reserved placeholder for the official OpenClaw plugin package. Use a published release version instead.
3
+ Official OpenClaw provider plugin for Volcengine models, the Volcengine coding
4
+ plan, and Volcengine Speech text-to-speech.
5
+
6
+ Install from OpenClaw:
7
+
8
+ ```bash
9
+ openclaw plugins install @openclaw/volcengine-provider
10
+ openclaw gateway restart
11
+ ```
12
+
13
+ See <https://docs.openclaw.ai/providers/volcengine> for model and speech setup.
package/dist/api.js ADDED
@@ -0,0 +1,21 @@
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 "./models-BiRjObX0.js";
2
+ import { applyModelCompatPatch } from "openclaw/plugin-sdk/provider-model-shared";
3
+ import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ //#region extensions/volcengine/api.ts
5
+ const VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS = [
6
+ "minLength",
7
+ "maxLength",
8
+ "minItems",
9
+ "maxItems",
10
+ "minContains",
11
+ "maxContains"
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
+ function applyVolcengineToolSchemaCompat(model) {
18
+ return applyModelCompatPatch(model, { unsupportedToolSchemaKeywords: mergeUnsupportedToolSchemaKeywords(model.compat?.unsupportedToolSchemaKeywords) });
19
+ }
20
+ //#endregion
21
+ export { DOUBAO_BASE_URL, DOUBAO_CODING_BASE_URL, DOUBAO_CODING_MODEL_CATALOG, DOUBAO_MODEL_CATALOG, VOLCENGINE_UNSUPPORTED_TOOL_SCHEMA_KEYWORDS, applyVolcengineToolSchemaCompat };
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ import { a as VOLCENGINE_PROVIDER_CATALOG, o as openclaw_plugin_default } from "./models-BiRjObX0.js";
2
+ import { applyVolcengineToolSchemaCompat } from "./api.js";
3
+ import { buildVolcengineSpeechProvider } from "./speech-provider.js";
4
+ import { buildOpenAICompatibleProviderFamilyCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
5
+ import { readManifestProviderDefaultModelRef } from "openclaw/plugin-sdk/provider-catalog-shared";
6
+ import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
7
+ import { ensureModelAllowlistEntry } from "openclaw/plugin-sdk/provider-onboard";
8
+ //#region extensions/volcengine/index.ts
9
+ const PROVIDER_ID = "volcengine";
10
+ const VOLCENGINE_DEFAULT_MODEL_REF = readManifestProviderDefaultModelRef(openclaw_plugin_default, "volcengine-plan");
11
+ var volcengine_default = defineSingleProviderPluginEntry({
12
+ id: PROVIDER_ID,
13
+ name: "Volcengine Provider",
14
+ description: "Bundled Volcengine provider plugin",
15
+ manifest: openclaw_plugin_default,
16
+ provider: {
17
+ label: "Volcengine",
18
+ docsPath: "/concepts/model-providers#volcano-engine-doubao",
19
+ hookAliases: ["volcengine-plan"],
20
+ manifestAuth: {
21
+ defaultModel: VOLCENGINE_DEFAULT_MODEL_REF,
22
+ applyConfig: (cfg) => ensureModelAllowlistEntry({
23
+ cfg,
24
+ modelRef: VOLCENGINE_DEFAULT_MODEL_REF
25
+ })
26
+ },
27
+ ...buildOpenAICompatibleProviderFamilyCatalog({
28
+ credentialProviderId: PROVIDER_ID,
29
+ entries: VOLCENGINE_PROVIDER_CATALOG.entries,
30
+ staticCatalog: VOLCENGINE_PROVIDER_CATALOG.staticCatalog,
31
+ augmentModelCatalog: VOLCENGINE_PROVIDER_CATALOG.augmentModelCatalog
32
+ }),
33
+ normalizeResolvedModel: ({ model }) => applyVolcengineToolSchemaCompat(model)
34
+ },
35
+ register(api) {
36
+ api.registerSpeechProvider(buildVolcengineSpeechProvider());
37
+ }
38
+ });
39
+ //#endregion
40
+ export { volcengine_default as default };
@@ -0,0 +1,306 @@
1
+ import { buildManifestProviderCatalogFamily } from "openclaw/plugin-sdk/provider-catalog-shared";
2
+ //#region extensions/volcengine/openclaw.plugin.json
3
+ var openclaw_plugin_default = {
4
+ id: "volcengine",
5
+ activation: { "onStartup": false },
6
+ enabledByDefault: true,
7
+ providerCatalogEntry: "./provider-discovery.ts",
8
+ providers: ["volcengine", "volcengine-plan"],
9
+ setup: { "providers": [{
10
+ "id": "volcengine",
11
+ "envVars": ["VOLCANO_ENGINE_API_KEY"]
12
+ }, {
13
+ "id": "volcengine-tts",
14
+ "envVars": [
15
+ "VOLCENGINE_TTS_API_KEY",
16
+ "BYTEPLUS_SEED_SPEECH_API_KEY",
17
+ "VOLCENGINE_TTS_APPID",
18
+ "VOLCENGINE_TTS_TOKEN"
19
+ ]
20
+ }] },
21
+ providerAuthAliases: { "volcengine-plan": "volcengine" },
22
+ providerRequest: { "providers": {
23
+ "volcengine": { "openAICompletions": { "supportsStreamingUsage": true } },
24
+ "volcengine-plan": { "openAICompletions": { "supportsStreamingUsage": true } }
25
+ } },
26
+ modelCatalog: {
27
+ "providers": {
28
+ "volcengine": {
29
+ "baseUrl": "https://ark.cn-beijing.volces.com/api/v3",
30
+ "api": "openai-completions",
31
+ "models": [
32
+ {
33
+ "id": "doubao-seed-evolving",
34
+ "name": "Doubao Seed Evolving",
35
+ "reasoning": true,
36
+ "input": ["text", "image"],
37
+ "contextWindow": 1024e3,
38
+ "maxTokens": 256e3,
39
+ "cost": {
40
+ "input": .885478,
41
+ "output": 4.427391,
42
+ "cacheRead": .177096,
43
+ "cacheWrite": 0
44
+ }
45
+ },
46
+ {
47
+ "id": "doubao-seed-2-1-pro-260628",
48
+ "name": "Doubao Seed 2.1 Pro",
49
+ "reasoning": true,
50
+ "input": ["text", "image"],
51
+ "contextWindow": 256e3,
52
+ "maxTokens": 256e3,
53
+ "cost": {
54
+ "input": .885478,
55
+ "output": 4.427391,
56
+ "cacheRead": .177096,
57
+ "cacheWrite": 0
58
+ }
59
+ },
60
+ {
61
+ "id": "doubao-seed-2-1-turbo-260628",
62
+ "name": "Doubao Seed 2.1 Turbo",
63
+ "reasoning": true,
64
+ "input": ["text", "image"],
65
+ "contextWindow": 256e3,
66
+ "maxTokens": 256e3,
67
+ "cost": {
68
+ "input": .442739,
69
+ "output": 2.213695,
70
+ "cacheRead": .088548,
71
+ "cacheWrite": 0
72
+ }
73
+ },
74
+ {
75
+ "id": "glm-5-2-260617",
76
+ "name": "GLM 5.2",
77
+ "reasoning": true,
78
+ "input": ["text"],
79
+ "contextWindow": 1024e3,
80
+ "maxTokens": 128e3,
81
+ "cost": {
82
+ "input": 1.180638,
83
+ "output": 4.132231,
84
+ "cacheRead": .295159,
85
+ "cacheWrite": 0
86
+ }
87
+ },
88
+ {
89
+ "id": "deepseek-v4-pro-260425",
90
+ "name": "DeepSeek V4 Pro",
91
+ "reasoning": true,
92
+ "input": ["text"],
93
+ "contextWindow": 1024e3,
94
+ "maxTokens": 384e3,
95
+ "cost": {
96
+ "input": 1.770956,
97
+ "output": 3.541913,
98
+ "cacheRead": .14758,
99
+ "cacheWrite": 0
100
+ }
101
+ },
102
+ {
103
+ "id": "deepseek-v4-flash-260425",
104
+ "name": "DeepSeek V4 Flash",
105
+ "reasoning": true,
106
+ "input": ["text"],
107
+ "contextWindow": 1024e3,
108
+ "maxTokens": 384e3,
109
+ "cost": {
110
+ "input": .14758,
111
+ "output": .295159,
112
+ "cacheRead": .029516,
113
+ "cacheWrite": 0
114
+ }
115
+ },
116
+ {
117
+ "id": "kimi-k2-5-260127",
118
+ "name": "Kimi K2.5",
119
+ "input": ["text", "image"],
120
+ "contextWindow": 256e3,
121
+ "maxTokens": 4096,
122
+ "cost": {
123
+ "input": 1e-4,
124
+ "output": 2e-4,
125
+ "cacheRead": 0,
126
+ "cacheWrite": 0
127
+ },
128
+ "status": "deprecated",
129
+ "replacedBy": "doubao-seed-evolving"
130
+ },
131
+ {
132
+ "id": "glm-4-7-251222",
133
+ "name": "GLM 4.7",
134
+ "reasoning": true,
135
+ "input": ["text"],
136
+ "contextWindow": 2e5,
137
+ "maxTokens": 128e3,
138
+ "cost": {
139
+ "input": 1e-4,
140
+ "output": 2e-4,
141
+ "cacheRead": 0,
142
+ "cacheWrite": 0
143
+ },
144
+ "status": "deprecated",
145
+ "replacedBy": "glm-5-2-260617"
146
+ },
147
+ {
148
+ "id": "deepseek-v3-2-251201",
149
+ "name": "DeepSeek V3.2",
150
+ "reasoning": true,
151
+ "input": ["text"],
152
+ "contextWindow": 128e3,
153
+ "maxTokens": 32e3,
154
+ "cost": {
155
+ "input": .295159,
156
+ "output": .442739,
157
+ "cacheRead": .059032,
158
+ "cacheWrite": 0,
159
+ "tieredPricing": [{
160
+ "input": .295159,
161
+ "output": .442739,
162
+ "cacheRead": .059032,
163
+ "cacheWrite": 0,
164
+ "range": [0, 32e3]
165
+ }, {
166
+ "input": .590319,
167
+ "output": .885478,
168
+ "cacheRead": .059032,
169
+ "cacheWrite": 0,
170
+ "range": [32e3]
171
+ }]
172
+ },
173
+ "status": "deprecated",
174
+ "replacedBy": "deepseek-v4-flash-260425"
175
+ }
176
+ ]
177
+ },
178
+ "volcengine-plan": {
179
+ "baseUrl": "https://ark.cn-beijing.volces.com/api/coding/v3",
180
+ "api": "openai-completions",
181
+ "defaultModel": "ark-code-latest",
182
+ "models": [
183
+ {
184
+ "id": "ark-code-latest",
185
+ "name": "Ark Coding Plan",
186
+ "input": ["text"],
187
+ "contextWindow": 256e3,
188
+ "maxTokens": 4096,
189
+ "cost": {
190
+ "input": 0,
191
+ "output": 0,
192
+ "cacheRead": 0,
193
+ "cacheWrite": 0
194
+ }
195
+ },
196
+ {
197
+ "id": "doubao-seed-2.1-turbo",
198
+ "name": "Doubao Seed 2.1 Turbo",
199
+ "reasoning": true,
200
+ "input": ["text", "image"],
201
+ "contextWindow": 256e3,
202
+ "maxTokens": 256e3,
203
+ "cost": {
204
+ "input": 0,
205
+ "output": 0,
206
+ "cacheRead": 0,
207
+ "cacheWrite": 0
208
+ }
209
+ },
210
+ {
211
+ "id": "glm-5.2",
212
+ "name": "GLM 5.2",
213
+ "reasoning": true,
214
+ "input": ["text"],
215
+ "contextWindow": 1024e3,
216
+ "maxTokens": 128e3,
217
+ "cost": {
218
+ "input": 0,
219
+ "output": 0,
220
+ "cacheRead": 0,
221
+ "cacheWrite": 0
222
+ },
223
+ "compat": { "codeMode": "capable" }
224
+ },
225
+ {
226
+ "id": "deepseek-v4-pro",
227
+ "name": "DeepSeek V4 Pro",
228
+ "reasoning": true,
229
+ "input": ["text"],
230
+ "contextWindow": 1024e3,
231
+ "maxTokens": 384e3,
232
+ "cost": {
233
+ "input": 0,
234
+ "output": 0,
235
+ "cacheRead": 0,
236
+ "cacheWrite": 0
237
+ },
238
+ "compat": { "codeMode": "capable" }
239
+ },
240
+ {
241
+ "id": "deepseek-v4-flash",
242
+ "name": "DeepSeek V4 Flash",
243
+ "reasoning": true,
244
+ "input": ["text"],
245
+ "contextWindow": 1024e3,
246
+ "maxTokens": 384e3,
247
+ "cost": {
248
+ "input": 0,
249
+ "output": 0,
250
+ "cacheRead": 0,
251
+ "cacheWrite": 0
252
+ },
253
+ "compat": { "codeMode": "capable" }
254
+ }
255
+ ]
256
+ }
257
+ },
258
+ "discovery": {
259
+ "volcengine": "refreshable",
260
+ "volcengine-plan": "refreshable"
261
+ }
262
+ },
263
+ providerAuthChoices: [{
264
+ "provider": "volcengine",
265
+ "method": "api-key",
266
+ "choiceId": "volcengine-api-key",
267
+ "appGuidedSecret": true,
268
+ "choiceLabel": "Volcano Engine API key",
269
+ "groupId": "volcengine",
270
+ "groupLabel": "Volcano Engine",
271
+ "groupHint": "API key",
272
+ "optionKey": "volcengineApiKey",
273
+ "cliFlag": "--volcengine-api-key",
274
+ "cliOption": "--volcengine-api-key <key>",
275
+ "cliDescription": "Volcano Engine API key"
276
+ }],
277
+ configSchema: {
278
+ "type": "object",
279
+ "additionalProperties": false,
280
+ "properties": {}
281
+ },
282
+ contracts: { "speechProviders": [
283
+ "volcengine",
284
+ "bytedance",
285
+ "doubao"
286
+ ] }
287
+ };
288
+ //#endregion
289
+ //#region extensions/volcengine/models.ts
290
+ const VOLCENGINE_PROVIDER_CATALOG = buildManifestProviderCatalogFamily({ surfaces: [{
291
+ id: "volcengine",
292
+ label: "Volcengine",
293
+ catalog: openclaw_plugin_default.modelCatalog.providers.volcengine
294
+ }, {
295
+ id: "volcengine-plan",
296
+ label: "Volcengine Plan",
297
+ catalog: openclaw_plugin_default.modelCatalog.providers["volcengine-plan"]
298
+ }] });
299
+ const DOUBAO_PROVIDER = VOLCENGINE_PROVIDER_CATALOG.entries[0];
300
+ const DOUBAO_CODING_PROVIDER = VOLCENGINE_PROVIDER_CATALOG.entries[1];
301
+ const DOUBAO_BASE_URL = DOUBAO_PROVIDER.baseUrl;
302
+ const DOUBAO_CODING_BASE_URL = DOUBAO_CODING_PROVIDER.baseUrl;
303
+ const DOUBAO_MODEL_CATALOG = DOUBAO_PROVIDER.models;
304
+ const DOUBAO_CODING_MODEL_CATALOG = DOUBAO_CODING_PROVIDER.models;
305
+ //#endregion
306
+ 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 };
package/dist/models.js ADDED
@@ -0,0 +1,2 @@
1
+ import { a as VOLCENGINE_PROVIDER_CATALOG, i as DOUBAO_MODEL_CATALOG, n as DOUBAO_CODING_BASE_URL, r as DOUBAO_CODING_MODEL_CATALOG, t as DOUBAO_BASE_URL } from "./models-BiRjObX0.js";
2
+ export { DOUBAO_BASE_URL, DOUBAO_CODING_BASE_URL, DOUBAO_CODING_MODEL_CATALOG, DOUBAO_MODEL_CATALOG, VOLCENGINE_PROVIDER_CATALOG };
@@ -0,0 +1,5 @@
1
+ import { a as VOLCENGINE_PROVIDER_CATALOG } from "./models-BiRjObX0.js";
2
+ //#region extensions/volcengine/provider-discovery.ts
3
+ var provider_discovery_default = VOLCENGINE_PROVIDER_CATALOG.staticDiscovery;
4
+ //#endregion
5
+ export { provider_discovery_default as default };
@@ -0,0 +1,173 @@
1
+ import { volcengineTTS } from "./tts.js";
2
+ import { asFiniteNumberInRange, asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
4
+ import { parseSpeechDirectiveNumberOverride, resolveSpeechProviderApiKey, trimToUndefined } from "openclaw/plugin-sdk/speech-core";
5
+ //#region extensions/volcengine/speech-provider.ts
6
+ const DEFAULT_VOICE = "en_female_anna_mars_bigtts";
7
+ const DEFAULT_CLUSTER = "volcano_tts";
8
+ const DEFAULT_RESOURCE_ID = "seed-tts-1.0";
9
+ const DEFAULT_APP_KEY = "aGjiRDfUWi";
10
+ const VOLCENGINE_VOICES = [
11
+ "en_female_anna_mars_bigtts",
12
+ "en_male_adam_mars_bigtts",
13
+ "en_female_sarah_mars_bigtts",
14
+ "en_male_smith_mars_bigtts",
15
+ "zh_female_cancan_mars_bigtts",
16
+ "zh_female_qingxinnvsheng_mars_bigtts",
17
+ "zh_female_linjia_mars_bigtts",
18
+ "zh_male_wennuanahu_moon_bigtts",
19
+ "zh_male_shaonianzixin_moon_bigtts",
20
+ "zh_female_shuangkuaisisi_moon_bigtts"
21
+ ];
22
+ function normalizeSpeedRatio(value) {
23
+ return asFiniteNumberInRange(value, {
24
+ min: .2,
25
+ max: 3
26
+ });
27
+ }
28
+ function normalizeVolcengineProviderConfig(rawConfig) {
29
+ const raw = asOptionalRecord(asOptionalRecord(rawConfig.providers)?.volcengine) ?? asOptionalRecord(rawConfig.volcengine);
30
+ return {
31
+ apiKey: normalizeResolvedSecretInputString({
32
+ value: raw?.apiKey,
33
+ path: "tts.providers.volcengine.apiKey"
34
+ }),
35
+ appId: trimToUndefined(raw?.appId),
36
+ token: normalizeResolvedSecretInputString({
37
+ value: raw?.token,
38
+ path: "tts.providers.volcengine.token"
39
+ }),
40
+ voice: trimToUndefined(raw?.voice) ?? trimToUndefined(process.env.VOLCENGINE_TTS_VOICE) ?? DEFAULT_VOICE,
41
+ cluster: trimToUndefined(raw?.cluster) ?? trimToUndefined(process.env.VOLCENGINE_TTS_CLUSTER) ?? DEFAULT_CLUSTER,
42
+ resourceId: trimToUndefined(raw?.resourceId) ?? trimToUndefined(process.env.VOLCENGINE_TTS_RESOURCE_ID) ?? DEFAULT_RESOURCE_ID,
43
+ appKey: trimToUndefined(raw?.appKey) ?? trimToUndefined(process.env.VOLCENGINE_TTS_APP_KEY) ?? DEFAULT_APP_KEY,
44
+ baseUrl: trimToUndefined(raw?.baseUrl) ?? trimToUndefined(process.env.VOLCENGINE_TTS_BASE_URL),
45
+ speedRatio: normalizeSpeedRatio(raw?.speedRatio),
46
+ emotion: trimToUndefined(raw?.emotion)
47
+ };
48
+ }
49
+ function resolveSeedSpeechApiKey(configApiKey) {
50
+ return resolveSpeechProviderApiKey(configApiKey, process.env.VOLCENGINE_TTS_API_KEY, process.env.BYTEPLUS_SEED_SPEECH_API_KEY);
51
+ }
52
+ function resolveLegacyVolcengineCredentials(config) {
53
+ return {
54
+ appId: trimToUndefined(config.appId) ?? trimToUndefined(process.env.VOLCENGINE_TTS_APPID),
55
+ token: resolveSpeechProviderApiKey(config.token, process.env.VOLCENGINE_TTS_TOKEN)
56
+ };
57
+ }
58
+ function readProviderConfig(config) {
59
+ const normalized = normalizeVolcengineProviderConfig({});
60
+ return {
61
+ apiKey: normalizeResolvedSecretInputString({
62
+ value: config.apiKey,
63
+ path: "tts.providers.volcengine.apiKey"
64
+ }) ?? normalized.apiKey,
65
+ appId: trimToUndefined(config.appId) ?? normalized.appId,
66
+ token: trimToUndefined(config.token) ?? normalized.token,
67
+ voice: trimToUndefined(config.voice) ?? normalized.voice,
68
+ cluster: trimToUndefined(config.cluster) ?? normalized.cluster,
69
+ resourceId: trimToUndefined(config.resourceId) ?? normalized.resourceId,
70
+ appKey: trimToUndefined(config.appKey) ?? normalized.appKey,
71
+ baseUrl: trimToUndefined(config.baseUrl) ?? normalized.baseUrl,
72
+ speedRatio: normalizeSpeedRatio(config.speedRatio) ?? normalized.speedRatio,
73
+ emotion: trimToUndefined(config.emotion) ?? normalized.emotion
74
+ };
75
+ }
76
+ function readVolcengineOverrides(overrides) {
77
+ if (!overrides) return {};
78
+ return {
79
+ voice: trimToUndefined(overrides.voice),
80
+ speedRatio: normalizeSpeedRatio(overrides.speedRatio),
81
+ emotion: trimToUndefined(overrides.emotion)
82
+ };
83
+ }
84
+ function parseDirectiveToken(ctx) {
85
+ switch (ctx.key) {
86
+ case "voice":
87
+ case "volcengine_voice":
88
+ case "volcenginevoice":
89
+ if (!ctx.policy.allowVoice) return { handled: true };
90
+ return {
91
+ handled: true,
92
+ overrides: {
93
+ ...ctx.currentOverrides,
94
+ voice: ctx.value
95
+ }
96
+ };
97
+ case "speed":
98
+ case "speedratio":
99
+ case "speed_ratio": return parseSpeechDirectiveNumberOverride({
100
+ ctx,
101
+ overrideKey: "speedRatio",
102
+ range: {
103
+ min: .2,
104
+ max: 3
105
+ },
106
+ warning: (value) => `invalid Volcengine speedRatio "${value}"`,
107
+ mergeCurrentOverrides: true
108
+ });
109
+ case "emotion":
110
+ if (!ctx.policy.allowVoiceSettings) return { handled: true };
111
+ return {
112
+ handled: true,
113
+ overrides: {
114
+ ...ctx.currentOverrides,
115
+ emotion: ctx.value
116
+ }
117
+ };
118
+ default: return { handled: false };
119
+ }
120
+ }
121
+ function buildVolcengineSpeechProvider() {
122
+ return {
123
+ id: "volcengine",
124
+ label: "Volcengine",
125
+ autoSelectOrder: 90,
126
+ aliases: ["bytedance", "doubao"],
127
+ voices: VOLCENGINE_VOICES,
128
+ resolveConfig: ({ rawConfig }) => normalizeVolcengineProviderConfig(rawConfig),
129
+ parseDirectiveToken,
130
+ listVoices: async () => VOLCENGINE_VOICES.map((v) => ({
131
+ id: v,
132
+ name: v.replace(/^(?:en|zh)_(female|male)_/, "").replace(/_.*$/, ""),
133
+ locale: v.startsWith("en_") ? "en-US" : "zh-CN",
134
+ gender: v.includes("_female_") ? "female" : "male"
135
+ })),
136
+ isConfigured: ({ providerConfig }) => {
137
+ const cfg = readProviderConfig(providerConfig);
138
+ const legacy = resolveLegacyVolcengineCredentials(cfg);
139
+ return Boolean(resolveSeedSpeechApiKey(cfg.apiKey) || legacy.appId && legacy.token);
140
+ },
141
+ synthesize: async (req) => {
142
+ const cfg = readProviderConfig(req.providerConfig);
143
+ const overrides = readVolcengineOverrides(req.providerOverrides);
144
+ const apiKey = resolveSeedSpeechApiKey(cfg.apiKey);
145
+ const { appId, token } = resolveLegacyVolcengineCredentials(cfg);
146
+ 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.");
147
+ const isVoiceNote = req.target === "voice-note";
148
+ const encoding = isVoiceNote ? "ogg_opus" : "mp3";
149
+ return {
150
+ audioBuffer: await volcengineTTS({
151
+ text: req.text,
152
+ apiKey,
153
+ appId,
154
+ token,
155
+ voice: overrides.voice ?? cfg.voice,
156
+ cluster: cfg.cluster,
157
+ resourceId: cfg.resourceId,
158
+ appKey: cfg.appKey,
159
+ baseUrl: cfg.baseUrl,
160
+ speedRatio: overrides.speedRatio ?? cfg.speedRatio,
161
+ emotion: overrides.emotion ?? cfg.emotion,
162
+ encoding,
163
+ timeoutMs: req.timeoutMs
164
+ }),
165
+ outputFormat: encoding === "ogg_opus" ? "opus" : "mp3",
166
+ fileExtension: encoding === "ogg_opus" ? ".opus" : ".mp3",
167
+ voiceCompatible: isVoiceNote
168
+ };
169
+ }
170
+ };
171
+ }
172
+ //#endregion
173
+ export { buildVolcengineSpeechProvider };
package/dist/tts.js ADDED
@@ -0,0 +1,171 @@
1
+ import * as crypto from "node:crypto";
2
+ import { canonicalizeBase64 } from "openclaw/plugin-sdk/media-runtime";
3
+ import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
4
+ import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
5
+ //#region extensions/volcengine/tts.ts
6
+ const DEFAULT_SEED_VOICE = "en_female_anna_mars_bigtts";
7
+ const DEFAULT_LEGACY_VOICE = "zh_female_xiaohe_uranus_bigtts";
8
+ const DEFAULT_CLUSTER = "volcano_tts";
9
+ const DEFAULT_SEED_TTS_RESOURCE_ID = "seed-tts-1.0";
10
+ const DEFAULT_SEED_TTS_APP_KEY = "aGjiRDfUWi";
11
+ const VOLCENGINE_TTS_RESPONSE_MAX_BYTES = 16 * 1024 * 1024;
12
+ const BYTEPLUS_SEED_TTS_URL = "https://voice.ap-southeast-1.bytepluses.com/api/v3/tts/unidirectional";
13
+ const VOLCENGINE_LEGACY_TTS_URL = "https://openspeech.bytedance.com/api/v1/tts";
14
+ function parseJsonObject(text, providerName) {
15
+ try {
16
+ const parsed = JSON.parse(text);
17
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("expected JSON object");
18
+ return parsed;
19
+ } catch (err) {
20
+ const detail = err instanceof Error ? err.message : String(err);
21
+ throw new Error(`${providerName} TTS: failed to parse response JSON: ${detail}`, { cause: err });
22
+ }
23
+ }
24
+ function toTtsResponse(parsed) {
25
+ const header = parsed.header && typeof parsed.header === "object" && !Array.isArray(parsed.header) ? parsed.header : void 0;
26
+ return {
27
+ code: typeof parsed.code === "number" ? parsed.code : typeof header?.code === "number" ? header.code : void 0,
28
+ message: typeof parsed.message === "string" ? parsed.message : typeof header?.message === "string" ? header.message : void 0,
29
+ data: typeof parsed.data === "string" ? parsed.data : void 0
30
+ };
31
+ }
32
+ function parseLegacyTtsResponse(text) {
33
+ return toTtsResponse(parseJsonObject(text, "Volcengine"));
34
+ }
35
+ function parseSeedTtsFrames(text) {
36
+ const trimmed = text.trim();
37
+ if (!trimmed) return [];
38
+ try {
39
+ return [toTtsResponse(parseJsonObject(trimmed, "BytePlus Seed Speech"))];
40
+ } catch {}
41
+ const frames = [];
42
+ for (const line of trimmed.split(/\r?\n/)) {
43
+ const item = line.trim();
44
+ if (!item) continue;
45
+ const json = item.startsWith("data:") ? item.slice(5).trim() : item;
46
+ frames.push(toTtsResponse(parseJsonObject(json, "BytePlus Seed Speech")));
47
+ }
48
+ return frames;
49
+ }
50
+ function hostnameAllowlist(url) {
51
+ return [new URL(url).hostname];
52
+ }
53
+ function seedAudioFormat(encoding) {
54
+ return encoding === "wav" ? "pcm" : encoding;
55
+ }
56
+ async function seedSpeechTTS(params) {
57
+ const { text, apiKey, voice = DEFAULT_SEED_VOICE, resourceId = DEFAULT_SEED_TTS_RESOURCE_ID, appKey = DEFAULT_SEED_TTS_APP_KEY, baseUrl = BYTEPLUS_SEED_TTS_URL, speedRatio = 1, emotion, encoding = "ogg_opus", timeoutMs = 3e4 } = params;
58
+ const audioFormat = seedAudioFormat(encoding);
59
+ const payload = JSON.stringify({
60
+ user: { uid: "openclaw" },
61
+ req_params: {
62
+ text,
63
+ speaker: voice,
64
+ audio_params: {
65
+ format: audioFormat,
66
+ sample_rate: 24e3
67
+ },
68
+ ...speedRatio !== 1 ? { speed_ratio: speedRatio } : {},
69
+ ...emotion ? { emotion } : {}
70
+ }
71
+ });
72
+ const { response, release } = await fetchWithSsrFGuard({
73
+ url: baseUrl,
74
+ init: {
75
+ method: "POST",
76
+ headers: {
77
+ "Content-Type": "application/json",
78
+ Connection: "keep-alive",
79
+ "X-Api-Key": apiKey,
80
+ "X-Api-Resource-Id": resourceId,
81
+ "X-Api-App-Key": appKey
82
+ },
83
+ body: payload
84
+ },
85
+ timeoutMs,
86
+ policy: { hostnameAllowlist: hostnameAllowlist(baseUrl) },
87
+ auditContext: "volcengine.tts"
88
+ });
89
+ try {
90
+ const frames = parseSeedTtsFrames(new TextDecoder().decode(await readResponseWithLimit(response, VOLCENGINE_TTS_RESPONSE_MAX_BYTES, { onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`BytePlus Seed Speech TTS response exceeds ${maxBytes} bytes`) })));
91
+ const chunks = [];
92
+ for (const frame of frames) {
93
+ if (frame.code === 0) {
94
+ if (frame.data) {
95
+ const canonicalAudio = canonicalizeBase64(frame.data);
96
+ if (!canonicalAudio) throw new Error("BytePlus Seed Speech TTS returned malformed base64 audio data");
97
+ chunks.push(Buffer.from(canonicalAudio, "base64"));
98
+ }
99
+ continue;
100
+ }
101
+ if (frame.code === 2e7) continue;
102
+ throw new Error(`BytePlus Seed Speech TTS error ${frame.code ?? response.status}: ${frame.message ?? "unknown"}`);
103
+ }
104
+ if (!response.ok || chunks.length === 0) throw new Error(`BytePlus Seed Speech TTS error ${response.status}: no audio data`);
105
+ return Buffer.concat(chunks);
106
+ } finally {
107
+ await release();
108
+ }
109
+ }
110
+ async function legacyVolcengineTTS(params) {
111
+ const { text, appId, token, voice = DEFAULT_LEGACY_VOICE, cluster = DEFAULT_CLUSTER, baseUrl = VOLCENGINE_LEGACY_TTS_URL, speedRatio = 1, volumeRatio = 1, pitchRatio = 1, emotion, encoding = "ogg_opus", timeoutMs = 3e4 } = params;
112
+ const payload = JSON.stringify({
113
+ app: {
114
+ appid: appId,
115
+ token,
116
+ cluster
117
+ },
118
+ user: { uid: "openclaw" },
119
+ audio: {
120
+ voice_type: voice,
121
+ encoding,
122
+ speed_ratio: speedRatio,
123
+ volume_ratio: volumeRatio,
124
+ pitch_ratio: pitchRatio,
125
+ ...emotion ? { emotion } : {}
126
+ },
127
+ request: {
128
+ reqid: crypto.randomUUID(),
129
+ text,
130
+ text_type: "plain",
131
+ operation: "query"
132
+ }
133
+ });
134
+ const { response, release } = await fetchWithSsrFGuard({
135
+ url: baseUrl,
136
+ init: {
137
+ method: "POST",
138
+ headers: {
139
+ "Content-Type": "application/json",
140
+ Authorization: `Bearer;${token}`
141
+ },
142
+ body: payload
143
+ },
144
+ timeoutMs,
145
+ policy: { hostnameAllowlist: hostnameAllowlist(baseUrl) },
146
+ auditContext: "volcengine.tts"
147
+ });
148
+ try {
149
+ const body = parseLegacyTtsResponse(new TextDecoder().decode(await readResponseWithLimit(response, VOLCENGINE_TTS_RESPONSE_MAX_BYTES, { onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`Volcengine TTS response exceeds ${maxBytes} bytes`) })));
150
+ if (!response.ok || body.code !== 3e3 || !body.data) throw new Error(`Volcengine TTS error ${body.code ?? response.status}: ${body.message ?? "unknown"}`);
151
+ const canonicalAudio = canonicalizeBase64(body.data);
152
+ if (!canonicalAudio) throw new Error("Volcengine TTS returned malformed base64 audio data");
153
+ return Buffer.from(canonicalAudio, "base64");
154
+ } finally {
155
+ await release();
156
+ }
157
+ }
158
+ async function volcengineTTS(params) {
159
+ if (params.apiKey) return seedSpeechTTS({
160
+ ...params,
161
+ apiKey: params.apiKey
162
+ });
163
+ if (params.appId && params.token) return legacyVolcengineTTS({
164
+ ...params,
165
+ appId: params.appId,
166
+ token: params.token
167
+ });
168
+ throw new Error("Volcengine TTS credentials missing. Set a BytePlus Seed Speech API key or legacy AppID/token.");
169
+ }
170
+ //#endregion
171
+ export { volcengineTTS };
@@ -0,0 +1,360 @@
1
+ {
2
+ "id": "volcengine",
3
+ "activation": {
4
+ "onStartup": false
5
+ },
6
+ "enabledByDefault": true,
7
+ "providerCatalogEntry": "./provider-discovery.ts",
8
+ "providers": [
9
+ "volcengine",
10
+ "volcengine-plan"
11
+ ],
12
+ "setup": {
13
+ "providers": [
14
+ {
15
+ "id": "volcengine",
16
+ "envVars": [
17
+ "VOLCANO_ENGINE_API_KEY"
18
+ ]
19
+ },
20
+ {
21
+ "id": "volcengine-tts",
22
+ "envVars": [
23
+ "VOLCENGINE_TTS_API_KEY",
24
+ "BYTEPLUS_SEED_SPEECH_API_KEY",
25
+ "VOLCENGINE_TTS_APPID",
26
+ "VOLCENGINE_TTS_TOKEN"
27
+ ]
28
+ }
29
+ ]
30
+ },
31
+ "providerAuthAliases": {
32
+ "volcengine-plan": "volcengine"
33
+ },
34
+ "providerRequest": {
35
+ "providers": {
36
+ "volcengine": {
37
+ "openAICompletions": {
38
+ "supportsStreamingUsage": true
39
+ }
40
+ },
41
+ "volcengine-plan": {
42
+ "openAICompletions": {
43
+ "supportsStreamingUsage": true
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "modelCatalog": {
49
+ "providers": {
50
+ "volcengine": {
51
+ "baseUrl": "https://ark.cn-beijing.volces.com/api/v3",
52
+ "api": "openai-completions",
53
+ "models": [
54
+ {
55
+ "id": "doubao-seed-evolving",
56
+ "name": "Doubao Seed Evolving",
57
+ "reasoning": true,
58
+ "input": [
59
+ "text",
60
+ "image"
61
+ ],
62
+ "contextWindow": 1024000,
63
+ "maxTokens": 256000,
64
+ "cost": {
65
+ "input": 0.885478,
66
+ "output": 4.427391,
67
+ "cacheRead": 0.177096,
68
+ "cacheWrite": 0
69
+ }
70
+ },
71
+ {
72
+ "id": "doubao-seed-2-1-pro-260628",
73
+ "name": "Doubao Seed 2.1 Pro",
74
+ "reasoning": true,
75
+ "input": [
76
+ "text",
77
+ "image"
78
+ ],
79
+ "contextWindow": 256000,
80
+ "maxTokens": 256000,
81
+ "cost": {
82
+ "input": 0.885478,
83
+ "output": 4.427391,
84
+ "cacheRead": 0.177096,
85
+ "cacheWrite": 0
86
+ }
87
+ },
88
+ {
89
+ "id": "doubao-seed-2-1-turbo-260628",
90
+ "name": "Doubao Seed 2.1 Turbo",
91
+ "reasoning": true,
92
+ "input": [
93
+ "text",
94
+ "image"
95
+ ],
96
+ "contextWindow": 256000,
97
+ "maxTokens": 256000,
98
+ "cost": {
99
+ "input": 0.442739,
100
+ "output": 2.213695,
101
+ "cacheRead": 0.088548,
102
+ "cacheWrite": 0
103
+ }
104
+ },
105
+ {
106
+ "id": "glm-5-2-260617",
107
+ "name": "GLM 5.2",
108
+ "reasoning": true,
109
+ "input": [
110
+ "text"
111
+ ],
112
+ "contextWindow": 1024000,
113
+ "maxTokens": 128000,
114
+ "cost": {
115
+ "input": 1.180638,
116
+ "output": 4.132231,
117
+ "cacheRead": 0.295159,
118
+ "cacheWrite": 0
119
+ }
120
+ },
121
+ {
122
+ "id": "deepseek-v4-pro-260425",
123
+ "name": "DeepSeek V4 Pro",
124
+ "reasoning": true,
125
+ "input": [
126
+ "text"
127
+ ],
128
+ "contextWindow": 1024000,
129
+ "maxTokens": 384000,
130
+ "cost": {
131
+ "input": 1.770956,
132
+ "output": 3.541913,
133
+ "cacheRead": 0.14758,
134
+ "cacheWrite": 0
135
+ }
136
+ },
137
+ {
138
+ "id": "deepseek-v4-flash-260425",
139
+ "name": "DeepSeek V4 Flash",
140
+ "reasoning": true,
141
+ "input": [
142
+ "text"
143
+ ],
144
+ "contextWindow": 1024000,
145
+ "maxTokens": 384000,
146
+ "cost": {
147
+ "input": 0.14758,
148
+ "output": 0.295159,
149
+ "cacheRead": 0.029516,
150
+ "cacheWrite": 0
151
+ }
152
+ },
153
+ {
154
+ "id": "kimi-k2-5-260127",
155
+ "name": "Kimi K2.5",
156
+ "input": [
157
+ "text",
158
+ "image"
159
+ ],
160
+ "contextWindow": 256000,
161
+ "maxTokens": 4096,
162
+ "cost": {
163
+ "input": 0.0001,
164
+ "output": 0.0002,
165
+ "cacheRead": 0,
166
+ "cacheWrite": 0
167
+ },
168
+ "status": "deprecated",
169
+ "replacedBy": "doubao-seed-evolving"
170
+ },
171
+ {
172
+ "id": "glm-4-7-251222",
173
+ "name": "GLM 4.7",
174
+ "reasoning": true,
175
+ "input": [
176
+ "text"
177
+ ],
178
+ "contextWindow": 200000,
179
+ "maxTokens": 128000,
180
+ "cost": {
181
+ "input": 0.0001,
182
+ "output": 0.0002,
183
+ "cacheRead": 0,
184
+ "cacheWrite": 0
185
+ },
186
+ "status": "deprecated",
187
+ "replacedBy": "glm-5-2-260617"
188
+ },
189
+ {
190
+ "id": "deepseek-v3-2-251201",
191
+ "name": "DeepSeek V3.2",
192
+ "reasoning": true,
193
+ "input": [
194
+ "text"
195
+ ],
196
+ "contextWindow": 128000,
197
+ "maxTokens": 32000,
198
+ "cost": {
199
+ "input": 0.295159,
200
+ "output": 0.442739,
201
+ "cacheRead": 0.059032,
202
+ "cacheWrite": 0,
203
+ "tieredPricing": [
204
+ {
205
+ "input": 0.295159,
206
+ "output": 0.442739,
207
+ "cacheRead": 0.059032,
208
+ "cacheWrite": 0,
209
+ "range": [
210
+ 0,
211
+ 32000
212
+ ]
213
+ },
214
+ {
215
+ "input": 0.590319,
216
+ "output": 0.885478,
217
+ "cacheRead": 0.059032,
218
+ "cacheWrite": 0,
219
+ "range": [
220
+ 32000
221
+ ]
222
+ }
223
+ ]
224
+ },
225
+ "status": "deprecated",
226
+ "replacedBy": "deepseek-v4-flash-260425"
227
+ }
228
+ ]
229
+ },
230
+ "volcengine-plan": {
231
+ "baseUrl": "https://ark.cn-beijing.volces.com/api/coding/v3",
232
+ "api": "openai-completions",
233
+ "defaultModel": "ark-code-latest",
234
+ "models": [
235
+ {
236
+ "id": "ark-code-latest",
237
+ "name": "Ark Coding Plan",
238
+ "input": [
239
+ "text"
240
+ ],
241
+ "contextWindow": 256000,
242
+ "maxTokens": 4096,
243
+ "cost": {
244
+ "input": 0,
245
+ "output": 0,
246
+ "cacheRead": 0,
247
+ "cacheWrite": 0
248
+ }
249
+ },
250
+ {
251
+ "id": "doubao-seed-2.1-turbo",
252
+ "name": "Doubao Seed 2.1 Turbo",
253
+ "reasoning": true,
254
+ "input": [
255
+ "text",
256
+ "image"
257
+ ],
258
+ "contextWindow": 256000,
259
+ "maxTokens": 256000,
260
+ "cost": {
261
+ "input": 0,
262
+ "output": 0,
263
+ "cacheRead": 0,
264
+ "cacheWrite": 0
265
+ }
266
+ },
267
+ {
268
+ "id": "glm-5.2",
269
+ "name": "GLM 5.2",
270
+ "reasoning": true,
271
+ "input": [
272
+ "text"
273
+ ],
274
+ "contextWindow": 1024000,
275
+ "maxTokens": 128000,
276
+ "cost": {
277
+ "input": 0,
278
+ "output": 0,
279
+ "cacheRead": 0,
280
+ "cacheWrite": 0
281
+ },
282
+ "compat": {
283
+ "codeMode": "capable"
284
+ }
285
+ },
286
+ {
287
+ "id": "deepseek-v4-pro",
288
+ "name": "DeepSeek V4 Pro",
289
+ "reasoning": true,
290
+ "input": [
291
+ "text"
292
+ ],
293
+ "contextWindow": 1024000,
294
+ "maxTokens": 384000,
295
+ "cost": {
296
+ "input": 0,
297
+ "output": 0,
298
+ "cacheRead": 0,
299
+ "cacheWrite": 0
300
+ },
301
+ "compat": {
302
+ "codeMode": "capable"
303
+ }
304
+ },
305
+ {
306
+ "id": "deepseek-v4-flash",
307
+ "name": "DeepSeek V4 Flash",
308
+ "reasoning": true,
309
+ "input": [
310
+ "text"
311
+ ],
312
+ "contextWindow": 1024000,
313
+ "maxTokens": 384000,
314
+ "cost": {
315
+ "input": 0,
316
+ "output": 0,
317
+ "cacheRead": 0,
318
+ "cacheWrite": 0
319
+ },
320
+ "compat": {
321
+ "codeMode": "capable"
322
+ }
323
+ }
324
+ ]
325
+ }
326
+ },
327
+ "discovery": {
328
+ "volcengine": "refreshable",
329
+ "volcengine-plan": "refreshable"
330
+ }
331
+ },
332
+ "providerAuthChoices": [
333
+ {
334
+ "provider": "volcengine",
335
+ "method": "api-key",
336
+ "choiceId": "volcengine-api-key",
337
+ "appGuidedSecret": true,
338
+ "choiceLabel": "Volcano Engine API key",
339
+ "groupId": "volcengine",
340
+ "groupLabel": "Volcano Engine",
341
+ "groupHint": "API key",
342
+ "optionKey": "volcengineApiKey",
343
+ "cliFlag": "--volcengine-api-key",
344
+ "cliOption": "--volcengine-api-key <key>",
345
+ "cliDescription": "Volcano Engine API key"
346
+ }
347
+ ],
348
+ "configSchema": {
349
+ "type": "object",
350
+ "additionalProperties": false,
351
+ "properties": {}
352
+ },
353
+ "contracts": {
354
+ "speechProviders": [
355
+ "volcengine",
356
+ "bytedance",
357
+ "doubao"
358
+ ]
359
+ }
360
+ }
package/package.json CHANGED
@@ -1,14 +1,49 @@
1
1
  {
2
2
  "name": "@openclaw/volcengine-provider",
3
- "version": "0.0.0",
4
- "description": "Reserved package name for an official OpenClaw plugin.",
5
- "license": "MIT",
3
+ "version": "2026.8.1-beta.3",
4
+ "description": "OpenClaw Volcengine provider plugin.",
6
5
  "repository": {
7
6
  "type": "git",
8
- "url": "git+https://github.com/openclaw/openclaw.git"
7
+ "url": "https://github.com/openclaw/openclaw"
9
8
  },
10
- "publishConfig": {
11
- "access": "public",
12
- "tag": "placeholder"
13
- }
9
+ "type": "module",
10
+ "openclaw": {
11
+ "extensions": [
12
+ "./index.ts"
13
+ ],
14
+ "install": {
15
+ "clawhubSpec": "clawhub:@openclaw/volcengine-provider",
16
+ "npmSpec": "@openclaw/volcengine-provider",
17
+ "defaultChoice": "npm",
18
+ "minHostVersion": ">=2026.7.2"
19
+ },
20
+ "compat": {
21
+ "pluginApi": ">=2026.8.1-beta.3"
22
+ },
23
+ "build": {
24
+ "openclawVersion": "2026.8.1-beta.3",
25
+ "bundledDist": false
26
+ },
27
+ "release": {
28
+ "publishToClawHub": true,
29
+ "publishToNpm": true
30
+ },
31
+ "runtimeExtensions": [
32
+ "./dist/index.js"
33
+ ]
34
+ },
35
+ "files": [
36
+ "dist/**",
37
+ "openclaw.plugin.json",
38
+ "README.md"
39
+ ],
40
+ "peerDependencies": {
41
+ "openclaw": ">=2026.8.1-beta.3"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "openclaw": {
45
+ "optional": true
46
+ }
47
+ },
48
+ "bundledDependencies": []
14
49
  }