@wirecat/mail-cli 0.0.0-stage → 0.1.1

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.
Files changed (198) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +204 -0
  3. package/README.md +166 -2
  4. package/dist/bin/mail.d.ts +3 -0
  5. package/dist/bin/mail.d.ts.map +1 -0
  6. package/dist/bin/mail.js +36 -0
  7. package/dist/bin/mail.js.map +1 -0
  8. package/dist/bundle/all-profiles-TKMBELRZ.js +286 -0
  9. package/dist/bundle/anthropic-7LMUAEIZ.js +72 -0
  10. package/dist/bundle/app-server-JGMIJDD4.js +229 -0
  11. package/dist/bundle/bun-XRO6XJHQ.js +169 -0
  12. package/dist/bundle/bun-sqlite-Z54LEHVM.js +71 -0
  13. package/dist/bundle/chunk-2LLNPNMB.js +24 -0
  14. package/dist/bundle/chunk-3E3WA2L6.js +1932 -0
  15. package/dist/bundle/chunk-3KEVLSNN.js +138 -0
  16. package/dist/bundle/chunk-3KOA73LS.js +3416 -0
  17. package/dist/bundle/chunk-4E7BN3TC.js +122 -0
  18. package/dist/bundle/chunk-4FEMINO2.js +409 -0
  19. package/dist/bundle/chunk-52F5DWS5.js +27 -0
  20. package/dist/bundle/chunk-5BVIWP3S.js +71 -0
  21. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  22. package/dist/bundle/chunk-5NYMNSSO.js +264 -0
  23. package/dist/bundle/chunk-6MAZWSC3.js +132 -0
  24. package/dist/bundle/chunk-75CWWETH.js +379 -0
  25. package/dist/bundle/chunk-7SXGLT6T.js +444 -0
  26. package/dist/bundle/chunk-BTQX2ZSZ.js +288 -0
  27. package/dist/bundle/chunk-CEW6KIFA.js +1193 -0
  28. package/dist/bundle/chunk-CH6RXYAX.js +82 -0
  29. package/dist/bundle/chunk-D72URWJE.js +532 -0
  30. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  31. package/dist/bundle/chunk-EOEDICIE.js +6848 -0
  32. package/dist/bundle/chunk-F6D6PJ34.js +100 -0
  33. package/dist/bundle/chunk-FDCGTODC.js +78 -0
  34. package/dist/bundle/chunk-FZ5FXIG6.js +18 -0
  35. package/dist/bundle/chunk-GAH7N7HO.js +8181 -0
  36. package/dist/bundle/chunk-GK4M2SUP.js +195 -0
  37. package/dist/bundle/chunk-GN62YOT5.js +161 -0
  38. package/dist/bundle/chunk-GQQJOH7A.js +7050 -0
  39. package/dist/bundle/chunk-GWDCKUBI.js +781 -0
  40. package/dist/bundle/chunk-HTQTIKWP.js +928 -0
  41. package/dist/bundle/chunk-IK5TH3O7.js +217 -0
  42. package/dist/bundle/chunk-J3QXTBD2.js +2742 -0
  43. package/dist/bundle/chunk-J6MSJLIW.js +45 -0
  44. package/dist/bundle/chunk-JBBZCTTF.js +76 -0
  45. package/dist/bundle/chunk-JVMVLITS.js +260 -0
  46. package/dist/bundle/chunk-K4FVKPDQ.js +525 -0
  47. package/dist/bundle/chunk-KHTO2Q6E.js +886 -0
  48. package/dist/bundle/chunk-KM7Q67Z3.js +63 -0
  49. package/dist/bundle/chunk-LQ37ALDJ.js +2416 -0
  50. package/dist/bundle/chunk-MNOIRJEO.js +2315 -0
  51. package/dist/bundle/chunk-MS53RALV.js +168 -0
  52. package/dist/bundle/chunk-NK7EB63L.js +36225 -0
  53. package/dist/bundle/chunk-NPGVOZVK.js +2 -0
  54. package/dist/bundle/chunk-OTUOZ33L.js +82 -0
  55. package/dist/bundle/chunk-P7P5MNAU.js +46 -0
  56. package/dist/bundle/chunk-QLEUNU6G.js +537 -0
  57. package/dist/bundle/chunk-QQB7WT7R.js +216 -0
  58. package/dist/bundle/chunk-QX7RCLRS.js +23 -0
  59. package/dist/bundle/chunk-T6464KYA.js +35130 -0
  60. package/dist/bundle/chunk-TE5U5OAM.js +73 -0
  61. package/dist/bundle/chunk-TI6VBZKJ.js +166 -0
  62. package/dist/bundle/chunk-TQFCPUIM.js +53 -0
  63. package/dist/bundle/chunk-TVREDYX4.js +3574 -0
  64. package/dist/bundle/chunk-TWPDVUBR.js +106 -0
  65. package/dist/bundle/chunk-TWTATDM7.js +461 -0
  66. package/dist/bundle/chunk-UH4DDRHA.js +2989 -0
  67. package/dist/bundle/chunk-VEIZZRQ5.js +630 -0
  68. package/dist/bundle/chunk-WLFLBWNH.js +54 -0
  69. package/dist/bundle/chunk-WXAXYJJ7.js +486 -0
  70. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  71. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  72. package/dist/bundle/chunk-YO4CUH5E.js +33 -0
  73. package/dist/bundle/chunk-YPQQ5J4X.js +849 -0
  74. package/dist/bundle/chunk-Z34ICZA3.js +1028 -0
  75. package/dist/bundle/chunk-ZANYM66S.js +58 -0
  76. package/dist/bundle/chunk-ZD3WUGR2.js +142 -0
  77. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  78. package/dist/bundle/command-contract-WU434ZUL.js +34 -0
  79. package/dist/bundle/decode-YB3ZDTES.js +162 -0
  80. package/dist/bundle/dispatch-EUKKT3PD.js +411 -0
  81. package/dist/bundle/dist-A6GKSKFC.js +2072 -0
  82. package/dist/bundle/dist-HFUVURJG.js +7577 -0
  83. package/dist/bundle/echarts-YNGCOYHW.js +42501 -0
  84. package/dist/bundle/embed-LWNHIRBQ.js +37 -0
  85. package/dist/bundle/embedder-2LYD3U37.js +110 -0
  86. package/dist/bundle/failure-OAIC5VAP.js +24 -0
  87. package/dist/bundle/first-run-N3HJKGU7.js +27 -0
  88. package/dist/bundle/first-screen-4U2DMV3G.js +32 -0
  89. package/dist/bundle/instructions-GJHHFV64.js +11 -0
  90. package/dist/bundle/mail.js +166 -0
  91. package/dist/bundle/mcp-L7SRVDRN.js +167 -0
  92. package/dist/bundle/node-GFOH6FKP.js +176 -0
  93. package/dist/bundle/node-KM3CUABH.js +2340 -0
  94. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  95. package/dist/bundle/node-sqlite-NBXQXBIU.js +63 -0
  96. package/dist/bundle/oauth-56EFO5AQ.js +19 -0
  97. package/dist/bundle/open-2V7QZQJP.js +21 -0
  98. package/dist/bundle/openai-V3SVACVL.js +251 -0
  99. package/dist/bundle/process-XVDX4SPD.js +91 -0
  100. package/dist/bundle/program-JTJB26P3.js +35542 -0
  101. package/dist/bundle/prompt-YKWAI222.js +14 -0
  102. package/dist/bundle/recognize-PAR66KVM.js +25 -0
  103. package/dist/bundle/remote-CE43TKXC.js +28 -0
  104. package/dist/bundle/rerank-M7S7P2TW.js +51 -0
  105. package/dist/bundle/serve-ENPMIV6J.js +197 -0
  106. package/dist/bundle/server-JRTHUCVY.js +63 -0
  107. package/dist/bundle/server-MBEZLVKZ.js +189 -0
  108. package/dist/bundle/sqlite-runtime-HVGDHBJJ.js +18 -0
  109. package/dist/bundle/state-QZSOSKBD.js +35 -0
  110. package/dist/bundle/store-2BUX6LVX.js +124 -0
  111. package/dist/bundle/store-UJ7SNKXI.js +141 -0
  112. package/dist/bundle/store-maintenance-command-I7V5C44K.js +52 -0
  113. package/dist/commands/account.d.ts +3 -0
  114. package/dist/commands/account.d.ts.map +1 -0
  115. package/dist/commands/account.js +47 -0
  116. package/dist/commands/account.js.map +1 -0
  117. package/dist/commands/context.d.ts +41 -0
  118. package/dist/commands/context.d.ts.map +1 -0
  119. package/dist/commands/context.js +52 -0
  120. package/dist/commands/context.js.map +1 -0
  121. package/dist/commands/folders.d.ts +3 -0
  122. package/dist/commands/folders.d.ts.map +1 -0
  123. package/dist/commands/folders.js +36 -0
  124. package/dist/commands/folders.js.map +1 -0
  125. package/dist/commands/login.d.ts +5 -0
  126. package/dist/commands/login.d.ts.map +1 -0
  127. package/dist/commands/login.js +21 -0
  128. package/dist/commands/login.js.map +1 -0
  129. package/dist/commands/mailbox.d.ts +16 -0
  130. package/dist/commands/mailbox.d.ts.map +1 -0
  131. package/dist/commands/mailbox.js +54 -0
  132. package/dist/commands/mailbox.js.map +1 -0
  133. package/dist/commands/session.d.ts +3 -0
  134. package/dist/commands/session.d.ts.map +1 -0
  135. package/dist/commands/session.js +211 -0
  136. package/dist/commands/session.js.map +1 -0
  137. package/dist/commands/status.d.ts +3 -0
  138. package/dist/commands/status.d.ts.map +1 -0
  139. package/dist/commands/status.js +89 -0
  140. package/dist/commands/status.js.map +1 -0
  141. package/dist/commands/sync.d.ts +3 -0
  142. package/dist/commands/sync.d.ts.map +1 -0
  143. package/dist/commands/sync.js +190 -0
  144. package/dist/commands/sync.js.map +1 -0
  145. package/dist/config.d.ts +190 -0
  146. package/dist/config.d.ts.map +1 -0
  147. package/dist/config.js +46 -0
  148. package/dist/config.js.map +1 -0
  149. package/dist/discovery.d.ts +42 -0
  150. package/dist/discovery.d.ts.map +1 -0
  151. package/dist/discovery.js +179 -0
  152. package/dist/discovery.js.map +1 -0
  153. package/dist/identity.d.ts +5 -0
  154. package/dist/identity.d.ts.map +1 -0
  155. package/dist/identity.js +16 -0
  156. package/dist/identity.js.map +1 -0
  157. package/dist/index.d.ts +3 -0
  158. package/dist/index.d.ts.map +1 -0
  159. package/dist/index.js +3 -0
  160. package/dist/index.js.map +1 -0
  161. package/dist/mail/imap-errors.d.ts +4 -0
  162. package/dist/mail/imap-errors.d.ts.map +1 -0
  163. package/dist/mail/imap-errors.js +41 -0
  164. package/dist/mail/imap-errors.js.map +1 -0
  165. package/dist/mail/imap-messages.d.ts +18 -0
  166. package/dist/mail/imap-messages.d.ts.map +1 -0
  167. package/dist/mail/imap-messages.js +66 -0
  168. package/dist/mail/imap-messages.js.map +1 -0
  169. package/dist/mail/imap.d.ts +67 -0
  170. package/dist/mail/imap.d.ts.map +1 -0
  171. package/dist/mail/imap.js +348 -0
  172. package/dist/mail/imap.js.map +1 -0
  173. package/dist/profile.d.ts +16 -0
  174. package/dist/profile.d.ts.map +1 -0
  175. package/dist/profile.js +31 -0
  176. package/dist/profile.js.map +1 -0
  177. package/dist/program.d.ts +6 -0
  178. package/dist/program.d.ts.map +1 -0
  179. package/dist/program.js +52 -0
  180. package/dist/program.js.map +1 -0
  181. package/dist/providers.d.ts +53 -0
  182. package/dist/providers.d.ts.map +1 -0
  183. package/dist/providers.js +106 -0
  184. package/dist/providers.js.map +1 -0
  185. package/dist/secret.d.ts +30 -0
  186. package/dist/secret.d.ts.map +1 -0
  187. package/dist/secret.js +68 -0
  188. package/dist/secret.js.map +1 -0
  189. package/dist/store.d.ts +12 -0
  190. package/dist/store.d.ts.map +1 -0
  191. package/dist/store.js +25 -0
  192. package/dist/store.js.map +1 -0
  193. package/dist/version.d.ts +2 -0
  194. package/dist/version.d.ts.map +1 -0
  195. package/dist/version.js +2 -0
  196. package/dist/version.js.map +1 -0
  197. package/package.json +83 -4
  198. package/skills/mail-cli/SKILL.md +27 -0
