@wirecat/attio-cli 0.8.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/CHANGELOG.md +23 -0
- package/contracts/wirecat.json +1 -0
- package/dist/bin/attio.js +11 -11
- package/dist/bundle/attio.js +5 -166
- package/dist/bundle/{chunk-UXJZISVL.js → chunk-OGWKDPR5.js} +2 -1
- package/dist/bundle/chunk-TQAECZFO.js +13 -0
- package/dist/bundle/{definitions-FODOIPM2.js → definitions-J73IBAHT.js} +1 -1
- package/dist/bundle/program-NSBWZ25F.js +6201 -0
- package/dist/bundle/{schemas-YGSTNU6F.js → schemas-G3HFAS45.js} +576 -29
- package/dist/commands/api.js +1 -2
- package/dist/commands/crm.js +1 -4
- package/dist/commands/schedule.js +1 -1
- package/dist/commands/session.js +1 -2
- package/dist/config.js +1 -2
- package/dist/context.js +1 -1
- package/dist/identity.js +1 -0
- package/dist/program.js +1 -2
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/activities.d.ts +0 -4
- package/dist/activities.d.ts.map +0 -1
- package/dist/activities.js.map +0 -1
- package/dist/bin/attio.d.ts +0 -3
- package/dist/bin/attio.d.ts.map +0 -1
- package/dist/bin/attio.js.map +0 -1
- package/dist/bundle/agent-GUXXSLT5.js +0 -38
- package/dist/bundle/all-profiles-63N3EQ46.js +0 -320
- package/dist/bundle/anthropic-B4W7MZQE.js +0 -91
- package/dist/bundle/app-server-EXNGTHWO.js +0 -250
- package/dist/bundle/bun-OPDGMZZQ.js +0 -169
- package/dist/bundle/bun-sqlite-NBAY7FR2.js +0 -76
- package/dist/bundle/chunk-2JHVQMVC.js +0 -16
- package/dist/bundle/chunk-2QDUP74I.js +0 -794
- package/dist/bundle/chunk-2XBDILVW.js +0 -53
- package/dist/bundle/chunk-3HC5F3P7.js +0 -24
- package/dist/bundle/chunk-3MSHGNVE.js +0 -1243
- package/dist/bundle/chunk-3YM4B2GT.js +0 -63
- package/dist/bundle/chunk-4N7PP76S.js +0 -6848
- package/dist/bundle/chunk-4RBMCXZT.js +0 -1337
- package/dist/bundle/chunk-4RSWOPKL.js +0 -323
- package/dist/bundle/chunk-5JKTVAXX.js +0 -2788
- package/dist/bundle/chunk-5N2V6XO7.js +0 -119
- package/dist/bundle/chunk-5WD22IXQ.js +0 -66
- package/dist/bundle/chunk-6K4Z6CAM.js +0 -43997
- package/dist/bundle/chunk-6TD3DCWC.js +0 -106
- package/dist/bundle/chunk-7Z53MLQP.js +0 -388
- package/dist/bundle/chunk-AATTOFNY.js +0 -2045
- package/dist/bundle/chunk-APARYILG.js +0 -743
- package/dist/bundle/chunk-D72URWJE.js +0 -532
- package/dist/bundle/chunk-DFDN6AUB.js +0 -21
- package/dist/bundle/chunk-DM7KWVDZ.js +0 -3752
- package/dist/bundle/chunk-DNCLQPOM.js +0 -7
- package/dist/bundle/chunk-DPD4FMHN.js +0 -388
- package/dist/bundle/chunk-DPV53EZC.js +0 -206
- package/dist/bundle/chunk-DURNR4RO.js +0 -353
- package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
- package/dist/bundle/chunk-EVUMQKV7.js +0 -76
- package/dist/bundle/chunk-EY36BTKZ.js +0 -108
- package/dist/bundle/chunk-FH6OEGGN.js +0 -557
- package/dist/bundle/chunk-FOP6G45D.js +0 -358
- package/dist/bundle/chunk-GGMAIIVE.js +0 -38
- package/dist/bundle/chunk-GTEX4IUO.js +0 -334
- package/dist/bundle/chunk-HZ3C4WXD.js +0 -142
- package/dist/bundle/chunk-IA7LLLEI.js +0 -100
- package/dist/bundle/chunk-J6GVVISK.js +0 -185
- package/dist/bundle/chunk-JG6LCSEX.js +0 -407
- package/dist/bundle/chunk-JIGEJZ4I.js +0 -68943
- package/dist/bundle/chunk-KVTNYRDO.js +0 -1007
- package/dist/bundle/chunk-L45WN3AR.js +0 -80
- package/dist/bundle/chunk-L72WUJAS.js +0 -54
- package/dist/bundle/chunk-LKH3UKLO.js +0 -230
- package/dist/bundle/chunk-LM3W7YOM.js +0 -274
- package/dist/bundle/chunk-M4AC55ZB.js +0 -12733
- package/dist/bundle/chunk-MCLQTCGH.js +0 -1202
- package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
- package/dist/bundle/chunk-NISH4UXM.js +0 -58
- package/dist/bundle/chunk-OYEVYOCL.js +0 -259
- package/dist/bundle/chunk-P7G5HFY3.js +0 -288
- package/dist/bundle/chunk-PAEKXVJW.js +0 -188
- package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
- package/dist/bundle/chunk-PLPBEWD4.js +0 -170
- package/dist/bundle/chunk-PMQ7GP6X.js +0 -95
- package/dist/bundle/chunk-Q7ICVP25.js +0 -18
- package/dist/bundle/chunk-QPPOIWPY.js +0 -1246
- package/dist/bundle/chunk-QSJKSPWF.js +0 -131
- package/dist/bundle/chunk-RDVTHFPP.js +0 -338
- package/dist/bundle/chunk-RQORQN2V.js +0 -4072
- package/dist/bundle/chunk-RRTMPSQR.js +0 -29
- package/dist/bundle/chunk-S4UUN6LD.js +0 -1410
- package/dist/bundle/chunk-S6JG4YUH.js +0 -72
- package/dist/bundle/chunk-SCI7QEHF.js +0 -362
- package/dist/bundle/chunk-SSA6JBPA.js +0 -778
- package/dist/bundle/chunk-T4J7XFXT.js +0 -9667
- package/dist/bundle/chunk-TTF5DP4V.js +0 -1197
- package/dist/bundle/chunk-TXDR6YSF.js +0 -23
- package/dist/bundle/chunk-TY7NDMFY.js +0 -46
- package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
- package/dist/bundle/chunk-UKHF37ZU.js +0 -1068
- package/dist/bundle/chunk-V57E7PJQ.js +0 -161
- package/dist/bundle/chunk-V7IF2K3P.js +0 -52
- package/dist/bundle/chunk-VB7FZOYX.js +0 -633
- package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
- package/dist/bundle/chunk-WOPVBRPV.js +0 -29
- package/dist/bundle/chunk-WXQGA6XK.js +0 -50
- package/dist/bundle/chunk-XQGN2D44.js +0 -86
- package/dist/bundle/chunk-XQUUANA2.js +0 -24600
- package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
- package/dist/bundle/chunk-YNGU36GW.js +0 -218
- package/dist/bundle/chunk-YWDFYQOU.js +0 -82
- package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
- package/dist/bundle/chunk-ZZD2YPOX.js +0 -156
- package/dist/bundle/command-contract-KCCW4LNI.js +0 -37
- package/dist/bundle/command-server-entry-3NPPABQQ.js +0 -166
- package/dist/bundle/decode-26M7XE2B.js +0 -297
- package/dist/bundle/dispatch-2FTOHA5D.js +0 -411
- package/dist/bundle/dist-EM7KLEG4.js +0 -7577
- package/dist/bundle/dist-PAKDDIBT.js +0 -191
- package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
- package/dist/bundle/embed-XJLEAWXE.js +0 -38
- package/dist/bundle/embedder-OEL6PXEH.js +0 -111
- package/dist/bundle/failure-OHIXWTR6.js +0 -25
- package/dist/bundle/first-run-CIXGBXY6.js +0 -29
- package/dist/bundle/first-screen-5FK4D45F.js +0 -38
- package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
- package/dist/bundle/mcp-5HFPWC3W.js +0 -167
- package/dist/bundle/meeting-combined-DMVGQNJ7.js +0 -24
- package/dist/bundle/meeting-model-2THAT7OH.js +0 -25
- package/dist/bundle/meeting-semantic-Q6XYFYUD.js +0 -22
- package/dist/bundle/node-EGMCBAO7.js +0 -176
- package/dist/bundle/node-KM3CUABH.js +0 -2340
- package/dist/bundle/node-TLZSIHIJ.js +0 -21
- package/dist/bundle/node-sqlite-2SWWGW6H.js +0 -74
- package/dist/bundle/oauth-V5LGTXF2.js +0 -20
- package/dist/bundle/open-25EKOTZA.js +0 -23
- package/dist/bundle/openai-VX3OLIHM.js +0 -238
- package/dist/bundle/process-SGHEN6MQ.js +0 -91
- package/dist/bundle/program-Z5NUNXME.js +0 -34214
- package/dist/bundle/prompt-2VSPX5S7.js +0 -17
- package/dist/bundle/recognize-NA5XUFKK.js +0 -26
- package/dist/bundle/remote-BOME6XOE.js +0 -31
- package/dist/bundle/rerank-NG3XMFCV.js +0 -52
- package/dist/bundle/serve-MR67OBED.js +0 -199
- package/dist/bundle/server-4BWAGJQO.js +0 -80
- package/dist/bundle/server-OP2HJNXD.js +0 -213
- package/dist/bundle/sqlite-runtime-V5U6F5EB.js +0 -20
- package/dist/bundle/state-L4MWAATO.js +0 -36
- package/dist/bundle/store-2ALTEH55.js +0 -181
- package/dist/bundle/store-CXZFRG5D.js +0 -297
- package/dist/bundle/store-maintenance-command-LC55DRQA.js +0 -67
- package/dist/bundle/surface-3GRJ7473.js +0 -66
- package/dist/commands/api.d.ts +0 -12
- package/dist/commands/api.d.ts.map +0 -1
- package/dist/commands/api.js.map +0 -1
- package/dist/commands/crm.d.ts +0 -7
- package/dist/commands/crm.d.ts.map +0 -1
- package/dist/commands/crm.js.map +0 -1
- package/dist/commands/schedule.d.ts +0 -3
- package/dist/commands/schedule.d.ts.map +0 -1
- package/dist/commands/schedule.js.map +0 -1
- package/dist/commands/session.d.ts +0 -8
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js.map +0 -1
- package/dist/config.d.ts +0 -13
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context.d.ts +0 -37
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/generated/definitions.d.ts +0 -3
- package/dist/generated/definitions.d.ts.map +0 -1
- package/dist/generated/definitions.js.map +0 -1
- package/dist/generated/manifest.d.ts +0 -6
- package/dist/generated/manifest.d.ts.map +0 -1
- package/dist/generated/manifest.js.map +0 -1
- package/dist/generated/schemas.d.ts +0 -383
- package/dist/generated/schemas.d.ts.map +0 -1
- package/dist/generated/schemas.js.map +0 -1
- package/dist/generated/types.d.ts +0 -10166
- package/dist/generated/types.d.ts.map +0 -1
- package/dist/generated/types.js.map +0 -1
- package/dist/generated/wirecat-config.d.ts +0 -15
- package/dist/generated/wirecat-config.d.ts.map +0 -1
- package/dist/generated/wirecat-config.js.map +0 -1
- package/dist/hooks.d.ts +0 -33
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/identity.d.ts +0 -33
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/links.d.ts +0 -10
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js.map +0 -1
- package/dist/meetings.d.ts +0 -57
- package/dist/meetings.d.ts.map +0 -1
- package/dist/meetings.js.map +0 -1
- package/dist/program.d.ts +0 -6
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/wcat.d.ts +0 -3
- package/dist/wcat.d.ts.map +0 -1
- package/dist/wcat.js.map +0 -1
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
timezoneOf,
|
|
5
|
-
zonedMoment
|
|
6
|
-
} from "./chunk-RQORQN2V.js";
|
|
7
|
-
import {
|
|
8
|
-
CliError
|
|
9
|
-
} from "./chunk-S6JG4YUH.js";
|
|
10
|
-
import {
|
|
11
|
-
__name
|
|
12
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
13
|
-
|
|
14
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/domain/moment.js
|
|
15
|
-
var calendarMoment = /* @__PURE__ */ __name((wanted, flag, { zone, end = false } = {}) => {
|
|
16
|
-
try {
|
|
17
|
-
return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
|
|
18
|
-
} catch (error) {
|
|
19
|
-
if (!(error instanceof CliError))
|
|
20
|
-
throw error;
|
|
21
|
-
const alternative = error.details?.alternative;
|
|
22
|
-
throw new CliError("validation_error", `${flag}: "${wanted}" is not a time${alternative ? ` \u2014 ${alternative}` : ""}`);
|
|
23
|
-
}
|
|
24
|
-
}, "calendarMoment");
|
|
25
|
-
var dayIn = /* @__PURE__ */ __name((at, zone) => new Intl.DateTimeFormat("en-CA", { timeZone: zone, year: "numeric", month: "2-digit", day: "2-digit" }).format(at), "dayIn");
|
|
26
|
-
var MINUTE = 6e4;
|
|
27
|
-
var YEAR = 365 * 24 * 60 * MINUTE;
|
|
28
|
-
var RELATIVE = /^(\d+)(m|h|d)$/;
|
|
29
|
-
var RELATIVE_MS = { m: MINUTE, h: 60 * MINUTE, d: 24 * 60 * MINUTE };
|
|
30
|
-
var DATE_ALONE = /^\d{4}-\d{2}-\d{2}$/;
|
|
31
|
-
var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
32
|
-
var dayWord = /* @__PURE__ */ __name((word, zone, now) => {
|
|
33
|
-
const today = new Intl.DateTimeFormat("en-CA", { timeZone: zone }).format(now);
|
|
34
|
-
if (word === "today")
|
|
35
|
-
return today;
|
|
36
|
-
const date = /* @__PURE__ */ new Date(`${today}T00:00:00Z`);
|
|
37
|
-
date.setUTCDate(date.getUTCDate() - 1);
|
|
38
|
-
return date.toISOString().slice(0, 10);
|
|
39
|
-
}, "dayWord");
|
|
40
|
-
var readMoment = /* @__PURE__ */ __name((typed, flag, { zone, end = false, now = Date.now(), direction = -1 } = {}) => {
|
|
41
|
-
const wanted = typed.trim();
|
|
42
|
-
const [, amount, unit] = RELATIVE.exec(wanted) ?? [];
|
|
43
|
-
if (amount && unit)
|
|
44
|
-
return { time: now + direction * Number(amount) * (RELATIVE_MS[unit] ?? 0), local: false, dateAlone: false };
|
|
45
|
-
const word = wanted.toLowerCase();
|
|
46
|
-
const date = word === "today" || word === "yesterday" ? dayWord(word, timezoneOf(zone), now) : wanted;
|
|
47
|
-
if (!/^\d{4}-\d{2}-\d{2}/.test(date))
|
|
48
|
-
return void 0;
|
|
49
|
-
const iso = date.replace(/^(\d{4}-\d{2}-\d{2}) +(?=\d)/, "$1T");
|
|
50
|
-
return {
|
|
51
|
-
time: calendarMoment(iso, flag, { ...zone === void 0 ? {} : { zone }, end }),
|
|
52
|
-
local: !ZONED.test(iso),
|
|
53
|
-
dateAlone: DATE_ALONE.test(iso)
|
|
54
|
-
};
|
|
55
|
-
}, "readMoment");
|
|
56
|
-
var lead = /* @__PURE__ */ __name((ms) => ms === MINUTE ? "a minute" : ms === YEAR ? "a year" : `${Math.ceil(ms / MINUTE)} minutes`, "lead");
|
|
57
|
-
var aheadOf = /* @__PURE__ */ __name((reference, flag, now = Date.now(), options = {}) => {
|
|
58
|
-
const { refuseDate = false, soonest, latest, ...at } = options;
|
|
59
|
-
const read = readMoment(reference, flag, { ...at, now, direction: 1 });
|
|
60
|
-
if (read === void 0)
|
|
61
|
-
throw new CliError("validation_error", `${flag} takes an ISO 8601 time, today, or 30m, 2h, 3d from now \u2014 not "${reference.trim()}"`);
|
|
62
|
-
if (refuseDate && read.dateAlone)
|
|
63
|
-
throw new CliError("validation_error", DATE_ALONE.test(reference.trim()) ? `${flag} needs a time of day as well: ${reference.trim()}T09:00` : `${flag} needs a time of day as well, like 2026-11-20T09:00`);
|
|
64
|
-
if (soonest === 0 && read.time <= now)
|
|
65
|
-
throw new CliError("validation_error", `${flag} is in the past`);
|
|
66
|
-
if (soonest !== void 0 && soonest > 0 && read.time < now + soonest)
|
|
67
|
-
throw new CliError("validation_error", `${flag} has to be at least ${lead(soonest)} from now`);
|
|
68
|
-
if (latest !== void 0 && read.time > now + latest)
|
|
69
|
-
throw new CliError("validation_error", `${flag} can be at most ${lead(latest)} from now`);
|
|
70
|
-
return read.time;
|
|
71
|
-
}, "aheadOf");
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
calendarMoment,
|
|
75
|
-
dayIn,
|
|
76
|
-
MINUTE,
|
|
77
|
-
YEAR,
|
|
78
|
-
readMoment,
|
|
79
|
-
aheadOf
|
|
80
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
resolvePaths
|
|
5
|
-
} from "./chunk-5JKTVAXX.js";
|
|
6
|
-
import {
|
|
7
|
-
__name
|
|
8
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
-
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/store/path.js
|
|
11
|
-
import { realpathSync } from "node:fs";
|
|
12
|
-
import { userInfo } from "node:os";
|
|
13
|
-
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
14
|
-
var wirecatDirectory = /* @__PURE__ */ __name((env = process.env, platform) => resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env, ...platform ? { platform } : {} }).state, "wirecatDirectory");
|
|
15
|
-
var storePath = /* @__PURE__ */ __name((env = process.env) => env.MESSAGING_STORE ?? join(wirecatDirectory(env), "wirecat.db"), "storePath");
|
|
16
|
-
var accountHome = /* @__PURE__ */ __name(() => {
|
|
17
|
-
try {
|
|
18
|
-
return userInfo().homedir;
|
|
19
|
-
} catch {
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
}, "accountHome");
|
|
23
|
-
var inOwnerFolder = /* @__PURE__ */ __name((file, home = accountHome()) => {
|
|
24
|
-
if (!home || file === ":memory:")
|
|
25
|
-
return false;
|
|
26
|
-
const owner = wirecatDirectory({ HOME: home, USERPROFILE: home });
|
|
27
|
-
const within = /* @__PURE__ */ __name((path, folder) => {
|
|
28
|
-
const inside = relative(folder, path);
|
|
29
|
-
return !(inside.startsWith("..") || isAbsolute(inside));
|
|
30
|
-
}, "within");
|
|
31
|
-
return within(resolve(file), owner) || within(settled(resolve(file)), settled(owner));
|
|
32
|
-
}, "inOwnerFolder");
|
|
33
|
-
var settled = /* @__PURE__ */ __name((path) => {
|
|
34
|
-
try {
|
|
35
|
-
return realpathSync(path);
|
|
36
|
-
} catch {
|
|
37
|
-
const parent = dirname(path);
|
|
38
|
-
return parent === path ? path : join(settled(parent), basename(path));
|
|
39
|
-
}
|
|
40
|
-
}, "settled");
|
|
41
|
-
var refuseOwnerStoreInTests = /* @__PURE__ */ __name((file, env = process.env, home = accountHome()) => {
|
|
42
|
-
if (!env.VITEST || !inOwnerFolder(file, home))
|
|
43
|
-
return;
|
|
44
|
-
throw new Error(`a test tried to open ${file}, in the owner's real WireCat folder; give it a MESSAGING_STORE or HOME of its own`);
|
|
45
|
-
}, "refuseOwnerStoreInTests");
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
wirecatDirectory,
|
|
49
|
-
storePath,
|
|
50
|
-
accountHome,
|
|
51
|
-
inOwnerFolder,
|
|
52
|
-
settled,
|
|
53
|
-
refuseOwnerStoreInTests
|
|
54
|
-
};
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
importFrom
|
|
5
|
-
} from "./chunk-Y5E2WNWB.js";
|
|
6
|
-
import {
|
|
7
|
-
CliError
|
|
8
|
-
} from "./chunk-S6JG4YUH.js";
|
|
9
|
-
import {
|
|
10
|
-
__name
|
|
11
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
-
|
|
13
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/recognize.js
|
|
14
|
-
import { createRequire } from "node:module";
|
|
15
|
-
|
|
16
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/ogg-limit.js
|
|
17
|
-
var invalid = /* @__PURE__ */ __name(() => new CliError("validation_error", "local transcription needs a complete mono or stereo Ogg Opus recording"), "invalid");
|
|
18
|
-
var checkOggDuration = /* @__PURE__ */ __name((bytes) => {
|
|
19
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
20
|
-
let offset = 0;
|
|
21
|
-
let serial;
|
|
22
|
-
let packet = 0;
|
|
23
|
-
let length = 0;
|
|
24
|
-
const prefix = [];
|
|
25
|
-
while (offset < bytes.length) {
|
|
26
|
-
if (offset + 27 > bytes.length || view.getUint32(offset, false) !== 1332176723 || bytes[offset + 4] !== 0)
|
|
27
|
-
throw invalid();
|
|
28
|
-
const stream = view.getUint32(offset + 14, true);
|
|
29
|
-
if (serial !== void 0 && serial !== stream)
|
|
30
|
-
throw invalid();
|
|
31
|
-
serial = stream;
|
|
32
|
-
const segments = bytes[offset + 26] ?? 0;
|
|
33
|
-
let data = offset + 27 + segments;
|
|
34
|
-
if (data > bytes.length || Boolean((bytes[offset + 5] ?? 0) & 1) !== length > 0)
|
|
35
|
-
throw invalid();
|
|
36
|
-
for (let index = 0; index < segments; index++) {
|
|
37
|
-
const size = bytes[offset + 27 + index] ?? 0;
|
|
38
|
-
if (data + size > bytes.length)
|
|
39
|
-
throw invalid();
|
|
40
|
-
const take = Math.min(size, 19 - prefix.length);
|
|
41
|
-
for (let i = 0; i < take; i++)
|
|
42
|
-
prefix.push(bytes[data + i] ?? 0);
|
|
43
|
-
length += size;
|
|
44
|
-
data += size;
|
|
45
|
-
if (size === 255)
|
|
46
|
-
continue;
|
|
47
|
-
if (packet === 0) {
|
|
48
|
-
if (length < 19 || String.fromCharCode(...prefix.slice(0, 8)) !== "OpusHead" || ![1, 2].includes(prefix[9] ?? 0) || prefix[18] !== 0)
|
|
49
|
-
throw invalid();
|
|
50
|
-
} else if (packet === 1) {
|
|
51
|
-
if (length < 8 || String.fromCharCode(...prefix.slice(0, 8)) !== "OpusTags")
|
|
52
|
-
throw invalid();
|
|
53
|
-
} else {
|
|
54
|
-
if (length < 1)
|
|
55
|
-
throw invalid();
|
|
56
|
-
const toc = prefix[0] ?? 0;
|
|
57
|
-
const config = toc >> 3;
|
|
58
|
-
const frame = config >= 16 ? 120 << (config & 3) : config >= 12 ? 480 << (config & 1) : (config & 3) === 3 ? 2880 : 480 << (config & 3);
|
|
59
|
-
const count = (toc & 3) === 0 ? 1 : (toc & 3) === 3 ? length >= 2 ? (prefix[1] ?? 0) & 63 : 0 : 2;
|
|
60
|
-
if (count < 1 || frame * count > 5760)
|
|
61
|
-
throw invalid();
|
|
62
|
-
}
|
|
63
|
-
packet++;
|
|
64
|
-
length = 0;
|
|
65
|
-
prefix.length = 0;
|
|
66
|
-
}
|
|
67
|
-
offset = data;
|
|
68
|
-
}
|
|
69
|
-
if (length !== 0 || packet < 3)
|
|
70
|
-
throw invalid();
|
|
71
|
-
}, "checkOggDuration");
|
|
72
|
-
|
|
73
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/recognize.js
|
|
74
|
-
var SAMPLE_RATE = 16e3;
|
|
75
|
-
var LEAD = SAMPLE_RATE / 2;
|
|
76
|
-
var toModelRate = /* @__PURE__ */ __name((samples, rate) => {
|
|
77
|
-
const step = rate / SAMPLE_RATE;
|
|
78
|
-
const length = Math.floor(samples.length / step);
|
|
79
|
-
const pcm = new Float32Array(LEAD + length);
|
|
80
|
-
for (let i = 0; i < length; i++) {
|
|
81
|
-
const from = Math.floor(i * step);
|
|
82
|
-
const to = Math.max(from + 1, Math.floor((i + 1) * step));
|
|
83
|
-
let sum = 0;
|
|
84
|
-
for (let j = from; j < to; j++)
|
|
85
|
-
sum += samples[j] ?? 0;
|
|
86
|
-
pcm[LEAD + i] = sum / (to - from);
|
|
87
|
-
}
|
|
88
|
-
return pcm;
|
|
89
|
-
}, "toModelRate");
|
|
90
|
-
var decodeOgg = /* @__PURE__ */ __name(async (bytes) => {
|
|
91
|
-
checkOggDuration(bytes);
|
|
92
|
-
const { OggOpusDecoder } = await importFrom(new URL("speech/recognize.js", import.meta.resolve("@wirecat/cli-core")).href, "ogg-opus-decoder");
|
|
93
|
-
const decoder = new OggOpusDecoder();
|
|
94
|
-
await decoder.ready;
|
|
95
|
-
try {
|
|
96
|
-
const { channelData, sampleRate, samplesDecoded } = await decoder.decodeFile(bytes);
|
|
97
|
-
if (!channelData[0] || samplesDecoded === 0)
|
|
98
|
-
throw new Error("no Ogg Opus audio in it");
|
|
99
|
-
return channelData.map((samples) => ({ samples, rate: sampleRate }));
|
|
100
|
-
} finally {
|
|
101
|
-
decoder.free();
|
|
102
|
-
}
|
|
103
|
-
}, "decodeOgg");
|
|
104
|
-
var WINDOW = 512;
|
|
105
|
-
var detector = /* @__PURE__ */ __name((vadModel) => ({
|
|
106
|
-
sileroVad: {
|
|
107
|
-
model: vadModel,
|
|
108
|
-
// At the default 0.5 a quietly spoken stretch in the middle of a voice message never counted as
|
|
109
|
-
// speech and was lost; 0.3 keeps it for both models and changes nothing on clear speech (126508, 2026-09-30).
|
|
110
|
-
threshold: 0.3,
|
|
111
|
-
minSilenceDuration: 0.5,
|
|
112
|
-
minSpeechDuration: 0.25,
|
|
113
|
-
maxSpeechDuration: 20,
|
|
114
|
-
windowSize: WINDOW
|
|
115
|
-
},
|
|
116
|
-
sampleRate: SAMPLE_RATE,
|
|
117
|
-
numThreads: 1,
|
|
118
|
-
provider: "cpu",
|
|
119
|
-
debug: 0,
|
|
120
|
-
bufferSizeInSeconds: 30
|
|
121
|
-
}), "detector");
|
|
122
|
-
var cut = /* @__PURE__ */ __name((vad, pcm, each) => {
|
|
123
|
-
vad.reset();
|
|
124
|
-
const last = Math.max(0, pcm.length - LEAD);
|
|
125
|
-
const drain = /* @__PURE__ */ __name(() => {
|
|
126
|
-
for (; !vad.isEmpty(); vad.pop()) {
|
|
127
|
-
const { start, samples } = vad.front();
|
|
128
|
-
each({
|
|
129
|
-
start: Math.min(last, Math.max(0, start - LEAD)) / SAMPLE_RATE,
|
|
130
|
-
end: Math.min(last, Math.max(0, start + samples.length - LEAD)) / SAMPLE_RATE,
|
|
131
|
-
samples
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}, "drain");
|
|
135
|
-
for (let i = 0; i + WINDOW <= pcm.length; i += WINDOW) {
|
|
136
|
-
vad.acceptWaveform(pcm.subarray(i, i + WINDOW));
|
|
137
|
-
drain();
|
|
138
|
-
}
|
|
139
|
-
vad.flush();
|
|
140
|
-
drain();
|
|
141
|
-
}, "cut");
|
|
142
|
-
var openSpeechCutter = /* @__PURE__ */ __name((vadModel) => {
|
|
143
|
-
const vad = loadSherpa().createVad(detector(vadModel));
|
|
144
|
-
return {
|
|
145
|
-
cut: /* @__PURE__ */ __name((pcm) => {
|
|
146
|
-
const spans = [];
|
|
147
|
-
cut(vad, pcm, ({ start, end }) => spans.push({ start, end }));
|
|
148
|
-
return spans;
|
|
149
|
-
}, "cut"),
|
|
150
|
-
free: /* @__PURE__ */ __name(() => vad.free(), "free")
|
|
151
|
-
};
|
|
152
|
-
}, "openSpeechCutter");
|
|
153
|
-
var loaded;
|
|
154
|
-
var loadSherpa = /* @__PURE__ */ __name(() => {
|
|
155
|
-
if (loaded)
|
|
156
|
-
return loaded;
|
|
157
|
-
const load = createRequire(new URL("speech/recognize.js", import.meta.resolve("@wirecat/cli-core")).href);
|
|
158
|
-
const wasm = {};
|
|
159
|
-
load("sherpa-onnx/sherpa-onnx-wasm-nodejs.js")(wasm);
|
|
160
|
-
const stdout = wasm.FS?.getStream(1);
|
|
161
|
-
if (stdout)
|
|
162
|
-
stdout.nfd = 2;
|
|
163
|
-
const asr = load("sherpa-onnx/sherpa-onnx-asr.js");
|
|
164
|
-
const vad = load("sherpa-onnx/sherpa-onnx-vad.js");
|
|
165
|
-
loaded = {
|
|
166
|
-
createOfflineRecognizer: /* @__PURE__ */ __name((config) => new asr.OfflineRecognizer(config, wasm), "createOfflineRecognizer"),
|
|
167
|
-
createVad: /* @__PURE__ */ __name((config) => vad.createVad(wasm, config), "createVad")
|
|
168
|
-
};
|
|
169
|
-
return loaded;
|
|
170
|
-
}, "loadSherpa");
|
|
171
|
-
var openRecognizer = /* @__PURE__ */ __name((model, path, vadModel) => {
|
|
172
|
-
const sherpa = loadSherpa();
|
|
173
|
-
const engine = sherpa.createOfflineRecognizer({
|
|
174
|
-
featConfig: { sampleRate: SAMPLE_RATE, featureDim: model.featureDim },
|
|
175
|
-
modelConfig: { ...model.config(path), numThreads: 1, provider: "cpu", debug: 0 },
|
|
176
|
-
decodingMethod: "greedy_search"
|
|
177
|
-
});
|
|
178
|
-
const vad = sherpa.createVad(detector(vadModel));
|
|
179
|
-
const piece = /* @__PURE__ */ __name((samples) => {
|
|
180
|
-
const stream = engine.createStream();
|
|
181
|
-
try {
|
|
182
|
-
stream.acceptWaveform(SAMPLE_RATE, samples);
|
|
183
|
-
engine.decode(stream);
|
|
184
|
-
return engine.getResult(stream).text.trim();
|
|
185
|
-
} finally {
|
|
186
|
-
stream.free();
|
|
187
|
-
}
|
|
188
|
-
}, "piece");
|
|
189
|
-
const pieces = /* @__PURE__ */ __name((pcm) => {
|
|
190
|
-
const heard = [];
|
|
191
|
-
cut(vad, pcm, ({ start, end, samples }) => {
|
|
192
|
-
const text = piece(samples);
|
|
193
|
-
if (text)
|
|
194
|
-
heard.push({ start, end, text });
|
|
195
|
-
});
|
|
196
|
-
return heard;
|
|
197
|
-
}, "pieces");
|
|
198
|
-
const piecesUntil = /* @__PURE__ */ __name(async (pcm, signal) => {
|
|
199
|
-
const spans = [];
|
|
200
|
-
cut(vad, pcm, (span) => spans.push(span));
|
|
201
|
-
const heard = [];
|
|
202
|
-
for (const { start, end, samples } of spans) {
|
|
203
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
204
|
-
signal.throwIfAborted();
|
|
205
|
-
const text = piece(samples);
|
|
206
|
-
if (text)
|
|
207
|
-
heard.push({ start, end, text });
|
|
208
|
-
}
|
|
209
|
-
return heard;
|
|
210
|
-
}, "piecesUntil");
|
|
211
|
-
return {
|
|
212
|
-
recognize: /* @__PURE__ */ __name((pcm) => pieces(pcm).map(({ text }) => text).join(" "), "recognize"),
|
|
213
|
-
pieces,
|
|
214
|
-
piecesUntil,
|
|
215
|
-
free: /* @__PURE__ */ __name(() => {
|
|
216
|
-
vad.free();
|
|
217
|
-
engine.free();
|
|
218
|
-
}, "free")
|
|
219
|
-
};
|
|
220
|
-
}, "openRecognizer");
|
|
221
|
-
|
|
222
|
-
export {
|
|
223
|
-
SAMPLE_RATE,
|
|
224
|
-
toModelRate,
|
|
225
|
-
decodeOgg,
|
|
226
|
-
detector,
|
|
227
|
-
openSpeechCutter,
|
|
228
|
-
loadSherpa,
|
|
229
|
-
openRecognizer
|
|
230
|
-
};
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
wirecatDirectory
|
|
5
|
-
} from "./chunk-L72WUJAS.js";
|
|
6
|
-
import {
|
|
7
|
-
CliError
|
|
8
|
-
} from "./chunk-S6JG4YUH.js";
|
|
9
|
-
import {
|
|
10
|
-
__name
|
|
11
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
-
|
|
13
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/models.js
|
|
14
|
-
var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/csukuangfj/${repository}/resolve/${commit}/${name}`, "huggingFace");
|
|
15
|
-
var gigaam = huggingFace("sherpa-onnx-nemo-transducer-punct-giga-am-v3-russian-2025-12-16", "a6039be7cee829a9044a69ac0ebaf1c191217c97");
|
|
16
|
-
var gigaamCtc = huggingFace("sherpa-onnx-nemo-ctc-punct-giga-am-v3-russian-2025-12-16", "4fb5407ff028a69fec516cdf4c10fac9ddea7c16");
|
|
17
|
-
var parakeet = huggingFace("sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8", "2bda32ec70b097a55adaa07d9a7173915b43cc78");
|
|
18
|
-
var MODELS = [
|
|
19
|
-
{
|
|
20
|
-
id: "gigaam-v3",
|
|
21
|
-
title: "GigaAM v3, with punctuation",
|
|
22
|
-
languages: "Russian \u2014 the best of the three for Russian",
|
|
23
|
-
language: "ru",
|
|
24
|
-
featureDim: 64,
|
|
25
|
-
files: [
|
|
26
|
-
{
|
|
27
|
-
name: "encoder.int8.onnx",
|
|
28
|
-
url: gigaam("encoder.int8.onnx"),
|
|
29
|
-
sha256: "369f35a71bf288d3b8e0391fabd8dba5f2314088d440bca474056b7b4b6e66bf",
|
|
30
|
-
bytes: 224570820
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "decoder.onnx",
|
|
34
|
-
url: gigaam("decoder.onnx"),
|
|
35
|
-
sha256: "38fc7475443ea2a26f63211ca350f73ac50fff824ab7a3876ee2bd610c53bbc4",
|
|
36
|
-
bytes: 4600132
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "joiner.onnx",
|
|
40
|
-
url: gigaam("joiner.onnx"),
|
|
41
|
-
sha256: "602ff7017a93311aad34df1437c8d7f49911353c13d6eae7a6ee7b041339465c",
|
|
42
|
-
bytes: 2712896
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "tokens.txt",
|
|
46
|
-
url: gigaam("tokens.txt"),
|
|
47
|
-
sha256: "39abae20e692998290c574e606f11a9edef2902a1995463fcff63d1490cf22b7",
|
|
48
|
-
bytes: 13354
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
config: /* @__PURE__ */ __name((path) => ({
|
|
52
|
-
transducer: { encoder: path("encoder.int8.onnx"), decoder: path("decoder.onnx"), joiner: path("joiner.onnx") },
|
|
53
|
-
tokens: path("tokens.txt"),
|
|
54
|
-
modelType: "nemo_transducer"
|
|
55
|
-
}), "config")
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: "gigaam-v3-ctc",
|
|
59
|
-
title: "GigaAM v3 CTC, with punctuation \u2014 a little faster",
|
|
60
|
-
languages: "Russian \u2014 a little faster, rougher with capital letters",
|
|
61
|
-
language: "ru",
|
|
62
|
-
featureDim: 64,
|
|
63
|
-
files: [
|
|
64
|
-
{
|
|
65
|
-
name: "model.int8.onnx",
|
|
66
|
-
url: gigaamCtc("model.int8.onnx"),
|
|
67
|
-
sha256: "d5fea8df94263c285e54b21e5774b707c707192d3bdbeffd7b1eb07fb6743b35",
|
|
68
|
-
bytes: 224893661
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: "tokens.txt",
|
|
72
|
-
url: gigaamCtc("tokens.txt"),
|
|
73
|
-
sha256: "142de7570b3de5b3035ce111a89c228e80e6085273731d944093ddf24fa539cd",
|
|
74
|
-
bytes: 2007
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
config: /* @__PURE__ */ __name((path) => ({ nemoCtc: { model: path("model.int8.onnx") }, tokens: path("tokens.txt") }), "config")
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: "parakeet-v3",
|
|
81
|
-
title: "NVIDIA Parakeet TDT 0.6B v3",
|
|
82
|
-
/** The model card's list: huggingface.co/nvidia/parakeet-tdt-0.6b-v3, read 2026-09-24. */
|
|
83
|
-
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",
|
|
84
|
-
featureDim: 80,
|
|
85
|
-
files: [
|
|
86
|
-
{
|
|
87
|
-
name: "encoder.int8.onnx",
|
|
88
|
-
url: parakeet("encoder.int8.onnx"),
|
|
89
|
-
sha256: "acfc2b4456377e15d04f0243af540b7fe7c992f8d898d751cf134c3a55fd2247",
|
|
90
|
-
bytes: 652184281
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: "decoder.int8.onnx",
|
|
94
|
-
url: parakeet("decoder.int8.onnx"),
|
|
95
|
-
sha256: "179e50c43d1a9de79c8a24149a2f9bac6eb5981823f2a2ed88d655b24248db4e",
|
|
96
|
-
bytes: 11845275
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: "joiner.int8.onnx",
|
|
100
|
-
url: parakeet("joiner.int8.onnx"),
|
|
101
|
-
sha256: "3164c13fc2821009440d20fcb5fdc78bff28b4db2f8d0f0b329101719c0948b3",
|
|
102
|
-
bytes: 6355277
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "tokens.txt",
|
|
106
|
-
url: parakeet("tokens.txt"),
|
|
107
|
-
sha256: "d58544679ea4bc6ac563d1f545eb7d474bd6cfa467f0a6e2c1dc1c7d37e3c35d",
|
|
108
|
-
bytes: 93939
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
config: /* @__PURE__ */ __name((path) => ({
|
|
112
|
-
transducer: {
|
|
113
|
-
encoder: path("encoder.int8.onnx"),
|
|
114
|
-
decoder: path("decoder.int8.onnx"),
|
|
115
|
-
joiner: path("joiner.int8.onnx")
|
|
116
|
-
},
|
|
117
|
-
tokens: path("tokens.txt"),
|
|
118
|
-
modelType: "nemo_transducer"
|
|
119
|
-
}), "config")
|
|
120
|
-
}
|
|
121
|
-
];
|
|
122
|
-
var OPENAI_TRANSCRIBE_MODEL = "gpt-transcribe";
|
|
123
|
-
var VAD = {
|
|
124
|
-
name: "silero_vad.onnx",
|
|
125
|
-
url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx",
|
|
126
|
-
sha256: "9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",
|
|
127
|
-
bytes: 643854
|
|
128
|
-
};
|
|
129
|
-
var DEFAULT_ORDER = ["parakeet-v3", "gigaam-v3", "gigaam-v3-ctc"];
|
|
130
|
-
var orderedModels = /* @__PURE__ */ __name((order = DEFAULT_ORDER) => [.../* @__PURE__ */ new Set([...order, ...DEFAULT_ORDER])].map(speechModel), "orderedModels");
|
|
131
|
-
var findModel = /* @__PURE__ */ __name((id) => MODELS.find((model) => model.id === id), "findModel");
|
|
132
|
-
var speechModel = /* @__PURE__ */ __name((id) => {
|
|
133
|
-
const model = findModel(id);
|
|
134
|
-
if (!model) {
|
|
135
|
-
throw new CliError("validation_error", `no speech model "${id}" \u2014 one of ${MODELS.map((known) => known.id).join(", ")}`);
|
|
136
|
-
}
|
|
137
|
-
return model;
|
|
138
|
-
}, "speechModel");
|
|
139
|
-
|
|
140
|
-
// node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/install.js
|
|
141
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
142
|
-
import { createReadStream, createWriteStream, mkdirSync, statSync } from "node:fs";
|
|
143
|
-
import { rename, rm } from "node:fs/promises";
|
|
144
|
-
import { dirname, join } from "node:path";
|
|
145
|
-
import { Readable, Transform } from "node:stream";
|
|
146
|
-
import { pipeline } from "node:stream/promises";
|
|
147
|
-
var sharedModelsDirectory = /* @__PURE__ */ __name((kind, env = process.env) => join(wirecatDirectory(env), "models", kind), "sharedModelsDirectory");
|
|
148
|
-
var modelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedModelsDirectory("audio", env), "modelsDirectory");
|
|
149
|
-
var STALL_MS = 6e4;
|
|
150
|
-
var watchdog = /* @__PURE__ */ __name((ms) => {
|
|
151
|
-
const controller = new AbortController();
|
|
152
|
-
let timer = setTimeout(() => controller.abort(), ms);
|
|
153
|
-
return {
|
|
154
|
-
signal: controller.signal,
|
|
155
|
-
poke: /* @__PURE__ */ __name(() => {
|
|
156
|
-
clearTimeout(timer);
|
|
157
|
-
timer = setTimeout(() => controller.abort(), ms);
|
|
158
|
-
}, "poke"),
|
|
159
|
-
stop: /* @__PURE__ */ __name(() => clearTimeout(timer), "stop")
|
|
160
|
-
};
|
|
161
|
-
}, "watchdog");
|
|
162
|
-
var modelPath = /* @__PURE__ */ __name((directory, model) => (name) => join(directory, model.id, name), "modelPath");
|
|
163
|
-
var vadPath = /* @__PURE__ */ __name((directory) => join(directory, VAD.name), "vadPath");
|
|
164
|
-
var placed = /* @__PURE__ */ __name((model, directory) => [
|
|
165
|
-
...model.files.map((file) => [file, modelPath(directory, model)(file.name)]),
|
|
166
|
-
[VAD, vadPath(directory)]
|
|
167
|
-
], "placed");
|
|
168
|
-
var isInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placed(model, directory)), "isInstalled");
|
|
169
|
-
var filesPresent = /* @__PURE__ */ __name((files) => files.every(([file, path]) => sizeOf(path) === file.bytes), "filesPresent");
|
|
170
|
-
var sizeOf = /* @__PURE__ */ __name((path) => {
|
|
171
|
-
try {
|
|
172
|
-
return statSync(path).size;
|
|
173
|
-
} catch {
|
|
174
|
-
return void 0;
|
|
175
|
-
}
|
|
176
|
-
}, "sizeOf");
|
|
177
|
-
var installedBytes = /* @__PURE__ */ __name((model) => model.files.reduce((sum, file) => sum + file.bytes, 0), "installedBytes");
|
|
178
|
-
var install = /* @__PURE__ */ __name(async (model, directory, { fetch: get = fetch, progress, bytes, verifyExisting } = {}) => {
|
|
179
|
-
mkdirSync(join(directory, model.id), { recursive: true, mode: 448 });
|
|
180
|
-
await installFiles(placed(model, directory), { fetch: get, progress, bytes, verifyExisting });
|
|
181
|
-
}, "install");
|
|
182
|
-
var installFiles = /* @__PURE__ */ __name(async (files, { fetch: get = fetch, progress, bytes = /* @__PURE__ */ __name(() => {
|
|
183
|
-
}, "bytes"), verifyExisting } = {}) => {
|
|
184
|
-
if (verifyExisting)
|
|
185
|
-
for (const [file, path] of files) {
|
|
186
|
-
if (sizeOf(path) !== void 0) {
|
|
187
|
-
const hash = createHash("sha256");
|
|
188
|
-
for await (const chunk of createReadStream(path))
|
|
189
|
-
hash.update(chunk);
|
|
190
|
-
if (hash.digest("hex") !== file.sha256) {
|
|
191
|
-
progress?.(`${path}: not the file this version expects, downloading it again`);
|
|
192
|
-
await rm(path, { force: true });
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const total = files.reduce((sum, [file]) => sum + file.bytes, 0);
|
|
197
|
-
const missing = files.filter(([file, path]) => sizeOf(path) !== file.bytes);
|
|
198
|
-
let done = total - missing.reduce((sum, [file]) => sum + file.bytes, 0);
|
|
199
|
-
bytes(done, total);
|
|
200
|
-
for (const [file, path] of missing) {
|
|
201
|
-
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
202
|
-
progress?.(`downloading ${file.name} (${megabytes(file.bytes)})`);
|
|
203
|
-
const before = done;
|
|
204
|
-
await fetchVerified(file, path, get, (received) => {
|
|
205
|
-
done = before + received;
|
|
206
|
-
bytes(done, total);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}, "installFiles");
|
|
210
|
-
var fetchVerified = /* @__PURE__ */ __name(async (file, path, get, received) => {
|
|
211
|
-
const stalled = watchdog(STALL_MS);
|
|
212
|
-
try {
|
|
213
|
-
await fetchInto(file, path, get, stalled, received);
|
|
214
|
-
} catch (error) {
|
|
215
|
-
if (stalled.signal.aborted) {
|
|
216
|
-
throw new CliError("timeout", `${file.name} stopped downloading for ${STALL_MS / 1e3} s \u2014 nothing was installed`);
|
|
217
|
-
}
|
|
218
|
-
throw error;
|
|
219
|
-
} finally {
|
|
220
|
-
stalled.stop();
|
|
221
|
-
}
|
|
222
|
-
}, "fetchVerified");
|
|
223
|
-
var fetchInto = /* @__PURE__ */ __name(async (file, path, get, stalled, received) => {
|
|
224
|
-
const response = await get(file.url, { signal: stalled.signal });
|
|
225
|
-
if (!response.ok || !response.body) {
|
|
226
|
-
await response.body?.cancel();
|
|
227
|
-
throw new CliError("network_error", `${file.name} could not be downloaded: HTTP ${response.status}`);
|
|
228
|
-
}
|
|
229
|
-
const partial = `${path}.${randomUUID()}.part`;
|
|
230
|
-
const hash = createHash("sha256");
|
|
231
|
-
let bytes = 0;
|
|
232
|
-
const hashing = new Transform({
|
|
233
|
-
transform(chunk, _encoding, done) {
|
|
234
|
-
stalled.poke();
|
|
235
|
-
bytes += chunk.length;
|
|
236
|
-
if (bytes > file.bytes) {
|
|
237
|
-
done(new CliError("invalid_response", `${file.name} is larger than this version expects \u2014 nothing was installed`));
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
hash.update(chunk);
|
|
241
|
-
received(bytes);
|
|
242
|
-
done(null, chunk);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
try {
|
|
246
|
-
await pipeline(Readable.fromWeb(response.body), hashing, createWriteStream(partial, { flags: "wx", mode: 384 }));
|
|
247
|
-
const actual = hash.digest("hex");
|
|
248
|
-
if (actual !== file.sha256) {
|
|
249
|
-
throw new CliError("invalid_response", `${file.name} is not the file this version expects (sha256 ${actual}) \u2014 nothing was installed`);
|
|
250
|
-
}
|
|
251
|
-
await rename(partial, path);
|
|
252
|
-
} finally {
|
|
253
|
-
await rm(partial, { force: true });
|
|
254
|
-
}
|
|
255
|
-
}, "fetchInto");
|
|
256
|
-
var megabytes = /* @__PURE__ */ __name((bytes) => bytes < 1e6 ? "under 1 MB" : `${Math.round(bytes / 1e6)} MB`, "megabytes");
|
|
257
|
-
|
|
258
|
-
export {
|
|
259
|
-
OPENAI_TRANSCRIBE_MODEL,
|
|
260
|
-
VAD,
|
|
261
|
-
DEFAULT_ORDER,
|
|
262
|
-
orderedModels,
|
|
263
|
-
speechModel,
|
|
264
|
-
sharedModelsDirectory,
|
|
265
|
-
modelsDirectory,
|
|
266
|
-
modelPath,
|
|
267
|
-
vadPath,
|
|
268
|
-
isInstalled,
|
|
269
|
-
filesPresent,
|
|
270
|
-
installedBytes,
|
|
271
|
-
install,
|
|
272
|
-
installFiles,
|
|
273
|
-
megabytes
|
|
274
|
-
};
|