@wirecat/cli-template 0.9.0 → 0.10.0
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/.github/workflows/ci.yml +1 -0
- package/.github/workflows/release.yml +63 -0
- package/CHANGELOG.md +42 -1
- package/bin/release +5 -3
- package/dist/bin/clidev.js +34 -12
- package/dist/bundle/all-profiles-XHC7BG3P.js +24 -0
- package/dist/bundle/anthropic-N6B3ZZHQ.js +70 -0
- package/dist/bundle/bun-HUJLS7KP.js +169 -0
- package/dist/bundle/bun-sqlite-OWFO2TVR.js +69 -0
- package/dist/bundle/chunk-222FANS2.js +161 -0
- package/dist/bundle/chunk-2CFBHYFA.js +884 -0
- package/dist/bundle/chunk-2KQZ24GI.js +82 -0
- package/dist/bundle/chunk-2TBVT4SZ.js +31 -0
- package/dist/bundle/chunk-437W3Z2M.js +76 -0
- package/dist/bundle/chunk-4QRLPOJ7.js +18 -0
- package/dist/bundle/chunk-54AJONOM.js +54 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-6CBWO7OF.js +73 -0
- package/dist/bundle/chunk-75LVQQEK.js +35782 -0
- package/dist/bundle/chunk-7RB76E2L.js +264 -0
- package/dist/bundle/chunk-7RXBN7HP.js +63 -0
- package/dist/bundle/chunk-ABP7FDMJ.js +122 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AP7QKYBG.js +3531 -0
- package/dist/bundle/chunk-ASMH7JWZ.js +288 -0
- package/dist/bundle/chunk-B4EED2RF.js +100 -0
- package/dist/bundle/chunk-B4LM2B6F.js +1900 -0
- package/dist/bundle/chunk-BDSDQCV4.js +281 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DMCN22H6.js +35 -0
- package/dist/bundle/chunk-E42W72PQ.js +151 -0
- package/dist/bundle/chunk-EFHLQXG6.js +5104 -0
- package/dist/bundle/chunk-FIHDGZIB.js +34352 -0
- package/dist/bundle/chunk-FWVKHD2L.js +48 -0
- package/dist/bundle/chunk-FXS3X76A.js +193 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-IJ3IA7EK.js +24 -0
- package/dist/bundle/chunk-JEBSORH7.js +3379 -0
- package/dist/bundle/chunk-JTTW5ZKF.js +45 -0
- package/dist/bundle/chunk-LSEF4QC3.js +3075 -0
- package/dist/bundle/chunk-LY7GS2YI.js +58 -0
- package/dist/bundle/chunk-MFS52LTZ.js +570 -0
- package/dist/bundle/chunk-MNSD5BX2.js +78 -0
- package/dist/bundle/chunk-MTGLJCAZ.js +24 -0
- package/dist/bundle/chunk-MZVV2JZT.js +744 -0
- package/dist/bundle/chunk-NE3NSB5O.js +8341 -0
- package/dist/bundle/chunk-NTLPDH76.js +440 -0
- package/dist/bundle/chunk-O3PBQVAB.js +447 -0
- package/dist/bundle/chunk-O5EHUB2V.js +2 -0
- package/dist/bundle/chunk-O5LMDQTO.js +82 -0
- package/dist/bundle/chunk-OPJ24VGH.js +1028 -0
- package/dist/bundle/chunk-OPPMGPFW.js +164 -0
- package/dist/bundle/chunk-QGNNMPUB.js +158 -0
- package/dist/bundle/chunk-QVJLOUQB.js +2 -0
- package/dist/bundle/chunk-S57AMKLX.js +6848 -0
- package/dist/bundle/chunk-TARN7CHN.js +215 -0
- package/dist/bundle/chunk-TJLGI3N6.js +1095 -0
- package/dist/bundle/chunk-VMTM46FH.js +7532 -0
- package/dist/bundle/chunk-W2IDKBNB.js +2315 -0
- package/dist/bundle/chunk-XFXBXQBS.js +630 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/clidev.js +22 -0
- package/dist/bundle/command-contract-PEM3S634.js +29 -0
- package/dist/bundle/dist-ESHIQU4M.js +7577 -0
- package/dist/bundle/echarts-2QGL2JP5.js +42501 -0
- package/dist/bundle/embed-HHAAGHA6.js +35 -0
- package/dist/bundle/embedder-W2OGVVYH.js +108 -0
- package/dist/bundle/first-run-WCJUDUBU.js +23 -0
- package/dist/bundle/first-screen-U4DFUKUC.js +27 -0
- package/dist/bundle/instructions-OTZHT6NV.js +9 -0
- package/dist/bundle/mcp-OQBZXELQ.js +165 -0
- package/dist/bundle/mcp-VVF6J7SQ.js +151 -0
- package/dist/bundle/mcp-Y7VCIZ2J.js +78 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-SYD4GX5O.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-X2DGRFOZ.js +45 -0
- package/dist/bundle/oauth-42M34GQ5.js +17 -0
- package/dist/bundle/open-SWXRCDLN.js +19 -0
- package/dist/bundle/process-KAFGXZ7Q.js +91 -0
- package/dist/bundle/program-EHR4G7VN.js +16967 -0
- package/dist/bundle/prompt-ZQTMHRGX.js +12 -0
- package/dist/bundle/recognize-TTED4SE3.js +190 -0
- package/dist/bundle/remote-C37XJ4BP.js +26 -0
- package/dist/bundle/rerank-APFZAMQL.js +49 -0
- package/dist/bundle/serve-DDPIHDVZ.js +19 -0
- package/dist/bundle/server-L5GNG7KC.js +793 -0
- package/dist/bundle/server-LKVYA2AE.js +39 -0
- package/dist/bundle/state-WWPPHERF.js +33 -0
- package/dist/bundle/store-H6UIA4PK.js +120 -0
- package/dist/bundle/store-maintenance-command-EYBT64A2.js +40 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/commands.md +9 -13
- package/docs/dev/TESTING.md +8 -0
- package/docs/dev/reference-clis.md +7 -5
- package/docs/dev/skills/release/SKILL.md +9 -6
- package/docs/dev/skills/release/fresh-audit.md +4 -0
- package/kit/dist/new.js +1 -0
- package/package.json +7 -5
- package/scripts/audit.sh +3 -2
- package/scripts/smoke-bundle.ts +63 -0
- package/scripts/version-level.test.ts +17 -1
- package/scripts/version-level.ts +35 -7
- package/skills/clidev-cli/SKILL.md +8 -0
- package/src/version.ts +1 -1
- package/lint/baseline/unknown-verb.json +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
wirecatDirectory
|
|
5
|
+
} from "./chunk-4QRLPOJ7.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-EFHLQXG6.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_9d12b0091b773232c527328da5835651/node_modules/@wirecat/cli-core/dist/speech/install.js
|
|
14
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
15
|
+
import { createReadStream, createWriteStream, mkdirSync, statSync } from "node:fs";
|
|
16
|
+
import { rename, rm } from "node:fs/promises";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { Readable, Transform } from "node:stream";
|
|
19
|
+
import { pipeline } from "node:stream/promises";
|
|
20
|
+
|
|
21
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_9d12b0091b773232c527328da5835651/node_modules/@wirecat/cli-core/dist/speech/models.js
|
|
22
|
+
var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/csukuangfj/${repository}/resolve/${commit}/${name}`, "huggingFace");
|
|
23
|
+
var gigaam = huggingFace("sherpa-onnx-nemo-transducer-punct-giga-am-v3-russian-2025-12-16", "a6039be7cee829a9044a69ac0ebaf1c191217c97");
|
|
24
|
+
var gigaamCtc = huggingFace("sherpa-onnx-nemo-ctc-punct-giga-am-v3-russian-2025-12-16", "4fb5407ff028a69fec516cdf4c10fac9ddea7c16");
|
|
25
|
+
var parakeet = huggingFace("sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8", "2bda32ec70b097a55adaa07d9a7173915b43cc78");
|
|
26
|
+
var MODELS = [
|
|
27
|
+
{
|
|
28
|
+
id: "gigaam-v3",
|
|
29
|
+
title: "GigaAM v3, with punctuation",
|
|
30
|
+
languages: "Russian \u2014 the best of the three for Russian",
|
|
31
|
+
featureDim: 64,
|
|
32
|
+
files: [
|
|
33
|
+
{
|
|
34
|
+
name: "encoder.int8.onnx",
|
|
35
|
+
url: gigaam("encoder.int8.onnx"),
|
|
36
|
+
sha256: "369f35a71bf288d3b8e0391fabd8dba5f2314088d440bca474056b7b4b6e66bf",
|
|
37
|
+
bytes: 224570820
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "decoder.onnx",
|
|
41
|
+
url: gigaam("decoder.onnx"),
|
|
42
|
+
sha256: "38fc7475443ea2a26f63211ca350f73ac50fff824ab7a3876ee2bd610c53bbc4",
|
|
43
|
+
bytes: 4600132
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "joiner.onnx",
|
|
47
|
+
url: gigaam("joiner.onnx"),
|
|
48
|
+
sha256: "602ff7017a93311aad34df1437c8d7f49911353c13d6eae7a6ee7b041339465c",
|
|
49
|
+
bytes: 2712896
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "tokens.txt",
|
|
53
|
+
url: gigaam("tokens.txt"),
|
|
54
|
+
sha256: "39abae20e692998290c574e606f11a9edef2902a1995463fcff63d1490cf22b7",
|
|
55
|
+
bytes: 13354
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
config: /* @__PURE__ */ __name((path) => ({
|
|
59
|
+
transducer: { encoder: path("encoder.int8.onnx"), decoder: path("decoder.onnx"), joiner: path("joiner.onnx") },
|
|
60
|
+
tokens: path("tokens.txt"),
|
|
61
|
+
modelType: "nemo_transducer"
|
|
62
|
+
}), "config")
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "gigaam-v3-ctc",
|
|
66
|
+
title: "GigaAM v3 CTC, with punctuation \u2014 a little faster",
|
|
67
|
+
languages: "Russian \u2014 a little faster, rougher with capital letters",
|
|
68
|
+
featureDim: 64,
|
|
69
|
+
files: [
|
|
70
|
+
{
|
|
71
|
+
name: "model.int8.onnx",
|
|
72
|
+
url: gigaamCtc("model.int8.onnx"),
|
|
73
|
+
sha256: "d5fea8df94263c285e54b21e5774b707c707192d3bdbeffd7b1eb07fb6743b35",
|
|
74
|
+
bytes: 224893661
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "tokens.txt",
|
|
78
|
+
url: gigaamCtc("tokens.txt"),
|
|
79
|
+
sha256: "142de7570b3de5b3035ce111a89c228e80e6085273731d944093ddf24fa539cd",
|
|
80
|
+
bytes: 2007
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
config: /* @__PURE__ */ __name((path) => ({ nemoCtc: { model: path("model.int8.onnx") }, tokens: path("tokens.txt") }), "config")
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "parakeet-v3",
|
|
87
|
+
title: "NVIDIA Parakeet TDT 0.6B v3",
|
|
88
|
+
/** The model card's list: huggingface.co/nvidia/parakeet-tdt-0.6b-v3, read 2026-09-24. */
|
|
89
|
+
languages: "25: bg cs da de el en es et fi fr hr hu it lt lv mt nl pl pt ro ru sk sl sv uk",
|
|
90
|
+
featureDim: 80,
|
|
91
|
+
files: [
|
|
92
|
+
{
|
|
93
|
+
name: "encoder.int8.onnx",
|
|
94
|
+
url: parakeet("encoder.int8.onnx"),
|
|
95
|
+
sha256: "acfc2b4456377e15d04f0243af540b7fe7c992f8d898d751cf134c3a55fd2247",
|
|
96
|
+
bytes: 652184281
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "decoder.int8.onnx",
|
|
100
|
+
url: parakeet("decoder.int8.onnx"),
|
|
101
|
+
sha256: "179e50c43d1a9de79c8a24149a2f9bac6eb5981823f2a2ed88d655b24248db4e",
|
|
102
|
+
bytes: 11845275
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "joiner.int8.onnx",
|
|
106
|
+
url: parakeet("joiner.int8.onnx"),
|
|
107
|
+
sha256: "3164c13fc2821009440d20fcb5fdc78bff28b4db2f8d0f0b329101719c0948b3",
|
|
108
|
+
bytes: 6355277
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "tokens.txt",
|
|
112
|
+
url: parakeet("tokens.txt"),
|
|
113
|
+
sha256: "d58544679ea4bc6ac563d1f545eb7d474bd6cfa467f0a6e2c1dc1c7d37e3c35d",
|
|
114
|
+
bytes: 93939
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
config: /* @__PURE__ */ __name((path) => ({
|
|
118
|
+
transducer: {
|
|
119
|
+
encoder: path("encoder.int8.onnx"),
|
|
120
|
+
decoder: path("decoder.int8.onnx"),
|
|
121
|
+
joiner: path("joiner.int8.onnx")
|
|
122
|
+
},
|
|
123
|
+
tokens: path("tokens.txt"),
|
|
124
|
+
modelType: "nemo_transducer"
|
|
125
|
+
}), "config")
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
var VAD = {
|
|
129
|
+
name: "silero_vad.onnx",
|
|
130
|
+
url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx",
|
|
131
|
+
sha256: "9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",
|
|
132
|
+
bytes: 643854
|
|
133
|
+
};
|
|
134
|
+
var DEFAULT_ORDER = ["parakeet-v3", "gigaam-v3", "gigaam-v3-ctc"];
|
|
135
|
+
var orderedModels = /* @__PURE__ */ __name((order = DEFAULT_ORDER) => [.../* @__PURE__ */ new Set([...order, ...DEFAULT_ORDER])].map(speechModel), "orderedModels");
|
|
136
|
+
var findModel = /* @__PURE__ */ __name((id) => MODELS.find((model) => model.id === id), "findModel");
|
|
137
|
+
var speechModel = /* @__PURE__ */ __name((id) => {
|
|
138
|
+
const model = findModel(id);
|
|
139
|
+
if (!model) {
|
|
140
|
+
throw new CliError("validation_error", `no speech model "${id}" \u2014 one of ${MODELS.map((known) => known.id).join(", ")}`);
|
|
141
|
+
}
|
|
142
|
+
return model;
|
|
143
|
+
}, "speechModel");
|
|
144
|
+
|
|
145
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_9d12b0091b773232c527328da5835651/node_modules/@wirecat/cli-core/dist/speech/install.js
|
|
146
|
+
var sharedModelsDirectory = /* @__PURE__ */ __name((kind, env = process.env) => join(wirecatDirectory(env), "models", kind), "sharedModelsDirectory");
|
|
147
|
+
var modelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedModelsDirectory("audio", env), "modelsDirectory");
|
|
148
|
+
var STALL_MS = 6e4;
|
|
149
|
+
var watchdog = /* @__PURE__ */ __name((ms) => {
|
|
150
|
+
const controller = new AbortController();
|
|
151
|
+
let timer = setTimeout(() => controller.abort(), ms);
|
|
152
|
+
return {
|
|
153
|
+
signal: controller.signal,
|
|
154
|
+
poke: /* @__PURE__ */ __name(() => {
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
timer = setTimeout(() => controller.abort(), ms);
|
|
157
|
+
}, "poke"),
|
|
158
|
+
stop: /* @__PURE__ */ __name(() => clearTimeout(timer), "stop")
|
|
159
|
+
};
|
|
160
|
+
}, "watchdog");
|
|
161
|
+
var modelPath = /* @__PURE__ */ __name((directory, model) => (name) => join(directory, model.id, name), "modelPath");
|
|
162
|
+
var vadPath = /* @__PURE__ */ __name((directory) => join(directory, VAD.name), "vadPath");
|
|
163
|
+
var placed = /* @__PURE__ */ __name((model, directory) => [
|
|
164
|
+
...model.files.map((file) => [file, modelPath(directory, model)(file.name)]),
|
|
165
|
+
[VAD, vadPath(directory)]
|
|
166
|
+
], "placed");
|
|
167
|
+
var isInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placed(model, directory)), "isInstalled");
|
|
168
|
+
var filesPresent = /* @__PURE__ */ __name((files) => files.every(([file, path]) => sizeOf(path) === file.bytes), "filesPresent");
|
|
169
|
+
var sizeOf = /* @__PURE__ */ __name((path) => {
|
|
170
|
+
try {
|
|
171
|
+
return statSync(path).size;
|
|
172
|
+
} catch {
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
}, "sizeOf");
|
|
176
|
+
var installedBytes = /* @__PURE__ */ __name((model) => model.files.reduce((sum, file) => sum + file.bytes, 0), "installedBytes");
|
|
177
|
+
var install = /* @__PURE__ */ __name(async (model, directory, { fetch: get = fetch, progress, verifyExisting } = {}) => {
|
|
178
|
+
mkdirSync(join(directory, model.id), { recursive: true, mode: 448 });
|
|
179
|
+
await installFiles(placed(model, directory), { fetch: get, progress, verifyExisting });
|
|
180
|
+
}, "install");
|
|
181
|
+
var installFiles = /* @__PURE__ */ __name(async (files, { fetch: get = fetch, progress, verifyExisting } = {}) => {
|
|
182
|
+
if (verifyExisting)
|
|
183
|
+
for (const [file, path] of files) {
|
|
184
|
+
if (sizeOf(path) !== void 0) {
|
|
185
|
+
const hash = createHash("sha256");
|
|
186
|
+
for await (const chunk of createReadStream(path))
|
|
187
|
+
hash.update(chunk);
|
|
188
|
+
if (hash.digest("hex") !== file.sha256) {
|
|
189
|
+
progress?.(`${path}: not the file this version expects, downloading it again`);
|
|
190
|
+
await rm(path, { force: true });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
for (const [file, path] of files) {
|
|
195
|
+
if (sizeOf(path) === file.bytes)
|
|
196
|
+
continue;
|
|
197
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
198
|
+
progress?.(`downloading ${file.name} (${megabytes(file.bytes)})`);
|
|
199
|
+
await fetchVerified(file, path, get);
|
|
200
|
+
}
|
|
201
|
+
}, "installFiles");
|
|
202
|
+
var fetchVerified = /* @__PURE__ */ __name(async (file, path, get) => {
|
|
203
|
+
const stalled = watchdog(STALL_MS);
|
|
204
|
+
try {
|
|
205
|
+
await fetchInto(file, path, get, stalled);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
if (stalled.signal.aborted) {
|
|
208
|
+
throw new CliError("timeout", `${file.name} stopped downloading for ${STALL_MS / 1e3} s \u2014 nothing was installed`);
|
|
209
|
+
}
|
|
210
|
+
throw error;
|
|
211
|
+
} finally {
|
|
212
|
+
stalled.stop();
|
|
213
|
+
}
|
|
214
|
+
}, "fetchVerified");
|
|
215
|
+
var fetchInto = /* @__PURE__ */ __name(async (file, path, get, stalled) => {
|
|
216
|
+
const response = await get(file.url, { signal: stalled.signal });
|
|
217
|
+
if (!response.ok || !response.body) {
|
|
218
|
+
await response.body?.cancel();
|
|
219
|
+
throw new CliError("network_error", `${file.name} could not be downloaded: HTTP ${response.status}`);
|
|
220
|
+
}
|
|
221
|
+
const partial = `${path}.${randomUUID()}.part`;
|
|
222
|
+
const hash = createHash("sha256");
|
|
223
|
+
let bytes = 0;
|
|
224
|
+
const hashing = new Transform({
|
|
225
|
+
transform(chunk, _encoding, done) {
|
|
226
|
+
stalled.poke();
|
|
227
|
+
bytes += chunk.length;
|
|
228
|
+
if (bytes > file.bytes) {
|
|
229
|
+
done(new CliError("invalid_response", `${file.name} is larger than this version expects \u2014 nothing was installed`));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
hash.update(chunk);
|
|
233
|
+
done(null, chunk);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
try {
|
|
237
|
+
await pipeline(Readable.fromWeb(response.body), hashing, createWriteStream(partial, { flags: "wx", mode: 384 }));
|
|
238
|
+
const actual = hash.digest("hex");
|
|
239
|
+
if (actual !== file.sha256) {
|
|
240
|
+
throw new CliError("invalid_response", `${file.name} is not the file this version expects (sha256 ${actual}) \u2014 nothing was installed`);
|
|
241
|
+
}
|
|
242
|
+
await rename(partial, path);
|
|
243
|
+
} finally {
|
|
244
|
+
await rm(partial, { force: true });
|
|
245
|
+
}
|
|
246
|
+
}, "fetchInto");
|
|
247
|
+
var megabytes = /* @__PURE__ */ __name((bytes) => bytes < 1e6 ? "under 1 MB" : `${Math.round(bytes / 1e6)} MB`, "megabytes");
|
|
248
|
+
|
|
249
|
+
export {
|
|
250
|
+
VAD,
|
|
251
|
+
DEFAULT_ORDER,
|
|
252
|
+
orderedModels,
|
|
253
|
+
speechModel,
|
|
254
|
+
sharedModelsDirectory,
|
|
255
|
+
modelsDirectory,
|
|
256
|
+
modelPath,
|
|
257
|
+
vadPath,
|
|
258
|
+
isInstalled,
|
|
259
|
+
filesPresent,
|
|
260
|
+
installedBytes,
|
|
261
|
+
install,
|
|
262
|
+
installFiles,
|
|
263
|
+
megabytes
|
|
264
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__name
|
|
5
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_9d12b0091b773232c527328da5835651/node_modules/@wirecat/cli-core/dist/background/processes.js
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { readdirSync, readFileSync, readlinkSync } from "node:fs";
|
|
10
|
+
var alive = /* @__PURE__ */ __name((pid) => {
|
|
11
|
+
try {
|
|
12
|
+
process.kill(pid, 0);
|
|
13
|
+
return true;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return error.code === "EPERM";
|
|
16
|
+
}
|
|
17
|
+
}, "alive");
|
|
18
|
+
var carries = /* @__PURE__ */ __name((pid, marker) => {
|
|
19
|
+
if (pid <= 0 || !alive(pid))
|
|
20
|
+
return false;
|
|
21
|
+
try {
|
|
22
|
+
if (process.platform === "linux") {
|
|
23
|
+
return readFileSync(`/proc/${pid}/environ`, "latin1").split("\0").some((entry) => entry.endsWith(marker));
|
|
24
|
+
}
|
|
25
|
+
if (process.platform === "darwin") {
|
|
26
|
+
return execFileSync("ps", ["eww", "-o", "command=", "-p", String(pid)], { encoding: "utf8" }).includes(marker);
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}, "carries");
|
|
33
|
+
var holdersOf = /* @__PURE__ */ __name((paths) => {
|
|
34
|
+
if (process.platform === "linux") {
|
|
35
|
+
const wanted = new Set(paths);
|
|
36
|
+
return readdirSync("/proc").filter((entry) => /^\d+$/.test(entry) && Number(entry) !== process.pid).filter((pid) => {
|
|
37
|
+
try {
|
|
38
|
+
return readdirSync(`/proc/${pid}/fd`).some((fd) => {
|
|
39
|
+
try {
|
|
40
|
+
return wanted.has(readlinkSync(`/proc/${pid}/fd/${fd}`));
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}).map(Number);
|
|
49
|
+
}
|
|
50
|
+
const pids = /* @__PURE__ */ __name((listed) => listed.split("\n").filter(Boolean).map(Number).filter((pid) => pid !== process.pid), "pids");
|
|
51
|
+
try {
|
|
52
|
+
return pids(execFileSync("lsof", ["-t", "--", ...paths], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const { status, stdout } = error;
|
|
55
|
+
return status === 1 ? pids(stdout ?? "") : void 0;
|
|
56
|
+
}
|
|
57
|
+
}, "holdersOf");
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
alive,
|
|
61
|
+
carries,
|
|
62
|
+
holdersOf
|
|
63
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
unit
|
|
5
|
+
} from "./chunk-OPJ24VGH.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-EFHLQXG6.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_9d12b0091b773232c527328da5835651/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
|
|
14
|
+
import { setTimeout } from "node:timers/promises";
|
|
15
|
+
var OPENAI_URL = "https://api.openai.com/v1";
|
|
16
|
+
var OPENAI_MODELS = {
|
|
17
|
+
"text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
|
|
18
|
+
"text-embedding-3-large": { dims: 3072, perMillion: 0.13 }
|
|
19
|
+
};
|
|
20
|
+
var DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
|
|
21
|
+
var PER_REQUEST = 256;
|
|
22
|
+
var LOCAL = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
23
|
+
var isLocal = /* @__PURE__ */ __name((baseUrl) => LOCAL.has(new URL(baseUrl).hostname), "isLocal");
|
|
24
|
+
var remoteModel = /* @__PURE__ */ __name(({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims }) => {
|
|
25
|
+
const known = baseUrl === void 0 ? OPENAI_MODELS[model] : void 0;
|
|
26
|
+
if (baseUrl === void 0 && !known) {
|
|
27
|
+
throw new CliError("validation_error", `OpenAI has no embedding model ${model} here \u2014 one of: ${Object.keys(OPENAI_MODELS).join(", ")}; another server takes --base-url`);
|
|
28
|
+
}
|
|
29
|
+
const size = dims ?? known?.dims;
|
|
30
|
+
if (size === void 0)
|
|
31
|
+
throw new CliError("validation_error", "with --base-url, say the vector size with --dims");
|
|
32
|
+
return {
|
|
33
|
+
provider: baseUrl === void 0 ? "openai" : `url:${new URL(baseUrl).host}`,
|
|
34
|
+
model,
|
|
35
|
+
dims: size,
|
|
36
|
+
baseUrl: baseUrl ?? OPENAI_URL,
|
|
37
|
+
shorten: known !== void 0 && size !== known.dims,
|
|
38
|
+
...known ? { price: { perMillion: known.perMillion, read: "2026-10-02" } } : {}
|
|
39
|
+
};
|
|
40
|
+
}, "remoteModel");
|
|
41
|
+
var remoteKey = /* @__PURE__ */ __name(({ provider, model, dims }) => `${provider}:${model}:${dims}`, "remoteKey");
|
|
42
|
+
var openRemote = /* @__PURE__ */ __name((remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5 } = {}) => {
|
|
43
|
+
const request = /* @__PURE__ */ __name(async (input) => {
|
|
44
|
+
for (let attempt = 1; ; attempt++) {
|
|
45
|
+
let response;
|
|
46
|
+
try {
|
|
47
|
+
response = await post(`${remote.baseUrl.replace(/\/$/, "")}/embeddings`, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"content-type": "application/json",
|
|
51
|
+
...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
model: remote.model,
|
|
55
|
+
input,
|
|
56
|
+
encoding_format: "float",
|
|
57
|
+
...remote.shorten ? { dimensions: remote.dims } : {}
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
} catch {
|
|
61
|
+
if (attempt >= tries)
|
|
62
|
+
throw new CliError("network_error", `${remote.provider} could not be reached`);
|
|
63
|
+
await setTimeout(1e3 * attempt);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (response.ok) {
|
|
67
|
+
const body = await response.json();
|
|
68
|
+
const data = [...body.data ?? []].sort((a, b) => a.index - b.index);
|
|
69
|
+
if (data.length !== input.length || data.some(({ embedding }) => embedding.length !== remote.dims)) {
|
|
70
|
+
throw new CliError("invalid_response", `${remote.provider} answered with vectors of another number or size than ${input.length} \xD7 ${remote.dims}`);
|
|
71
|
+
}
|
|
72
|
+
return data.map(({ embedding }) => unit(Float32Array.from(embedding)));
|
|
73
|
+
}
|
|
74
|
+
const code = await errorCode(response);
|
|
75
|
+
if (response.status === 401 || response.status === 403) {
|
|
76
|
+
throw new CliError("authentication_error", `${remote.provider} refused the key (HTTP ${response.status}${code}) \u2014 set it again with \`models keys set\``);
|
|
77
|
+
}
|
|
78
|
+
const again = response.status === 429 || response.status >= 500;
|
|
79
|
+
if (!again || attempt >= tries) {
|
|
80
|
+
throw new CliError(response.status === 429 ? "rate_limited" : "provider_error", `${remote.provider} answered HTTP ${response.status}${code}`);
|
|
81
|
+
}
|
|
82
|
+
const wait = Number(response.headers.get("retry-after"));
|
|
83
|
+
await setTimeout(Number.isFinite(wait) && wait > 0 ? wait * 1e3 : 1e3 * 2 ** attempt);
|
|
84
|
+
}
|
|
85
|
+
}, "request");
|
|
86
|
+
return {
|
|
87
|
+
model: { id: remote.model, dims: remote.dims },
|
|
88
|
+
embed: /* @__PURE__ */ __name(async (texts) => {
|
|
89
|
+
const parts = [];
|
|
90
|
+
for (let start = 0; start < texts.length; start += PER_REQUEST)
|
|
91
|
+
parts.push(texts.slice(start, start + PER_REQUEST));
|
|
92
|
+
const results = new Array(parts.length);
|
|
93
|
+
let next = 0;
|
|
94
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, parts.length) }, async () => {
|
|
95
|
+
for (let index = next++; index < parts.length; index = next++)
|
|
96
|
+
results[index] = await request(parts[index]);
|
|
97
|
+
}));
|
|
98
|
+
return results.flat();
|
|
99
|
+
}, "embed"),
|
|
100
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
101
|
+
}, "close")
|
|
102
|
+
};
|
|
103
|
+
}, "openRemote");
|
|
104
|
+
var errorCode = /* @__PURE__ */ __name(async (response) => {
|
|
105
|
+
try {
|
|
106
|
+
const body = await response.json();
|
|
107
|
+
const code = body.error?.code ?? body.error?.type;
|
|
108
|
+
return typeof code === "string" && /^[\w.-]{1,64}$/.test(code) ? `, ${code}` : "";
|
|
109
|
+
} catch {
|
|
110
|
+
return "";
|
|
111
|
+
}
|
|
112
|
+
}, "errorCode");
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
OPENAI_URL,
|
|
116
|
+
OPENAI_MODELS,
|
|
117
|
+
DEFAULT_OPENAI_MODEL,
|
|
118
|
+
isLocal,
|
|
119
|
+
remoteModel,
|
|
120
|
+
remoteKey,
|
|
121
|
+
openRemote
|
|
122
|
+
};
|