@volcengine/speech-cli 0.0.0-stage → 0.1.41

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ # @volcengine/speech-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 火山引擎豆包语音 CLI,支持语音合成、录音识别、音频生成和 Skill 更新。
4
+
5
+ ## 运行要求
6
+
7
+ Node.js 16 或更高版本,支持 macOS、Linux、Windows 的 x64 和 arm64。
8
+
9
+ ## 快速开始
10
+
11
+ ```sh
12
+ speech-cli auth login
13
+ speech-cli tts --text '你好,欢迎使用豆包语音。' --output hello.mp3
14
+ ```
15
+
16
+ 使用 `speech-cli auth status` 查看登录状态,使用 `speech-cli --help` 查看完整命令。
17
+
18
+ ## 常用命令
19
+
20
+ | 任务 | 命令 |
21
+ | --- | --- |
22
+ | 语音合成 | `speech-cli tts` |
23
+ | 录音识别 | `speech-cli asr --audio-file meeting.wav` |
24
+ | 音频生成 | `speech-cli audio create` |
25
+ | 查询生成任务 | `speech-cli audio get` |
26
+ | 查看版本 | `speech-cli --version` |
27
+
28
+ 具体参数请运行对应命令的 `--help`,例如 `speech-cli audio create --help`。
29
+
30
+ ## 更新 Skill
31
+
32
+ 更新指定 Skill;尚未安装时会自动安装:
33
+
34
+ ```sh
35
+ speech-cli skills update seedaudio15-pe
36
+ ```
37
+
38
+ 可同时传入多个名称。需要安装或更新本站全部 Skill 时,运行 `speech-cli skills update`。
39
+
40
+ 默认目录为 `~/.agents/skills`,可用 `--skills-dir` 指定其他目录。
41
+
42
+ ## 许可
43
+
44
+ [Apache-2.0](./LICENSE)。开源组件信息见 [Third-party software notice](<./Third-party software notice.md>),也可运行 `speech-cli licenses` 查看。
@@ -0,0 +1,39 @@
1
+ # Third-party software notice
2
+
3
+ This notice covers the Volcengine edition of Speech CLI, built with the
4
+ `volcengine` Go build tag, for macOS, Linux and Windows. It lists the
5
+ runtime and direct and transitive dependencies included in this edition.
6
+
7
+ The npm/BNPM launcher uses Node.js built-in modules and has no third-party npm
8
+ runtime dependencies. Build and release tooling dependencies, separately
9
+ distributed Skills and their example dependencies are outside this notice.
10
+
11
+ ## Components
12
+
13
+ | Component name | License name | Component address |
14
+ | --- | --- | --- |
15
+ | Go runtime and standard library | BSD 3-Clause License | https://go.dev/ |
16
+ | google/uuid | BSD 3-Clause License | https://github.com/google/uuid |
17
+ | inconshreveable/mousetrap | Apache License 2.0 | https://github.com/inconshreveable/mousetrap |
18
+ | jmespath/go-jmespath | Apache License 2.0 | https://github.com/jmespath/go-jmespath |
19
+ | spf13/cobra | Apache License 2.0 | https://github.com/spf13/cobra |
20
+ | spf13/pflag | BSD 3-Clause License | https://github.com/spf13/pflag |
21
+ | volcengine/ve-tos-golang-sdk | Apache License 2.0 | https://github.com/volcengine/ve-tos-golang-sdk |
22
+ | golang.org/x/crypto | BSD 3-Clause License | https://github.com/golang/crypto |
23
+ | golang.org/x/net | BSD 3-Clause License | https://github.com/golang/net |
24
+ | golang.org/x/sync | BSD 3-Clause License | https://github.com/golang/sync |
25
+ | golang.org/x/sys | BSD 3-Clause License | https://github.com/golang/sys |
26
+ | golang.org/x/term | BSD 3-Clause License | https://github.com/golang/term |
27
+ | golang.org/x/text | BSD 3-Clause License | https://github.com/golang/text |
28
+ | go-yaml/yaml | Apache License 2.0; MIT License (libyaml-derived code) | https://github.com/go-yaml/yaml |
29
+ | cenkalti/backoff | MIT License | https://github.com/cenkalti/backoff |
30
+ | volcengine/volc-sdk-golang | Apache License 2.0 | https://github.com/volcengine/volc-sdk-golang |
31
+ | volcengine/volcengine-go-sdk | Apache License 2.0 | https://github.com/volcengine/volcengine-go-sdk |
32
+ | @user_3cc1fcfa/doubao-seeduplex (embedded Web Demo) | MIT License (declared by upstream) | https://skillhub.cn/ |
33
+
34
+ `mousetrap` is used on Windows. `golang.org/x/crypto` is included through the
35
+ Go standard library. The applicable Go toolchain version is recorded in each
36
+ binary's build information.
37
+
38
+ The embedded Web Demo is derived from the named SkillHub component. This entry
39
+ covers the copy embedded in the CLI, not the separately distributed Skill.
package/lib/archive.js ADDED
@@ -0,0 +1,80 @@
1
+ /*!
2
+ * Copyright 2026 Volcengine
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ "use strict";
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.extractBinary = extractBinary;
20
+ const node_zlib_1 = require("node:zlib");
21
+ // Accept the current binary + notice layout and historical binary-only ZIPs.
22
+ // The caller verifies the archive SHA-256 before extracting anything.
23
+ function extractBinary(archive, member, expectedSize) {
24
+ const notice = "Third-party software notice.md";
25
+ const end = archive.length - 22;
26
+ if (end < 0 || archive.readUInt32LE(end) !== 0x06054b50
27
+ || archive.readUInt16LE(end + 4) !== 0 || archive.readUInt16LE(end + 6) !== 0
28
+ || archive.readUInt16LE(end + 20) !== 0)
29
+ throw new Error("Invalid release ZIP");
30
+ const count = archive.readUInt16LE(end + 10);
31
+ if ((count !== 1 && count !== 2) || archive.readUInt16LE(end + 8) !== count)
32
+ throw new Error("Unexpected ZIP member count");
33
+ const central = archive.readUInt32LE(end + 16);
34
+ if (central + archive.readUInt32LE(end + 12) !== end)
35
+ throw new Error("Invalid ZIP directory");
36
+ const seen = new Set();
37
+ const ranges = [];
38
+ let cursor = central;
39
+ let binary;
40
+ for (let index = 0; index < count; index++) {
41
+ if (cursor + 46 > end || archive.readUInt32LE(cursor) !== 0x02014b50)
42
+ throw new Error("Invalid ZIP directory");
43
+ const flags = archive.readUInt16LE(cursor + 8);
44
+ const method = archive.readUInt16LE(cursor + 10);
45
+ const compressed = archive.readUInt32LE(cursor + 20);
46
+ const size = archive.readUInt32LE(cursor + 24);
47
+ const nameLength = archive.readUInt16LE(cursor + 28);
48
+ const next = cursor + 46 + nameLength + archive.readUInt16LE(cursor + 30) + archive.readUInt16LE(cursor + 32);
49
+ if (next > end)
50
+ throw new Error("Invalid ZIP directory");
51
+ const name = archive.subarray(cursor + 46, cursor + 46 + nameLength).toString("utf8");
52
+ const kind = (archive.readUInt32LE(cursor + 38) >>> 16) & 0xf000;
53
+ if (seen.has(name) || (name !== member && name !== notice) || (kind !== 0 && kind !== 0x8000)
54
+ || flags & 1 || (method !== 0 && method !== 8) || archive.readUInt16LE(cursor + 34) !== 0
55
+ || (name === member ? size !== expectedSize || size > 64 * 1024 * 1024 : size === 0 || size > 1024 * 1024))
56
+ throw new Error("Unexpected ZIP member");
57
+ seen.add(name);
58
+ const local = archive.readUInt32LE(cursor + 42);
59
+ if (local + 30 > central || archive.readUInt32LE(local) !== 0x04034b50
60
+ || archive.readUInt16LE(local + 6) !== flags || archive.readUInt16LE(local + 8) !== method)
61
+ throw new Error("Invalid ZIP member data");
62
+ const localNameLength = archive.readUInt16LE(local + 26);
63
+ const start = local + 30 + localNameLength + archive.readUInt16LE(local + 28);
64
+ if (start + compressed > central || archive.subarray(local + 30, local + 30 + localNameLength).toString("utf8") !== name
65
+ || (!(flags & 8) && (archive.readUInt32LE(local + 18) !== compressed || archive.readUInt32LE(local + 22) !== size)))
66
+ throw new Error("Invalid ZIP member data");
67
+ ranges.push({ start: local, end: start + compressed });
68
+ if (name === member) {
69
+ const data = archive.subarray(start, start + compressed);
70
+ binary = method === 0 ? data : (0, node_zlib_1.inflateRawSync)(data, { maxOutputLength: expectedSize });
71
+ if (binary.length !== expectedSize)
72
+ throw new Error("Unsupported or invalid ZIP compression");
73
+ }
74
+ cursor = next;
75
+ }
76
+ ranges.sort((a, b) => a.start - b.start);
77
+ if (cursor !== end || !binary || (ranges.length === 2 && ranges[1].start < ranges[0].end))
78
+ throw new Error("Invalid ZIP directory or missing binary");
79
+ return binary;
80
+ }
@@ -0,0 +1,108 @@
1
+ /*!
2
+ * Copyright 2026 Volcengine
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ "use strict";
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.downloadArchive = downloadArchive;
23
+ const node_http_1 = __importDefault(require("node:http"));
24
+ const node_https_1 = __importDefault(require("node:https"));
25
+ async function downloadArchive(url, expectedSize, options = {}) {
26
+ if (!Number.isSafeInteger(expectedSize) || expectedSize <= 0 || expectedSize > 64 * 1024 * 1024)
27
+ throw new Error("Invalid archive size");
28
+ const started = Date.now();
29
+ const timeoutMs = options.timeoutMs ?? 14 * 60_000;
30
+ const idleMs = options.idleTimeoutMs ?? 45_000;
31
+ let size = 0;
32
+ const progress = () => options.onProgress?.(size, Date.now() - started);
33
+ const heartbeat = setInterval(progress, 15_000);
34
+ const visit = (address, redirects) => new Promise((resolve, reject) => {
35
+ if (redirects > 5) {
36
+ reject(new Error("Too many download redirects"));
37
+ return;
38
+ }
39
+ const source = new URL(address);
40
+ if (source.protocol !== "https:" && source.protocol !== "http:") {
41
+ reject(new Error("Unsupported download protocol"));
42
+ return;
43
+ }
44
+ const remaining = timeoutMs - (Date.now() - started);
45
+ if (remaining <= 0) {
46
+ reject(new Error(`Binary download total deadline exceeded after ${timeoutMs}ms; received=${size}/${expectedSize} bytes`));
47
+ return;
48
+ }
49
+ let finished = false;
50
+ const fail = (error) => {
51
+ if (finished)
52
+ return;
53
+ finished = true;
54
+ clearTimeout(deadline);
55
+ reject(error);
56
+ request.destroy();
57
+ };
58
+ const request = (source.protocol === "https:" ? node_https_1.default : node_http_1.default).get(source, response => {
59
+ const status = response.statusCode ?? 0;
60
+ if (status >= 300 && status < 400 && response.headers.location) {
61
+ const next = new URL(response.headers.location, source);
62
+ if (next.origin !== source.origin) {
63
+ fail(new Error("Download redirected to a different origin"));
64
+ return;
65
+ }
66
+ finished = true;
67
+ clearTimeout(deadline);
68
+ response.destroy();
69
+ void visit(next.href, redirects + 1).then(resolve, reject);
70
+ return;
71
+ }
72
+ if (status !== 200) {
73
+ fail(new Error(`Binary download failed: HTTP ${status}`));
74
+ return;
75
+ }
76
+ const chunks = [];
77
+ response.on("data", (chunk) => {
78
+ size += chunk.length;
79
+ if (size > expectedSize)
80
+ fail(new Error("Downloaded archive exceeds expected size"));
81
+ else
82
+ chunks.push(chunk);
83
+ });
84
+ response.on("error", fail);
85
+ response.on("end", () => {
86
+ if (size !== expectedSize) {
87
+ fail(new Error(`Downloaded archive size mismatch; received=${size}/${expectedSize} bytes`));
88
+ return;
89
+ }
90
+ if (!finished) {
91
+ finished = true;
92
+ clearTimeout(deadline);
93
+ resolve(Buffer.concat(chunks));
94
+ }
95
+ });
96
+ });
97
+ const deadline = setTimeout(() => fail(new Error(`Binary download total deadline exceeded after ${timeoutMs}ms; received=${size}/${expectedSize} bytes`)), remaining);
98
+ request.setTimeout(idleMs, () => fail(new Error(`Binary download inactivity timeout after ${idleMs}ms; received=${size}/${expectedSize} bytes`)));
99
+ request.on("error", fail);
100
+ });
101
+ try {
102
+ return await visit(url, 0);
103
+ }
104
+ finally {
105
+ clearInterval(heartbeat);
106
+ progress();
107
+ }
108
+ }
package/lib/install.js ADDED
@@ -0,0 +1,137 @@
1
+ /*!
2
+ * Copyright 2026 Volcengine
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ "use strict";
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.selectBinary = selectBinary;
23
+ exports.binaryCachePath = binaryCachePath;
24
+ exports.ensureBinary = ensureBinary;
25
+ const node_crypto_1 = __importDefault(require("node:crypto"));
26
+ const node_fs_1 = __importDefault(require("node:fs"));
27
+ const node_os_1 = __importDefault(require("node:os"));
28
+ const node_path_1 = __importDefault(require("node:path"));
29
+ const archive_1 = require("./archive");
30
+ const download_1 = require("./download");
31
+ const json_1 = require("./json");
32
+ function byteCount(value) {
33
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0 || value > 64 * 1024 * 1024)
34
+ throw new Error("Invalid binary size");
35
+ return value;
36
+ }
37
+ function digest(value) {
38
+ if (typeof value !== "string" || !/^[0-9a-f]{64}$/.test(value))
39
+ throw new Error("Invalid binary checksum");
40
+ return value;
41
+ }
42
+ function selectBinary(root, platform = process.platform, architecture = process.arch) {
43
+ const system = platform === "win32" ? "windows" : platform;
44
+ const arch = architecture === "x64" ? "amd64" : architecture;
45
+ if (!["darwin", "linux", "windows"].includes(system) || !["amd64", "arm64"].includes(arch))
46
+ throw new Error(`Unsupported platform: ${platform}/${architecture}`);
47
+ const pkg = (0, json_1.readJsonObject)(node_path_1.default.join(root, "package.json"));
48
+ const record = (0, json_1.readJsonObject)(node_path_1.default.join(root, "release.json"));
49
+ const product = record.product;
50
+ if (product !== "volcengine" && product !== "byteplus")
51
+ throw new Error("Invalid Speech CLI package identity");
52
+ const distribution = product === "volcengine" ? "volcengine-speech-cli" : "byteplus-speech-cli";
53
+ const command = "speech-cli";
54
+ const version = (0, json_1.stringValue)(record.version, "release version");
55
+ const bin = (0, json_1.objectValue)(pkg.bin, "package.bin");
56
+ if (pkg.version !== version || !/^\d+\.\d+\.\d+$/.test(version)
57
+ || Object.keys(bin).length !== 1 || bin[command] !== "lib/run.js"
58
+ || typeof pkg.name !== "string" || !/^@[a-z0-9-]+\/[a-z0-9-]+$/.test(pkg.name)
59
+ || (!pkg.name.endsWith(`/${distribution}`) && pkg.name !== `@${product}/${command}`))
60
+ throw new Error("Invalid Speech CLI package identity");
61
+ const suffix = system === "windows" ? ".exe" : "";
62
+ const name = `${command}-${system}-${arch}${suffix}`;
63
+ const raw = record.binaries;
64
+ if (!Array.isArray(raw))
65
+ throw new Error("Missing binary manifest");
66
+ const entries = raw;
67
+ const matches = entries.map(entry => (0, json_1.objectValue)(entry, "binary")).filter(entry => entry.name === name);
68
+ if (matches.length !== 1)
69
+ throw new Error("Missing or duplicate platform binary");
70
+ const entry = matches[0];
71
+ const origin = product === "volcengine" ? "https://doubao-speech.tos-cn-beijing.volces.com" : "https://dola-speech.tos-ap-southeast-1.volces.com";
72
+ const url = `${origin}/releases/speech-cli/v${version}/${command}_${version}_${system}_${arch}.zip`;
73
+ if (entry.archive_url !== url || entry.member !== `${command}${suffix}`)
74
+ throw new Error("Invalid versioned TOS binary URL or member");
75
+ return { product, command, version, name, member: entry.member, url, archiveBytes: byteCount(entry.archive_bytes),
76
+ archiveSha256: digest(entry.archive_sha256), bytes: byteCount(entry.binary_bytes), sha256: digest(entry.sha256) };
77
+ }
78
+ function binaryCachePath(asset, cacheRoot) {
79
+ const base = cacheRoot ?? process.env.SPEECH_CLI_CACHE_DIR ?? node_path_1.default.join(node_os_1.default.homedir(), ".cache", "speech-cli");
80
+ return node_path_1.default.resolve(base, asset.product, asset.version, asset.sha256, asset.name);
81
+ }
82
+ function matches(data, bytes, sha256) {
83
+ return data.length === bytes && node_crypto_1.default.createHash("sha256").update(data).digest("hex") === sha256;
84
+ }
85
+ function cached(file, asset) {
86
+ try {
87
+ const stat = node_fs_1.default.lstatSync(file);
88
+ return stat.isFile() && stat.size === asset.bytes && matches(node_fs_1.default.readFileSync(file), asset.bytes, asset.sha256);
89
+ }
90
+ catch (error) {
91
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
92
+ return false;
93
+ throw error;
94
+ }
95
+ }
96
+ async function ensureBinary(root, options = {}) {
97
+ const asset = selectBinary(root, options.platform, options.architecture);
98
+ const output = binaryCachePath(asset, options.cacheRoot);
99
+ if (cached(output, asset)) {
100
+ if (require.main === module)
101
+ console.error(`[speech-cli][${asset.product}@${asset.version}][${asset.name}] verified cache reused; no download`);
102
+ return output;
103
+ }
104
+ const download = options.download ?? download_1.downloadArchive;
105
+ const started = Date.now();
106
+ const log = (message) => console.error(`[speech-cli][${asset.product}@${asset.version}][${asset.name}][+${((Date.now() - started) / 1000).toFixed(1)}s] ${message}`);
107
+ log(`download started; host=${new URL(asset.url).hostname}; expected=${asset.archiveBytes} bytes`);
108
+ const archive = await download(asset.url, asset.archiveBytes, {
109
+ onProgress: (bytes, elapsedMs) => log(`received=${bytes}/${asset.archiveBytes} bytes (${(bytes / asset.archiveBytes * 100).toFixed(1)}%); average=${Math.round(bytes / Math.max(elapsedMs / 1000, 1))} B/s`),
110
+ });
111
+ if (!matches(archive, asset.archiveBytes, asset.archiveSha256))
112
+ throw new Error("TOS archive checksum mismatch");
113
+ const binary = (0, archive_1.extractBinary)(archive, asset.member, asset.bytes);
114
+ if (!matches(binary, asset.bytes, asset.sha256))
115
+ throw new Error("Binary checksum mismatch");
116
+ const directory = node_path_1.default.dirname(output);
117
+ node_fs_1.default.mkdirSync(directory, { recursive: true, mode: 0o700 });
118
+ const temporary = node_fs_1.default.mkdtempSync(node_path_1.default.join(directory, ".download-"));
119
+ try {
120
+ const staged = node_path_1.default.join(temporary, asset.name);
121
+ node_fs_1.default.writeFileSync(staged, binary, { mode: 0o755 });
122
+ // Another installer may have completed while this download was in flight.
123
+ if (!cached(output, asset))
124
+ node_fs_1.default.renameSync(staged, output);
125
+ log("installed; archive and binary SHA-256 verified");
126
+ return output;
127
+ }
128
+ finally {
129
+ node_fs_1.default.rmSync(temporary, { recursive: true, force: true });
130
+ }
131
+ }
132
+ if (require.main === module && process.env.SPEECH_CLI_SKIP_POSTINSTALL !== "1") {
133
+ void ensureBinary(node_path_1.default.join(__dirname, "..")).catch((error) => {
134
+ console.error(`[speech-cli] ${error instanceof Error ? error.message : String(error)}`);
135
+ process.exitCode = 1;
136
+ });
137
+ }
package/lib/json.js ADDED
@@ -0,0 +1,45 @@
1
+ /*!
2
+ * Copyright 2026 Volcengine
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ "use strict";
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.parseJson = parseJson;
23
+ exports.objectValue = objectValue;
24
+ exports.stringValue = stringValue;
25
+ exports.readJsonObject = readJsonObject;
26
+ const node_fs_1 = __importDefault(require("node:fs"));
27
+ function parseJson(text) {
28
+ return JSON.parse(text);
29
+ }
30
+ function isObject(value) {
31
+ return typeof value === "object" && value !== null && !Array.isArray(value);
32
+ }
33
+ function objectValue(value, label) {
34
+ if (!isObject(value))
35
+ throw new Error(`${label} must be an object`);
36
+ return value;
37
+ }
38
+ function stringValue(value, label) {
39
+ if (typeof value !== "string")
40
+ throw new Error(`${label} must be a string`);
41
+ return value;
42
+ }
43
+ function readJsonObject(filename) {
44
+ return objectValue(parseJson(node_fs_1.default.readFileSync(filename, "utf8")), filename);
45
+ }
package/lib/run.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ /*!
3
+ * Copyright 2026 Volcengine
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ "use strict";
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ const node_path_1 = __importDefault(require("node:path"));
24
+ const node_child_process_1 = require("node:child_process");
25
+ const install_1 = require("./install");
26
+ async function main() {
27
+ const binary = await (0, install_1.ensureBinary)(node_path_1.default.join(__dirname, ".."));
28
+ const result = (0, node_child_process_1.spawnSync)(binary, process.argv.slice(2), { stdio: "inherit", env: process.env });
29
+ if (result.error)
30
+ throw result.error;
31
+ if (result.signal) {
32
+ process.kill(process.pid, result.signal);
33
+ return;
34
+ }
35
+ process.exitCode = result.status ?? 1;
36
+ }
37
+ if (require.main === module) {
38
+ void main().catch((error) => {
39
+ console.error(`[speech-cli] ${error instanceof Error ? error.message : String(error)}`);
40
+ process.exitCode = 1;
41
+ });
42
+ }
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@volcengine/speech-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.41",
4
+ "description": "火山引擎豆包语音 CLI",
5
+ "bin": {
6
+ "speech-cli": "lib/run.js"
7
+ },
8
+ "files": [
9
+ "lib/",
10
+ "release.json",
11
+ "README.md",
12
+ "LICENSE",
13
+ "Third-party software notice.md"
14
+ ],
15
+ "scripts": {
16
+ "postinstall": "node lib/install.js"
17
+ },
18
+ "engines": {
19
+ "node": ">=16"
20
+ },
21
+ "os": [
22
+ "darwin",
23
+ "linux",
24
+ "win32"
25
+ ],
26
+ "cpu": [
27
+ "x64",
28
+ "arm64"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org",
33
+ "access": "public"
34
+ }
35
+ }
package/release.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "version": "0.1.41",
3
+ "product": "volcengine",
4
+ "source_commit": "562e565b363fb9e77bdab59eb6f8ae8992ffc3d6",
5
+ "binaries": [
6
+ {
7
+ "name": "speech-cli-darwin-amd64",
8
+ "member": "speech-cli",
9
+ "sha256": "0729652b2cac5c2cb592fc7dd451d94219a7c79d7fd7669591264566691a985d",
10
+ "binary_bytes": 13166688,
11
+ "archive_url": "https://doubao-speech.tos-cn-beijing.volces.com/releases/speech-cli/v0.1.41/speech-cli_0.1.41_darwin_amd64.zip",
12
+ "archive_sha256": "aaa32abb70e825238660c8615555801281fc0361a419eafdad726b60a9bdbb9b",
13
+ "archive_bytes": 5070443
14
+ },
15
+ {
16
+ "name": "speech-cli-darwin-arm64",
17
+ "member": "speech-cli",
18
+ "sha256": "89cd7a38e01c8388a065b3abf4be36092d90d7bdf07d1f38c2899c259d9c655b",
19
+ "binary_bytes": 12826738,
20
+ "archive_url": "https://doubao-speech.tos-cn-beijing.volces.com/releases/speech-cli/v0.1.41/speech-cli_0.1.41_darwin_arm64.zip",
21
+ "archive_sha256": "a3adc74aff604bb847e283cffaa660523f581992aefb90f78c036da1974f8b10",
22
+ "archive_bytes": 4867081
23
+ },
24
+ {
25
+ "name": "speech-cli-linux-amd64",
26
+ "member": "speech-cli",
27
+ "sha256": "8fa7ad712ad434457fbd57659ef7a8a6ec9eaf0ae2dead49fb7a4ee9c761d5e9",
28
+ "binary_bytes": 12169216,
29
+ "archive_url": "https://doubao-speech.tos-cn-beijing.volces.com/releases/speech-cli/v0.1.41/speech-cli_0.1.41_linux_amd64.zip",
30
+ "archive_sha256": "79a5d1a046cb22a78ae5d5573b663611df3c0c1142843a3528855605e0ed5aa7",
31
+ "archive_bytes": 4891850
32
+ },
33
+ {
34
+ "name": "speech-cli-linux-arm64",
35
+ "member": "speech-cli",
36
+ "sha256": "4aa9a72ff1fd203daf3a31b8309d54f12a33254bda682cfed133ac30b5e9e8d1",
37
+ "binary_bytes": 11468800,
38
+ "archive_url": "https://doubao-speech.tos-cn-beijing.volces.com/releases/speech-cli/v0.1.41/speech-cli_0.1.41_linux_arm64.zip",
39
+ "archive_sha256": "ae94c175e57981a8bd3d263e6551fe67749833f4e4002eeb0fcfdcc9284e9007",
40
+ "archive_bytes": 4462399
41
+ },
42
+ {
43
+ "name": "speech-cli-windows-amd64.exe",
44
+ "member": "speech-cli.exe",
45
+ "sha256": "6af57ccd62a8a92e37495e7e3cac36018d8148354aa2111dd9cfc2a753d8231c",
46
+ "binary_bytes": 12528640,
47
+ "archive_url": "https://doubao-speech.tos-cn-beijing.volces.com/releases/speech-cli/v0.1.41/speech-cli_0.1.41_windows_amd64.zip",
48
+ "archive_sha256": "ccfb291aef3ddf13974956455dded70922104f5de9b40cd9fee4ca5039c4168a",
49
+ "archive_bytes": 4994892
50
+ },
51
+ {
52
+ "name": "speech-cli-windows-arm64.exe",
53
+ "member": "speech-cli.exe",
54
+ "sha256": "e2683380f8d85d5d101a17673bed651fd2de9165bee10335c8d25f47806cd398",
55
+ "binary_bytes": 11726336,
56
+ "archive_url": "https://doubao-speech.tos-cn-beijing.volces.com/releases/speech-cli/v0.1.41/speech-cli_0.1.41_windows_arm64.zip",
57
+ "archive_sha256": "8cc097fe8c7ba01453e76e04da403d5f18bb9f69a9c7590577fab95ab7d3c14c",
58
+ "archive_bytes": 4551567
59
+ }
60
+ ]
61
+ }