@@ -0,0 +1,58 @@
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-5BVIWP3S.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-ZVVMGPBJ.js";
12
+
13
+ // 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/vector-extension.js
14
+ import { readFileSync } from "node:fs";
15
+ var musl = /* @__PURE__ */ __name(() => {
16
+ if (process.platform !== "linux")
17
+ return false;
18
+ try {
19
+ return readFileSync("/proc/self/maps", "utf8").includes("ld-musl");
20
+ } catch {
21
+ return false;
22
+ }
23
+ }, "musl");
24
+ var found;
25
+ var vectorExtension = /* @__PURE__ */ __name(() => {
26
+ found ??= locate();
27
+ return found;
28
+ }, "vectorExtension");
29
+ var locate = /* @__PURE__ */ __name(async () => {
30
+ const onMusl = musl();
31
+ const target = `${process.platform}-${process.arch}${onMusl ? "-musl" : ""}`;
32
+ let path;
33
+ try {
34
+ const { extensionFor } = await importFrom(new URL("store/vector-extension.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
35
+ path = extensionFor({ musl: onMusl });
36
+ } catch {
37
+ path = void 0;
38
+ }
39
+ if (path === void 0) {
40
+ found = void 0;
41
+ throw new CliError("configuration_error", `the message store needs the sqlite-vec extension, and @wirecat/cli-core-sqlite has none for ${target} \u2014 reinstall the CLI so its dependencies install with it (an install that skips optional or native packages leaves it out)`, { reason: "store.vector-extension-missing", target });
42
+ }
43
+ return path;
44
+ }, "locate");
45
+ var loadVectorExtension = /* @__PURE__ */ __name((database, path) => {
46
+ try {
47
+ database.loadExtension(path);
48
+ } catch (error) {
49
+ throw new CliError("configuration_error", `the sqlite-vec extension did not load on ${process.platform}-${process.arch} \u2014 reinstall the CLI; on macOS under Bun, @wirecat/cli-core-sqlite's SQLite must be installed, since the system's cannot load extensions`, { reason: "store.vector-extension-failed", cause: error instanceof Error ? error.message : String(error) });
50
+ } finally {
51
+ database.enableLoadExtension?.(false);
52
+ }
53
+ }, "loadVectorExtension");
54
+
55
+ export {
56
+ vectorExtension,
57
+ loadVectorExtension
58
+ };
@@ -0,0 +1,142 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ executableEnvironment,
5
+ executableOnPath
6
+ } from "./chunk-P7P5MNAU.js";
7
+ import {
8
+ require_cross_spawn
9
+ } from "./chunk-D72URWJE.js";
10
+ import {
11
+ loadConfigFile,
12
+ saveConfigFile
13
+ } from "./chunk-J3QXTBD2.js";
14
+ import {
15
+ number,
16
+ object,
17
+ optional,
18
+ string
19
+ } from "./chunk-LQ37ALDJ.js";
20
+ import {
21
+ __name,
22
+ __toESM
23
+ } from "./chunk-ZVVMGPBJ.js";
24
+
25
+ // 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/update/index.js
26
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
27
+ import { existsSync } from "node:fs";
28
+ var updateCommand = /* @__PURE__ */ __name((installer, packageName) => {
29
+ const target = `${packageName}@latest`;
30
+ switch (installer) {
31
+ // pnpm 11 installs only versions a day old (minimumReleaseAge 1440); a fix must reach users the day it ships.
32
+ // Only the package's own scope is exempt — every other dependency keeps the wait.
33
+ case "pnpm":
34
+ return ["pnpm", "add", "-g", target, `--config.minimumReleaseAgeExclude=${ownScope(packageName)}`];
35
+ case "npm":
36
+ return ["npm", "install", "-g", target];
37
+ case "bun":
38
+ return ["bun", "add", "-g", target];
39
+ default:
40
+ return void 0;
41
+ }
42
+ }, "updateCommand");
43
+ var ownScope = /* @__PURE__ */ __name((packageName) => packageName.startsWith("@") ? `${packageName.split("/", 1)[0]}/*` : packageName, "ownScope");
44
+ var isNewer = /* @__PURE__ */ __name((candidate, current) => {
45
+ const parse = /* @__PURE__ */ __name((version) => /^\d+\.\d+\.\d+$/.test(version) ? version.split(".").map(Number) : void 0, "parse");
46
+ const a = parse(candidate);
47
+ const b = parse(current);
48
+ if (!a || !b)
49
+ return false;
50
+ for (let i = 0; i < 3; i++) {
51
+ if (a[i] !== b[i])
52
+ return a[i] > b[i];
53
+ }
54
+ return false;
55
+ }, "isNewer");
56
+ var latestVersion = /* @__PURE__ */ __name(async (packageName, fetch, { timeoutMs = 1e3 } = {}) => {
57
+ try {
58
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
59
+ signal: AbortSignal.timeout(timeoutMs),
60
+ headers: { accept: "application/json" }
61
+ });
62
+ if (!response.ok)
63
+ return void 0;
64
+ const { version } = await response.json();
65
+ return typeof version === "string" ? version : void 0;
66
+ } catch {
67
+ return void 0;
68
+ }
69
+ }, "latestVersion");
70
+ var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
71
+ var mayNotify = /* @__PURE__ */ __name(({ format, stderrIsTTY, quiet, enabled, installer, env, offVariables = [] }) => enabled && format === "pretty" && stderrIsTTY && !quiet && updateCommand(installer, "any") !== void 0 && !env.CI && !env.NO_UPDATE_NOTIFIER && offVariables.every((name) => !env[name]), "mayNotify");
72
+ var updateState = object({
73
+ checkedAt: number(),
74
+ latest: optional(string()),
75
+ /** When the skill hint (`cli-base/skill`) was last shown — the other daily notice kept in this file. */
76
+ skillHintAt: optional(number())
77
+ });
78
+ var readNoticeState = /* @__PURE__ */ __name((path) => {
79
+ try {
80
+ return loadConfigFile(path, updateState, () => ({ checkedAt: 0 }));
81
+ } catch {
82
+ return { checkedAt: 0 };
83
+ }
84
+ }, "readNoticeState");
85
+ var readUpdateState = /* @__PURE__ */ __name((path) => {
86
+ const state = readNoticeState(path);
87
+ return state.checkedAt > 0 ? state : void 0;
88
+ }, "readUpdateState");
89
+ var writeUpdateState = /* @__PURE__ */ __name((path, state) => {
90
+ try {
91
+ saveConfigFile(path, { ...readNoticeState(path), ...state });
92
+ } catch {
93
+ }
94
+ }, "writeUpdateState");
95
+ var checkIsDue = /* @__PURE__ */ __name((state, now) => state === void 0 || now - state.checkedAt >= CHECK_EVERY_MS, "checkIsDue");
96
+ var spawnPlan = /* @__PURE__ */ __name(([command, ...args], platform = process.platform, env = process.env, exists = existsSync) => ({ file: executableOnPath(command, env, platform, exists), args, shell: false }), "spawnPlan");
97
+ var runUpdate = /* @__PURE__ */ __name((argv) => {
98
+ const { file, args, shell } = spawnPlan(argv);
99
+ const { status, error } = import_cross_spawn.default.sync(file, args, {
100
+ stdio: ["inherit", 2, 2],
101
+ shell,
102
+ env: executableEnvironment(process.env)
103
+ });
104
+ if (error)
105
+ throw new Error(`could not start ${argv[0]}: ${error.message}`);
106
+ return status ?? 1;
107
+ }, "runUpdate");
108
+ var updateNotice = /* @__PURE__ */ __name(async ({ argv, packageName, command, upgradeCommand = "upgrade", version, statePath, fetch, now = Date.now, ...context }) => {
109
+ try {
110
+ const path = commandWords(argv).slice(0, 2);
111
+ if (path.includes("complete") || path.includes(upgradeCommand))
112
+ return void 0;
113
+ if (!mayNotify(context))
114
+ return void 0;
115
+ const at = now();
116
+ let state = readUpdateState(statePath);
117
+ if (checkIsDue(state, at)) {
118
+ const found = await latestVersion(packageName, fetch, { timeoutMs: 1e3 });
119
+ const seen = found ?? state?.latest;
120
+ state = seen ? { checkedAt: at, latest: seen } : { checkedAt: at };
121
+ writeUpdateState(statePath, state);
122
+ }
123
+ return state?.latest && isNewer(state.latest, version) ? `${command} ${state.latest} is out \u2014 you have ${version}. \`${command} ${upgradeCommand}\` installs it.` : void 0;
124
+ } catch {
125
+ return void 0;
126
+ }
127
+ }, "updateNotice");
128
+ var commandWords = /* @__PURE__ */ __name((argv) => {
129
+ const end = argv.indexOf("--");
130
+ return argv.slice(0, end < 0 ? void 0 : end).filter((word) => !word.startsWith("-"));
131
+ }, "commandWords");
132
+
133
+ export {
134
+ updateCommand,
135
+ isNewer,
136
+ latestVersion,
137
+ CHECK_EVERY_MS,
138
+ readNoticeState,
139
+ writeUpdateState,
140
+ runUpdate,
141
+ updateNotice
142
+ };
@@ -0,0 +1,50 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
+ });
16
+ var __commonJS = (cb, mod) => function __require2() {
17
+ try {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ } catch (e) {
20
+ throw mod = 0, e;
21
+ }
22
+ };
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
+ // If the importer is in node compatibility mode or this is not an ESM
37
+ // file that has been converted to a CommonJS file using a Babel-
38
+ // compatible transform (i.e. "__esModule" has not been set), then set
39
+ // "default" to the CommonJS "module.exports" for node compatibility.
40
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
+ mod
42
+ ));
43
+
44
+ export {
45
+ __name,
46
+ __require,
47
+ __commonJS,
48
+ __export,
49
+ __toESM
50
+ };
@@ -0,0 +1,34 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ SCHEMA_DIALECT,
5
+ commandContract,
6
+ commandPathOf,
7
+ findCommand,
8
+ outputOf
9
+ } from "./chunk-MS53RALV.js";
10
+ import "./chunk-TVREDYX4.js";
11
+ import "./chunk-GQQJOH7A.js";
12
+ import "./chunk-QLEUNU6G.js";
13
+ import "./chunk-7SXGLT6T.js";
14
+ import "./chunk-WLFLBWNH.js";
15
+ import "./chunk-KM7Q67Z3.js";
16
+ import "./chunk-6MAZWSC3.js";
17
+ import "./chunk-3KEVLSNN.js";
18
+ import "./chunk-UH4DDRHA.js";
19
+ import "./chunk-NPGVOZVK.js";
20
+ import "./chunk-KHTO2Q6E.js";
21
+ import "./chunk-5NYMNSSO.js";
22
+ import "./chunk-FZ5FXIG6.js";
23
+ import "./chunk-J3QXTBD2.js";
24
+ import "./chunk-LQ37ALDJ.js";
25
+ import "./chunk-Y5E2WNWB.js";
26
+ import "./chunk-5BVIWP3S.js";
27
+ import "./chunk-ZVVMGPBJ.js";
28
+ export {
29
+ SCHEMA_DIALECT,
30
+ commandContract,
31
+ commandPathOf,
32
+ findCommand,
33
+ outputOf
34
+ };
@@ -0,0 +1,162 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ SAMPLE_RATE,
5
+ decodeOgg
6
+ } from "./chunk-QQB7WT7R.js";
7
+ import "./chunk-J3QXTBD2.js";
8
+ import "./chunk-LQ37ALDJ.js";
9
+ import {
10
+ importFrom
11
+ } from "./chunk-Y5E2WNWB.js";
12
+ import {
13
+ CliError
14
+ } from "./chunk-5BVIWP3S.js";
15
+ import {
16
+ __name
17
+ } from "./chunk-ZVVMGPBJ.js";
18
+
19
+ // 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/decode.js
20
+ import { spawn } from "node:child_process";
21
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
22
+ import { createRequire } from "node:module";
23
+ import { tmpdir } from "node:os";
24
+ import { join } from "node:path";
25
+ import { pathToFileURL } from "node:url";
26
+ var LONGEST_AUDIO_SECONDS = 3600;
27
+ var FFMPEG_TIMEOUT_MS = 12e4;
28
+ var FFMPEG_FORMATS = "mov,mp4,m4a,3gp,3g2,mj2,aac,mp3,wav,amr,caf,aiff,flac,ogg,matroska,webm,asf";
29
+ var text = /* @__PURE__ */ __name((bytes, from, length) => String.fromCharCode(...bytes.subarray(from, from + length)), "text");
30
+ var contains = /* @__PURE__ */ __name((bytes, needle, within) => Buffer.from(bytes.buffer, bytes.byteOffset, Math.min(bytes.length, within)).includes(needle, 0, "latin1"), "contains");
31
+ var formatOf = /* @__PURE__ */ __name((bytes) => {
32
+ if (text(bytes, 0, 4) === "OggS") {
33
+ if (contains(bytes, "OpusHead", 128))
34
+ return "opus";
35
+ if (contains(bytes, "vorbis", 128))
36
+ return "vorbis";
37
+ return "other";
38
+ }
39
+ if (text(bytes, 0, 4) === "fLaC")
40
+ return "flac";
41
+ const frame = bytes[0] === 255 && ((bytes[1] ?? 0) & 224) === 224 && ((bytes[1] ?? 0) >> 1 & 3) !== 0;
42
+ if (text(bytes, 0, 3) === "ID3" || frame)
43
+ return "mp3";
44
+ return "other";
45
+ }, "formatOf");
46
+ var everyChannel = /* @__PURE__ */ __name((decoded) => {
47
+ if (!decoded.channelData[0] || decoded.samplesDecoded === 0)
48
+ throw new CliError("validation_error", "no audio in that file");
49
+ return decoded.channelData.map((samples) => ({ samples, rate: decoded.sampleRate }));
50
+ }, "everyChannel");
51
+ var load = /* @__PURE__ */ __name((name) => importFrom(new URL("speech/decode.js", import.meta.resolve("@wirecat/cli-core")).href, pathToFileURL(createRequire(new URL("speech/decode.js", import.meta.resolve("@wirecat/cli-core")).href).resolve(name)).href), "load");
52
+ var decodeVorbis = /* @__PURE__ */ __name(async (bytes) => {
53
+ const { OggVorbisDecoder } = await load("@wasm-audio-decoders/ogg-vorbis");
54
+ const decoder = new OggVorbisDecoder();
55
+ await decoder.ready;
56
+ try {
57
+ return everyChannel(await decoder.decodeFile(bytes));
58
+ } finally {
59
+ decoder.free();
60
+ }
61
+ }, "decodeVorbis");
62
+ var decodeFlac = /* @__PURE__ */ __name(async (bytes) => {
63
+ const { FLACDecoder } = await load("@wasm-audio-decoders/flac");
64
+ const decoder = new FLACDecoder();
65
+ await decoder.ready;
66
+ try {
67
+ return everyChannel(await decoder.decodeFile(bytes));
68
+ } finally {
69
+ decoder.free();
70
+ }
71
+ }, "decodeFlac");
72
+ var decodeMp3 = /* @__PURE__ */ __name(async (bytes) => {
73
+ const { MPEGDecoder } = await load("mpg123-decoder");
74
+ const decoder = new MPEGDecoder();
75
+ await decoder.ready;
76
+ try {
77
+ return everyChannel(decoder.decode(bytes));
78
+ } finally {
79
+ decoder.free();
80
+ }
81
+ }, "decodeMp3");
82
+ var runFfmpeg = /* @__PURE__ */ __name(async (bytes) => {
83
+ const directory = await mkdtemp(join(tmpdir(), "wirecat-audio-"));
84
+ try {
85
+ const input = join(directory, "audio");
86
+ await writeFile(input, bytes, { mode: 384 });
87
+ const largest = LONGEST_AUDIO_SECONDS * SAMPLE_RATE * 4;
88
+ const output = await new Promise((resolve, reject) => {
89
+ const child = spawn("ffmpeg", [
90
+ "-nostdin",
91
+ "-hide_banner",
92
+ "-loglevel",
93
+ "error",
94
+ "-protocol_whitelist",
95
+ "file",
96
+ "-format_whitelist",
97
+ FFMPEG_FORMATS,
98
+ "-i",
99
+ input,
100
+ "-vn",
101
+ "-ac",
102
+ "1",
103
+ "-ar",
104
+ String(SAMPLE_RATE),
105
+ "-f",
106
+ "f32le",
107
+ "pipe:1"
108
+ ], { stdio: ["ignore", "pipe", "pipe"], timeout: FFMPEG_TIMEOUT_MS });
109
+ const chunks = [];
110
+ let size = 0;
111
+ let errors = "";
112
+ child.stdout.on("data", (chunk) => {
113
+ size += chunk.length;
114
+ if (size > largest)
115
+ child.kill();
116
+ else
117
+ chunks.push(chunk);
118
+ });
119
+ child.stderr.on("data", (chunk) => {
120
+ errors = (errors + chunk.toString()).slice(-500);
121
+ });
122
+ child.on("error", (error) => reject(error.code === "ENOENT" ? new CliError("validation_error", "only ffmpeg reads this audio format, and ffmpeg is not installed") : error));
123
+ child.on("close", (code) => {
124
+ if (size > largest)
125
+ reject(new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`));
126
+ else if (code === 0)
127
+ resolve(Buffer.concat(chunks));
128
+ else
129
+ reject(new CliError("validation_error", `ffmpeg could not read the audio: ${errors.trim() || code}`));
130
+ });
131
+ });
132
+ const samples = new Float32Array(Math.floor(output.length / 4));
133
+ Buffer.from(samples.buffer).set(output.subarray(0, samples.length * 4));
134
+ return { samples, rate: SAMPLE_RATE };
135
+ } finally {
136
+ await rm(directory, { recursive: true, force: true });
137
+ }
138
+ }, "runFfmpeg");
139
+ var BUNDLED = {
140
+ opus: decodeOgg,
141
+ vorbis: decodeVorbis,
142
+ flac: decodeFlac,
143
+ mp3: decodeMp3
144
+ };
145
+ var tooLong = /* @__PURE__ */ __name((pcm) => pcm.samples.length / pcm.rate > LONGEST_AUDIO_SECONDS, "tooLong");
146
+ var decodeChannels = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => {
147
+ const format = formatOf(bytes);
148
+ const decoded = format === "other" ? { channels: [await ffmpeg(bytes)], mixed: true } : await BUNDLED[format](bytes).then((channels) => ({ channels, mixed: false }), (error) => ffmpeg(bytes).then((pcm) => ({ channels: [pcm], mixed: true }), () => {
149
+ throw error;
150
+ }));
151
+ if (decoded.channels.some(tooLong))
152
+ throw new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`);
153
+ return decoded;
154
+ }, "decodeChannels");
155
+ var decodeAudio = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => (await decodeChannels(bytes, ffmpeg)).channels[0], "decodeAudio");
156
+ export {
157
+ LONGEST_AUDIO_SECONDS,
158
+ decodeAudio,
159
+ decodeChannels,
160
+ formatOf,
161
+ runFfmpeg
162
+ };