@wirecat/mail-cli 0.0.0-stage → 0.1.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 +50 -0
- package/LICENSE +204 -0
- package/README.md +141 -2
- package/dist/bin/mail.d.ts +3 -0
- package/dist/bin/mail.d.ts.map +1 -0
- package/dist/bin/mail.js +36 -0
- package/dist/bin/mail.js.map +1 -0
- package/dist/bundle/all-profiles-TKMBELRZ.js +286 -0
- package/dist/bundle/anthropic-7LMUAEIZ.js +72 -0
- package/dist/bundle/app-server-JGMIJDD4.js +229 -0
- package/dist/bundle/bun-XRO6XJHQ.js +169 -0
- package/dist/bundle/bun-sqlite-Z54LEHVM.js +71 -0
- package/dist/bundle/chunk-2LLNPNMB.js +24 -0
- package/dist/bundle/chunk-3E3WA2L6.js +1932 -0
- package/dist/bundle/chunk-3KEVLSNN.js +138 -0
- package/dist/bundle/chunk-3KOA73LS.js +3416 -0
- package/dist/bundle/chunk-4E7BN3TC.js +122 -0
- package/dist/bundle/chunk-4FEMINO2.js +409 -0
- package/dist/bundle/chunk-5BVIWP3S.js +71 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5NYMNSSO.js +264 -0
- package/dist/bundle/chunk-5WGEUDE4.js +27 -0
- package/dist/bundle/chunk-6MAZWSC3.js +132 -0
- package/dist/bundle/chunk-75CWWETH.js +379 -0
- package/dist/bundle/chunk-7SXGLT6T.js +444 -0
- package/dist/bundle/chunk-BTQX2ZSZ.js +288 -0
- package/dist/bundle/chunk-CEW6KIFA.js +1193 -0
- package/dist/bundle/chunk-CH6RXYAX.js +82 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-EOEDICIE.js +6848 -0
- package/dist/bundle/chunk-F6D6PJ34.js +100 -0
- package/dist/bundle/chunk-FDCGTODC.js +78 -0
- package/dist/bundle/chunk-FZ5FXIG6.js +18 -0
- package/dist/bundle/chunk-GAH7N7HO.js +8181 -0
- package/dist/bundle/chunk-GK4M2SUP.js +195 -0
- package/dist/bundle/chunk-GN62YOT5.js +161 -0
- package/dist/bundle/chunk-GQQJOH7A.js +7050 -0
- package/dist/bundle/chunk-GWDCKUBI.js +781 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-IK5TH3O7.js +217 -0
- package/dist/bundle/chunk-J3QXTBD2.js +2742 -0
- package/dist/bundle/chunk-J6MSJLIW.js +45 -0
- package/dist/bundle/chunk-JBBZCTTF.js +76 -0
- package/dist/bundle/chunk-JVMVLITS.js +260 -0
- package/dist/bundle/chunk-K4FVKPDQ.js +525 -0
- package/dist/bundle/chunk-KHTO2Q6E.js +886 -0
- package/dist/bundle/chunk-KM7Q67Z3.js +63 -0
- package/dist/bundle/chunk-LQ37ALDJ.js +2416 -0
- package/dist/bundle/chunk-MNOIRJEO.js +2315 -0
- package/dist/bundle/chunk-MS53RALV.js +168 -0
- package/dist/bundle/chunk-NK7EB63L.js +36225 -0
- package/dist/bundle/chunk-NPGVOZVK.js +2 -0
- package/dist/bundle/chunk-OTUOZ33L.js +82 -0
- package/dist/bundle/chunk-P7P5MNAU.js +46 -0
- package/dist/bundle/chunk-QLEUNU6G.js +537 -0
- package/dist/bundle/chunk-QQB7WT7R.js +216 -0
- package/dist/bundle/chunk-QX7RCLRS.js +23 -0
- package/dist/bundle/chunk-T6464KYA.js +35130 -0
- package/dist/bundle/chunk-TE5U5OAM.js +73 -0
- package/dist/bundle/chunk-TI6VBZKJ.js +166 -0
- package/dist/bundle/chunk-TQFCPUIM.js +53 -0
- package/dist/bundle/chunk-TVREDYX4.js +3574 -0
- package/dist/bundle/chunk-TWPDVUBR.js +106 -0
- package/dist/bundle/chunk-TWTATDM7.js +461 -0
- package/dist/bundle/chunk-UH4DDRHA.js +2989 -0
- package/dist/bundle/chunk-VEIZZRQ5.js +630 -0
- package/dist/bundle/chunk-WLFLBWNH.js +54 -0
- package/dist/bundle/chunk-WXAXYJJ7.js +486 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YO4CUH5E.js +33 -0
- package/dist/bundle/chunk-YPQQ5J4X.js +849 -0
- package/dist/bundle/chunk-Z34ICZA3.js +1028 -0
- package/dist/bundle/chunk-ZANYM66S.js +58 -0
- package/dist/bundle/chunk-ZD3WUGR2.js +142 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-WU434ZUL.js +34 -0
- package/dist/bundle/decode-YB3ZDTES.js +162 -0
- package/dist/bundle/dispatch-EUKKT3PD.js +411 -0
- package/dist/bundle/dist-A6GKSKFC.js +2072 -0
- package/dist/bundle/dist-X36THCOF.js +7577 -0
- package/dist/bundle/echarts-YNGCOYHW.js +42501 -0
- package/dist/bundle/embed-LWNHIRBQ.js +37 -0
- package/dist/bundle/embedder-2LYD3U37.js +110 -0
- package/dist/bundle/failure-OAIC5VAP.js +24 -0
- package/dist/bundle/first-run-N3HJKGU7.js +27 -0
- package/dist/bundle/first-screen-4U2DMV3G.js +32 -0
- package/dist/bundle/instructions-GJHHFV64.js +11 -0
- package/dist/bundle/mail.js +166 -0
- package/dist/bundle/mcp-L7SRVDRN.js +167 -0
- package/dist/bundle/node-GFOH6FKP.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-NBXQXBIU.js +63 -0
- package/dist/bundle/oauth-56EFO5AQ.js +19 -0
- package/dist/bundle/open-2V7QZQJP.js +21 -0
- package/dist/bundle/openai-V3SVACVL.js +251 -0
- package/dist/bundle/process-XVDX4SPD.js +91 -0
- package/dist/bundle/program-ILID6EAT.js +35542 -0
- package/dist/bundle/prompt-YKWAI222.js +14 -0
- package/dist/bundle/recognize-PAR66KVM.js +25 -0
- package/dist/bundle/remote-CE43TKXC.js +28 -0
- package/dist/bundle/rerank-M7S7P2TW.js +51 -0
- package/dist/bundle/serve-ENPMIV6J.js +197 -0
- package/dist/bundle/server-JRTHUCVY.js +63 -0
- package/dist/bundle/server-MBEZLVKZ.js +189 -0
- package/dist/bundle/sqlite-runtime-HVGDHBJJ.js +18 -0
- package/dist/bundle/state-QZSOSKBD.js +35 -0
- package/dist/bundle/store-2BUX6LVX.js +124 -0
- package/dist/bundle/store-UJ7SNKXI.js +141 -0
- package/dist/bundle/store-maintenance-command-I7V5C44K.js +52 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +47 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/context.d.ts +41 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +52 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +74 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/folders.d.ts +3 -0
- package/dist/commands/folders.d.ts.map +1 -0
- package/dist/commands/folders.js +36 -0
- package/dist/commands/folders.js.map +1 -0
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +21 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/mailbox.d.ts +16 -0
- package/dist/commands/mailbox.d.ts.map +1 -0
- package/dist/commands/mailbox.js +54 -0
- package/dist/commands/mailbox.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +97 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +211 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +3 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +156 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +89 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +190 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/config.d.ts +190 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +46 -0
- package/dist/config.js.map +1 -0
- package/dist/discovery.d.ts +42 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +179 -0
- package/dist/discovery.js.map +1 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +16 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mail/imap-errors.d.ts +4 -0
- package/dist/mail/imap-errors.d.ts.map +1 -0
- package/dist/mail/imap-errors.js +41 -0
- package/dist/mail/imap-errors.js.map +1 -0
- package/dist/mail/imap-messages.d.ts +18 -0
- package/dist/mail/imap-messages.d.ts.map +1 -0
- package/dist/mail/imap-messages.js +66 -0
- package/dist/mail/imap-messages.js.map +1 -0
- package/dist/mail/imap.d.ts +67 -0
- package/dist/mail/imap.d.ts.map +1 -0
- package/dist/mail/imap.js +348 -0
- package/dist/mail/imap.js.map +1 -0
- package/dist/mail/parse.d.ts +18 -0
- package/dist/mail/parse.d.ts.map +1 -0
- package/dist/mail/parse.js +31 -0
- package/dist/mail/parse.js.map +1 -0
- package/dist/mail/port.d.ts +50 -0
- package/dist/mail/port.d.ts.map +1 -0
- package/dist/mail/port.js +4 -0
- package/dist/mail/port.js.map +1 -0
- package/dist/mcp.d.ts +29 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +98 -0
- package/dist/mcp.js.map +1 -0
- package/dist/profile.d.ts +16 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +31 -0
- package/dist/profile.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +52 -0
- package/dist/program.js.map +1 -0
- package/dist/providers.d.ts +53 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +106 -0
- package/dist/providers.js.map +1 -0
- package/dist/secret.d.ts +30 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +68 -0
- package/dist/secret.js.map +1 -0
- package/dist/store.d.ts +12 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +25 -0
- package/dist/store.js.map +1 -0
- package/dist/sync.d.ts +26 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +75 -0
- package/dist/sync.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +83 -4
- package/skills/mail-cli/SKILL.md +27 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
child_process,
|
|
5
|
+
crypto,
|
|
6
|
+
fs,
|
|
7
|
+
os,
|
|
8
|
+
path,
|
|
9
|
+
stream,
|
|
10
|
+
util
|
|
11
|
+
} from "./chunk-DFDN6AUB.js";
|
|
12
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
13
|
+
export {
|
|
14
|
+
child_process,
|
|
15
|
+
crypto,
|
|
16
|
+
fs,
|
|
17
|
+
os,
|
|
18
|
+
path,
|
|
19
|
+
stream,
|
|
20
|
+
util
|
|
21
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
loadVectorExtension,
|
|
5
|
+
vectorExtension
|
|
6
|
+
} from "./chunk-ZANYM66S.js";
|
|
7
|
+
import "./chunk-J3QXTBD2.js";
|
|
8
|
+
import "./chunk-LQ37ALDJ.js";
|
|
9
|
+
import "./chunk-Y5E2WNWB.js";
|
|
10
|
+
import "./chunk-5BVIWP3S.js";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/store/drivers/node-sqlite.js
|
|
16
|
+
import { DatabaseSync } from "node:sqlite";
|
|
17
|
+
var openWithNodeSqlite = /* @__PURE__ */ __name(async (path) => cacheOverNodeSqlite(await nodeClient(path)), "openWithNodeSqlite");
|
|
18
|
+
var nodeClient = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
|
|
19
|
+
const extension = await vectorExtension();
|
|
20
|
+
const client = new DatabaseSync(path, { readOnly, allowExtension: true });
|
|
21
|
+
try {
|
|
22
|
+
loadVectorExtension(client, extension);
|
|
23
|
+
return client;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
client.close();
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}, "nodeClient");
|
|
29
|
+
var STATEMENT_CACHE_SIZE = 1e3;
|
|
30
|
+
var cacheOverNodeSqlite = /* @__PURE__ */ __name((database, cacheSize = STATEMENT_CACHE_SIZE) => {
|
|
31
|
+
const statements = /* @__PURE__ */ new Map();
|
|
32
|
+
const prepare = /* @__PURE__ */ __name((sql) => {
|
|
33
|
+
const statement = database.prepare(sql);
|
|
34
|
+
return {
|
|
35
|
+
run: /* @__PURE__ */ __name((...parameters) => ({ changes: Number(statement.run(...parameters).changes) }), "run"),
|
|
36
|
+
get: /* @__PURE__ */ __name((...parameters) => statement.get(...parameters), "get"),
|
|
37
|
+
all: /* @__PURE__ */ __name((...parameters) => statement.all(...parameters), "all")
|
|
38
|
+
};
|
|
39
|
+
}, "prepare");
|
|
40
|
+
return {
|
|
41
|
+
exec: /* @__PURE__ */ __name((sql) => database.exec(sql), "exec"),
|
|
42
|
+
prepare: /* @__PURE__ */ __name((sql) => {
|
|
43
|
+
const cached = statements.get(sql);
|
|
44
|
+
if (cached)
|
|
45
|
+
statements.delete(sql);
|
|
46
|
+
const statement = cached ?? prepare(sql);
|
|
47
|
+
statements.set(sql, statement);
|
|
48
|
+
if (statements.size > cacheSize)
|
|
49
|
+
statements.delete(statements.keys().next().value);
|
|
50
|
+
return statement;
|
|
51
|
+
}, "prepare"),
|
|
52
|
+
close: /* @__PURE__ */ __name(() => {
|
|
53
|
+
statements.clear();
|
|
54
|
+
database.close();
|
|
55
|
+
}, "close")
|
|
56
|
+
};
|
|
57
|
+
}, "cacheOverNodeSqlite");
|
|
58
|
+
export {
|
|
59
|
+
STATEMENT_CACHE_SIZE,
|
|
60
|
+
cacheOverNodeSqlite,
|
|
61
|
+
nodeClient,
|
|
62
|
+
openWithNodeSqlite
|
|
63
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ownerLogin,
|
|
5
|
+
revokeAll
|
|
6
|
+
} from "./chunk-BTQX2ZSZ.js";
|
|
7
|
+
import "./chunk-5D4AEUVA.js";
|
|
8
|
+
import "./chunk-GN62YOT5.js";
|
|
9
|
+
import "./chunk-TE5U5OAM.js";
|
|
10
|
+
import "./chunk-KM7Q67Z3.js";
|
|
11
|
+
import "./chunk-J3QXTBD2.js";
|
|
12
|
+
import "./chunk-LQ37ALDJ.js";
|
|
13
|
+
import "./chunk-Y5E2WNWB.js";
|
|
14
|
+
import "./chunk-5BVIWP3S.js";
|
|
15
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
16
|
+
export {
|
|
17
|
+
ownerLogin,
|
|
18
|
+
revokeAll
|
|
19
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CAPABILITY_STATEMENTS,
|
|
5
|
+
assertStoreCapable,
|
|
6
|
+
openCache,
|
|
7
|
+
openFile,
|
|
8
|
+
storeCapable
|
|
9
|
+
} from "./chunk-F6D6PJ34.js";
|
|
10
|
+
import "./chunk-J3QXTBD2.js";
|
|
11
|
+
import "./chunk-LQ37ALDJ.js";
|
|
12
|
+
import "./chunk-Y5E2WNWB.js";
|
|
13
|
+
import "./chunk-5BVIWP3S.js";
|
|
14
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
15
|
+
export {
|
|
16
|
+
CAPABILITY_STATEMENTS,
|
|
17
|
+
assertStoreCapable,
|
|
18
|
+
openCache,
|
|
19
|
+
openFile,
|
|
20
|
+
storeCapable
|
|
21
|
+
};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
SAMPLE_RATE,
|
|
5
|
+
toModelRate
|
|
6
|
+
} from "./chunk-QQB7WT7R.js";
|
|
7
|
+
import "./chunk-75CWWETH.js";
|
|
8
|
+
import {
|
|
9
|
+
OPENAI_URL
|
|
10
|
+
} from "./chunk-4E7BN3TC.js";
|
|
11
|
+
import "./chunk-Z34ICZA3.js";
|
|
12
|
+
import {
|
|
13
|
+
OPENAI_TRANSCRIBE_MODEL,
|
|
14
|
+
VAD,
|
|
15
|
+
filesPresent,
|
|
16
|
+
modelsDirectory,
|
|
17
|
+
vadPath
|
|
18
|
+
} from "./chunk-5NYMNSSO.js";
|
|
19
|
+
import "./chunk-FZ5FXIG6.js";
|
|
20
|
+
import {
|
|
21
|
+
DEFAULT_RETRY,
|
|
22
|
+
backoffMs
|
|
23
|
+
} from "./chunk-J3QXTBD2.js";
|
|
24
|
+
import "./chunk-LQ37ALDJ.js";
|
|
25
|
+
import "./chunk-Y5E2WNWB.js";
|
|
26
|
+
import {
|
|
27
|
+
CliError
|
|
28
|
+
} from "./chunk-5BVIWP3S.js";
|
|
29
|
+
import {
|
|
30
|
+
__name
|
|
31
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
32
|
+
|
|
33
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/speech/openai.js
|
|
34
|
+
import { setTimeout as wait } from "node:timers/promises";
|
|
35
|
+
|
|
36
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
|
|
37
|
+
var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
|
|
38
|
+
if (!header)
|
|
39
|
+
return void 0;
|
|
40
|
+
const trimmed = header.trim();
|
|
41
|
+
if (/^\d+$/.test(trimmed))
|
|
42
|
+
return Number(trimmed) * 1e3;
|
|
43
|
+
const at = Date.parse(trimmed);
|
|
44
|
+
if (Number.isNaN(at))
|
|
45
|
+
return void 0;
|
|
46
|
+
const delta = at - now().getTime();
|
|
47
|
+
return delta > 0 ? delta : void 0;
|
|
48
|
+
}, "parseRetryAfter");
|
|
49
|
+
var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
|
|
50
|
+
if (!header)
|
|
51
|
+
return void 0;
|
|
52
|
+
const seconds = Number(header.trim());
|
|
53
|
+
if (!Number.isFinite(seconds))
|
|
54
|
+
return void 0;
|
|
55
|
+
const delta = seconds * 1e3 - now().getTime();
|
|
56
|
+
return delta > 0 ? delta : void 0;
|
|
57
|
+
}, "parseRateLimitReset");
|
|
58
|
+
var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
|
|
59
|
+
|
|
60
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/speech/wav.js
|
|
61
|
+
var encodeWav = /* @__PURE__ */ __name((samples, sampleRate = 16e3) => {
|
|
62
|
+
const bytes = Buffer.alloc(44 + samples.length * 2);
|
|
63
|
+
bytes.write("RIFF", 0, "ascii");
|
|
64
|
+
bytes.writeUInt32LE(bytes.length - 8, 4);
|
|
65
|
+
bytes.write("WAVEfmt ", 8, "ascii");
|
|
66
|
+
bytes.writeUInt32LE(16, 16);
|
|
67
|
+
bytes.writeUInt16LE(1, 20);
|
|
68
|
+
bytes.writeUInt16LE(1, 22);
|
|
69
|
+
bytes.writeUInt32LE(sampleRate, 24);
|
|
70
|
+
bytes.writeUInt32LE(sampleRate * 2, 28);
|
|
71
|
+
bytes.writeUInt16LE(2, 32);
|
|
72
|
+
bytes.writeUInt16LE(16, 34);
|
|
73
|
+
bytes.write("data", 36, "ascii");
|
|
74
|
+
bytes.writeUInt32LE(samples.length * 2, 40);
|
|
75
|
+
samples.forEach((sample, index) => {
|
|
76
|
+
bytes.writeInt16LE(Math.round(Math.max(-1, Math.min(1, sample || 0)) * 32767), 44 + index * 2);
|
|
77
|
+
});
|
|
78
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
79
|
+
}, "encodeWav");
|
|
80
|
+
|
|
81
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/speech/openai.js
|
|
82
|
+
var LONGEST_REQUEST_SECONDS = 600;
|
|
83
|
+
var JOINED_SECONDS = 0.2;
|
|
84
|
+
var PAD_SECONDS = 0.2;
|
|
85
|
+
var LEAD = SAMPLE_RATE / 2;
|
|
86
|
+
var EXHAUSTED = /* @__PURE__ */ new Set([
|
|
87
|
+
"insufficient_quota",
|
|
88
|
+
"credit_balance_exhausted",
|
|
89
|
+
"organization_spend_limit_exceeded",
|
|
90
|
+
"project_spend_limit_exceeded",
|
|
91
|
+
"organization_usage_limit_exceeded"
|
|
92
|
+
]);
|
|
93
|
+
var RETRY = { ...DEFAULT_RETRY, retries: 4 };
|
|
94
|
+
var interrupted = /* @__PURE__ */ __name((signal) => {
|
|
95
|
+
if (!signal?.aborted)
|
|
96
|
+
return;
|
|
97
|
+
if (signal.reason instanceof CliError)
|
|
98
|
+
throw signal.reason;
|
|
99
|
+
const timeout = signal.reason instanceof Error && signal.reason.name === "TimeoutError";
|
|
100
|
+
throw new CliError(timeout ? "timeout" : "cancelled", "the transcription was interrupted");
|
|
101
|
+
}, "interrupted");
|
|
102
|
+
var sleeping = /* @__PURE__ */ __name((ms, signal) => wait(ms, void 0, signal ? { signal } : {}).then(() => void 0, (error) => {
|
|
103
|
+
interrupted(signal);
|
|
104
|
+
throw error;
|
|
105
|
+
}), "sleeping");
|
|
106
|
+
var formOf = /* @__PURE__ */ __name((wav, options) => {
|
|
107
|
+
const form = new FormData();
|
|
108
|
+
form.append("file", new Blob([wav], { type: "audio/wav" }), "audio.wav");
|
|
109
|
+
form.append("model", options.model ?? OPENAI_TRANSCRIBE_MODEL);
|
|
110
|
+
for (const language of options.languages ?? [])
|
|
111
|
+
form.append("languages[]", language);
|
|
112
|
+
for (const keyword of options.keywords ?? [])
|
|
113
|
+
form.append("keywords[]", keyword);
|
|
114
|
+
if (options.prompt)
|
|
115
|
+
form.append("prompt", options.prompt);
|
|
116
|
+
return form;
|
|
117
|
+
}, "formOf");
|
|
118
|
+
var safe = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[\w.-]{1,64}$/.test(value) ? value : void 0, "safe");
|
|
119
|
+
var failureOf = /* @__PURE__ */ __name(async (response) => {
|
|
120
|
+
try {
|
|
121
|
+
const body = await response.json();
|
|
122
|
+
const code = safe(body.error?.code);
|
|
123
|
+
const type = safe(body.error?.type);
|
|
124
|
+
return { ...code ? { code } : {}, ...type ? { type } : {} };
|
|
125
|
+
} catch {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
}, "failureOf");
|
|
129
|
+
var send = /* @__PURE__ */ __name(async (wav, options) => {
|
|
130
|
+
const post = options.fetch ?? fetch;
|
|
131
|
+
const retry = options.retry ?? RETRY;
|
|
132
|
+
const sleep = options.sleep ?? sleeping;
|
|
133
|
+
const random = options.random ?? Math.random;
|
|
134
|
+
const url = `${(options.baseUrl ?? OPENAI_URL).replace(/\/+$/, "")}/audio/transcriptions`;
|
|
135
|
+
for (let attempt = 1; ; attempt++) {
|
|
136
|
+
interrupted(options.signal);
|
|
137
|
+
let response;
|
|
138
|
+
try {
|
|
139
|
+
response = await post(url, {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: { authorization: `Bearer ${options.apiKey}` },
|
|
142
|
+
body: formOf(wav, options),
|
|
143
|
+
...options.signal ? { signal: options.signal } : {}
|
|
144
|
+
});
|
|
145
|
+
} catch {
|
|
146
|
+
interrupted(options.signal);
|
|
147
|
+
if (attempt > retry.retries)
|
|
148
|
+
throw new CliError("network_error", "OpenAI could not be reached", { reason: "network.failed" });
|
|
149
|
+
await sleep(backoffMs(attempt, retry, random), options.signal);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (response.ok) {
|
|
153
|
+
const body = await response.json().catch(() => interrupted(options.signal));
|
|
154
|
+
if (typeof body?.text !== "string")
|
|
155
|
+
throw new CliError("invalid_response", "OpenAI answered without a transcript", {
|
|
156
|
+
reason: "provider.invalid-response"
|
|
157
|
+
});
|
|
158
|
+
return body.text.trim();
|
|
159
|
+
}
|
|
160
|
+
const { code, type } = await failureOf(response);
|
|
161
|
+
const status = response.status;
|
|
162
|
+
const said = `HTTP ${status}${code ? `, ${code}` : type ? `, ${type}` : ""}`;
|
|
163
|
+
if (status === 401)
|
|
164
|
+
throw new CliError("authentication_error", `OpenAI refused the key (${said}) \u2014 set it again with \`models keys set openai\``, { reason: "auth.failed" });
|
|
165
|
+
if (status === 403)
|
|
166
|
+
throw new CliError("permission_error", `OpenAI refused the request (${said}) \u2014 it answers this when the country or region is not supported, or the key's project may not use the model`, { reason: "access.denied" });
|
|
167
|
+
if (status === 413)
|
|
168
|
+
throw new CliError("validation_error", `OpenAI refused the audio as too large (${said})`, {
|
|
169
|
+
reason: "transcription.too-large"
|
|
170
|
+
});
|
|
171
|
+
if (EXHAUSTED.has(code ?? "") || EXHAUSTED.has(type ?? ""))
|
|
172
|
+
throw new CliError("permission_error", `OpenAI refused: the account's credit, spend limit or usage limit is used up (${said}) \u2014 see the billing page`, { reason: "transcription.quota-exhausted" });
|
|
173
|
+
const again = status === 408 || status === 429 || status >= 500;
|
|
174
|
+
const asked = providerWaitMs(response.headers, () => /* @__PURE__ */ new Date());
|
|
175
|
+
if (again && attempt <= retry.retries && (asked === void 0 || asked <= retry.maxRetryAfterMs)) {
|
|
176
|
+
await sleep(asked ?? backoffMs(attempt, retry, random), options.signal);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (status === 429)
|
|
180
|
+
throw new CliError("rate_limited", `OpenAI answered ${said}`, {
|
|
181
|
+
reason: "provider.rate-limited",
|
|
182
|
+
...asked === void 0 ? {} : { retry_after_ms: asked }
|
|
183
|
+
});
|
|
184
|
+
if (status >= 500)
|
|
185
|
+
throw new CliError([502, 503, 504].includes(status) ? "provider_unavailable" : "provider_error", `OpenAI answered ${said}`, { reason: [502, 503, 504].includes(status) ? "provider.unavailable" : "provider.refused" });
|
|
186
|
+
throw new CliError("provider_error", `OpenAI answered ${said}`, { reason: "provider.refused" });
|
|
187
|
+
}
|
|
188
|
+
}, "send");
|
|
189
|
+
var piecesOf = /* @__PURE__ */ __name((spans, limit) => {
|
|
190
|
+
const pieces = [];
|
|
191
|
+
for (const span of spans) {
|
|
192
|
+
const last = pieces.at(-1);
|
|
193
|
+
const joined = last !== void 0 && span.start - last.end < JOINED_SECONDS;
|
|
194
|
+
const fits = last !== void 0 && limit !== void 0 && span.end - last.start <= limit;
|
|
195
|
+
if (last && (fits || joined && span.end - last.start <= LONGEST_REQUEST_SECONDS))
|
|
196
|
+
last.end = span.end;
|
|
197
|
+
else
|
|
198
|
+
pieces.push({ start: span.start, end: span.end });
|
|
199
|
+
}
|
|
200
|
+
return pieces;
|
|
201
|
+
}, "piecesOf");
|
|
202
|
+
var openCutter = /* @__PURE__ */ __name(async (vadModel) => {
|
|
203
|
+
const { openSpeechCutter } = await import("./recognize-PAR66KVM.js");
|
|
204
|
+
return openSpeechCutter(vadModel);
|
|
205
|
+
}, "openCutter");
|
|
206
|
+
var checkKeywords = /* @__PURE__ */ __name((keywords = []) => {
|
|
207
|
+
const bad = keywords.find((keyword) => typeof keyword !== "string" || !keyword.trim() || /[<>\r\n]/.test(keyword));
|
|
208
|
+
if (bad !== void 0)
|
|
209
|
+
throw new CliError("validation_error", "a keyword must be a non-empty single line without < or > \u2014 OpenAI refuses the whole request otherwise");
|
|
210
|
+
}, "checkKeywords");
|
|
211
|
+
var transcribeOpenAI = /* @__PURE__ */ __name(async (audio, options) => {
|
|
212
|
+
if (!options.apiKey)
|
|
213
|
+
throw new CliError("authentication_error", "no OpenAI key \u2014 `models keys set openai`, or OPENAI_API_KEY", {
|
|
214
|
+
reason: "transcription.no-key"
|
|
215
|
+
});
|
|
216
|
+
checkKeywords(options.keywords);
|
|
217
|
+
interrupted(options.signal);
|
|
218
|
+
const pcm = toModelRate(audio.samples, audio.rate);
|
|
219
|
+
const duration = (pcm.length - LEAD) / SAMPLE_RATE;
|
|
220
|
+
if (options.bundle && duration <= LONGEST_REQUEST_SECONDS) {
|
|
221
|
+
const text = await send(encodeWav(pcm.subarray(LEAD)), options);
|
|
222
|
+
return text ? [{ start: 0, end: duration, text }] : [];
|
|
223
|
+
}
|
|
224
|
+
const vadModel = options.vadModel ?? vadPath(modelsDirectory(options.env));
|
|
225
|
+
if (!options.cutter && !filesPresent([[VAD, vadModel]]))
|
|
226
|
+
throw new CliError("not_found", "the voice detector that finds the speech is not on this machine \u2014 it comes with any speech model: `models download`", { reason: "model.not-downloaded", model: "silero_vad" });
|
|
227
|
+
const cutter = await (options.cutter ?? openCutter)(vadModel);
|
|
228
|
+
let spans;
|
|
229
|
+
try {
|
|
230
|
+
spans = cutter.cut(pcm);
|
|
231
|
+
} finally {
|
|
232
|
+
cutter.free();
|
|
233
|
+
}
|
|
234
|
+
const pieces = piecesOf(spans, options.bundle ? LONGEST_REQUEST_SECONDS : void 0);
|
|
235
|
+
const heard = [];
|
|
236
|
+
for (const [index, piece] of pieces.entries()) {
|
|
237
|
+
const end = Math.min(piece.end, duration);
|
|
238
|
+
const from = Math.max(piece.start - PAD_SECONDS, pieces[index - 1]?.end ?? 0);
|
|
239
|
+
const to = Math.min(end + PAD_SECONDS, pieces[index + 1]?.start ?? duration);
|
|
240
|
+
const samples = pcm.subarray(LEAD + Math.floor(from * SAMPLE_RATE), LEAD + Math.ceil(to * SAMPLE_RATE));
|
|
241
|
+
const text = await send(encodeWav(samples), options);
|
|
242
|
+
if (text)
|
|
243
|
+
heard.push({ start: Math.min(piece.start, end), end, text });
|
|
244
|
+
}
|
|
245
|
+
return heard;
|
|
246
|
+
}, "transcribeOpenAI");
|
|
247
|
+
export {
|
|
248
|
+
LONGEST_REQUEST_SECONDS,
|
|
249
|
+
piecesOf,
|
|
250
|
+
transcribeOpenAI
|
|
251
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import "./chunk-Y5E2WNWB.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
7
|
+
|
|
8
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/embeddings/process.js
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { createInterface } from "node:readline";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
var openProcess = /* @__PURE__ */ __name(async (model, directory, { threads }) => {
|
|
13
|
+
const child = await modelProcess({ model, directory, threads });
|
|
14
|
+
return {
|
|
15
|
+
model,
|
|
16
|
+
embed: /* @__PURE__ */ __name(async (texts, kind) => ((await child.ask({ texts, kind })).vectors ?? []).map((vector) => Float32Array.from(vector)), "embed"),
|
|
17
|
+
close: child.close
|
|
18
|
+
};
|
|
19
|
+
}, "openProcess");
|
|
20
|
+
var openRerankerProcess = /* @__PURE__ */ __name(async (model, directory, { threads }) => {
|
|
21
|
+
const child = await modelProcess({ model, directory, threads, rerank: true });
|
|
22
|
+
return {
|
|
23
|
+
model,
|
|
24
|
+
score: /* @__PURE__ */ __name(async (question, passages) => (await child.ask({ question, texts: passages })).scores ?? [], "score"),
|
|
25
|
+
close: child.close
|
|
26
|
+
};
|
|
27
|
+
}, "openRerankerProcess");
|
|
28
|
+
var modelProcess = /* @__PURE__ */ __name(async (setup) => {
|
|
29
|
+
const child = spawn(process.execPath, [fileURLToPath(new URL("./child.js", new URL("embeddings/process.js", import.meta.resolve("@wirecat/cli-core")).href)), JSON.stringify(setup)], { stdio: ["pipe", "pipe", "pipe"] });
|
|
30
|
+
const pending = /* @__PURE__ */ new Map();
|
|
31
|
+
let said = "";
|
|
32
|
+
child.stderr.setEncoding("utf8").on("data", (text) => {
|
|
33
|
+
said = (said + text).slice(-2e3);
|
|
34
|
+
});
|
|
35
|
+
let ready = /* @__PURE__ */ __name(() => {
|
|
36
|
+
}, "ready");
|
|
37
|
+
let refused = /* @__PURE__ */ __name((_error) => {
|
|
38
|
+
}, "refused");
|
|
39
|
+
const started = new Promise((resolve, reject) => {
|
|
40
|
+
ready = resolve;
|
|
41
|
+
refused = reject;
|
|
42
|
+
});
|
|
43
|
+
let gone;
|
|
44
|
+
const stopped = /* @__PURE__ */ __name((error) => {
|
|
45
|
+
gone ??= error;
|
|
46
|
+
refused(error);
|
|
47
|
+
for (const job of pending.values())
|
|
48
|
+
job.reject(error);
|
|
49
|
+
pending.clear();
|
|
50
|
+
}, "stopped");
|
|
51
|
+
const exited = new Promise((resolve) => {
|
|
52
|
+
child.once("exit", (code) => {
|
|
53
|
+
const last = said.trim().split("\n").at(-1);
|
|
54
|
+
stopped(new Error(`the embedding process stopped (exit ${code})${last ? `: ${last}` : ""}`));
|
|
55
|
+
resolve();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
child.once("error", stopped);
|
|
59
|
+
createInterface({ input: child.stdout }).on("line", (line) => {
|
|
60
|
+
const answer = JSON.parse(line);
|
|
61
|
+
if ("ready" in answer)
|
|
62
|
+
return ready();
|
|
63
|
+
const job = pending.get(answer.id);
|
|
64
|
+
pending.delete(answer.id);
|
|
65
|
+
if (answer.error !== void 0 || !(answer.vectors ?? answer.scores))
|
|
66
|
+
job?.reject(new Error(answer.error ?? "no answer"));
|
|
67
|
+
else
|
|
68
|
+
job?.resolve(answer);
|
|
69
|
+
});
|
|
70
|
+
await started;
|
|
71
|
+
let next = 0;
|
|
72
|
+
return {
|
|
73
|
+
ask: /* @__PURE__ */ __name((request) => new Promise((resolve, reject) => {
|
|
74
|
+
if (gone)
|
|
75
|
+
return reject(gone);
|
|
76
|
+
const id = next++;
|
|
77
|
+
pending.set(id, { resolve, reject });
|
|
78
|
+
child.stdin.write(`${JSON.stringify({ id, ...request })}
|
|
79
|
+
`);
|
|
80
|
+
}), "ask"),
|
|
81
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
82
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
83
|
+
child.stdin.end();
|
|
84
|
+
await exited;
|
|
85
|
+
}, "close")
|
|
86
|
+
};
|
|
87
|
+
}, "modelProcess");
|
|
88
|
+
export {
|
|
89
|
+
openProcess,
|
|
90
|
+
openRerankerProcess
|
|
91
|
+
};
|