@wirecat/zoom-cli 0.60.1 → 0.62.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.
Files changed (182) hide show
  1. package/README.md +3 -3
  2. package/dist/answers.d.ts +16 -0
  3. package/dist/answers.d.ts.map +1 -1
  4. package/dist/bin/zm.js +2 -2
  5. package/dist/bundle/{chunk-3R437ICM.js → all-profiles-CGGNBINU.js} +11 -7
  6. package/dist/bundle/answer-policy-D46SGQ35.js +96 -0
  7. package/dist/bundle/{anthropic-CSLAACWX.js → anthropic-KVWPIHFG.js} +4 -4
  8. package/dist/bundle/{app-server-RYYXX6QV.js → app-server-NKKFBTQN.js} +50 -50
  9. package/dist/bundle/{bun-JVDJVDHL.js → bun-XRO6XJHQ.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-B5CZHAV4.js → bun-sqlite-FWNCLOAR.js} +3 -3
  11. package/dist/bundle/{chunk-HAUAEGGI.js → chunk-2DPMYUWQ.js} +10 -10
  12. package/dist/bundle/{chunk-HBYE4EP2.js → chunk-2LLNPNMB.js} +1 -1
  13. package/dist/bundle/{chunk-WB7MQHUI.js → chunk-2NAM2XQG.js} +2 -2
  14. package/dist/bundle/{chunk-PAEBFJUC.js → chunk-2T7MUSDB.js} +118 -95
  15. package/dist/bundle/{chunk-LPY2ISJK.js → chunk-3YBDRVOG.js} +6 -6
  16. package/dist/bundle/{chunk-WEUXLXOZ.js → chunk-4OQVRDTG.js} +31 -21
  17. package/dist/bundle/{chunk-Q7U627RY.js → chunk-4OTXE6CF.js} +79 -59
  18. package/dist/bundle/{chunk-LPDYI5GR.js → chunk-4UUQEQ5D.js} +1 -1
  19. package/dist/bundle/{chunk-FWJ3Q7NO.js → chunk-5LMQTEU5.js} +5 -5
  20. package/dist/bundle/{chunk-6BJQBVMN.js → chunk-5MYLM6SU.js} +45 -27
  21. package/dist/bundle/{chunk-Z5H47R4G.js → chunk-5NLFQ644.js} +1034 -870
  22. package/dist/bundle/{chunk-XS72YFPV.js → chunk-6R3GMSLR.js} +2 -2
  23. package/dist/bundle/{chunk-AZZPMHP2.js → chunk-6SK5SHCR.js} +2 -2
  24. package/dist/bundle/{chunk-TY5PBEH2.js → chunk-6SPWQCJF.js} +11 -11
  25. package/dist/bundle/{chunk-EUHQ5D4K.js → chunk-6URISMGR.js} +26 -26
  26. package/dist/bundle/{chunk-43BX56ZI.js → chunk-72S5TXFN.js} +9 -9
  27. package/dist/bundle/{chunk-OBUKZ2ZM.js → chunk-73BAQ7PH.js} +31 -211
  28. package/dist/bundle/{chunk-3LBA63D5.js → chunk-7AY3ADNV.js} +22 -5
  29. package/dist/bundle/{chunk-RACSKYNX.js → chunk-7CNRZSAV.js} +7 -5
  30. package/dist/bundle/{chunk-IQENQXUJ.js → chunk-7LQLJ7LW.js} +2 -2
  31. package/dist/bundle/{chunk-EN5DBDKW.js → chunk-AMIIU3UZ.js} +4 -4
  32. package/dist/bundle/{chunk-RUEPZTNA.js → chunk-BJPFWPKH.js} +2 -2
  33. package/dist/bundle/{chunk-KNAS4VEA.js → chunk-BNTAQADF.js} +2 -2
  34. package/dist/bundle/{chunk-PEMLI3T7.js → chunk-BPMKLWHV.js} +6 -4
  35. package/dist/bundle/chunk-CXPHUOJR.js +380 -0
  36. package/dist/bundle/{chunk-LVHZQCP4.js → chunk-D6FTCPXA.js} +14 -10
  37. package/dist/bundle/{chunk-IRX2YVAH.js → chunk-DIXC56OU.js} +4 -4
  38. package/dist/bundle/{chunk-WFT2GGFH.js → chunk-ECXRRW7J.js} +25 -22
  39. package/dist/bundle/{chunk-KXEC5FVT.js → chunk-EG7HC4EC.js} +2 -2
  40. package/dist/bundle/{chunk-GEVHI226.js → chunk-EJFSS65P.js} +6 -6
  41. package/dist/bundle/{chunk-HIAO4MPA.js → chunk-EOEDICIE.js} +1 -1
  42. package/dist/bundle/{chunk-BO7J5Z3T.js → chunk-FAOLCUKV.js} +17 -17
  43. package/dist/bundle/{chunk-ZK7Y5K63.js → chunk-FDCGTODC.js} +1 -1
  44. package/dist/bundle/{chunk-IQSBMAYB.js → chunk-GOESXUJQ.js} +3 -3
  45. package/dist/bundle/{chunk-AOZGGGUK.js → chunk-HIZQYFY3.js} +3 -3
  46. package/dist/bundle/{chunk-YLATWUE7.js → chunk-IK2OSV5C.js} +6 -6
  47. package/dist/bundle/{chunk-46R2JTGO.js → chunk-IOCS5FXW.js} +2 -2
  48. package/dist/bundle/{chunk-Y3YURIZF.js → chunk-IOUPXUFH.js} +52 -38
  49. package/dist/bundle/{chunk-ZXQCA3ZW.js → chunk-IR73ZZY6.js} +8 -8
  50. package/dist/bundle/{chunk-EF2RCQ3L.js → chunk-JBBZCTTF.js} +1 -1
  51. package/dist/bundle/{chunk-OEEMCNAO.js → chunk-JDJDVYGS.js} +6 -6
  52. package/dist/bundle/{chunk-PATM7JGR.js → chunk-JYVFFUIX.js} +1 -1
  53. package/dist/bundle/{chunk-W5EUHV3J.js → chunk-KM7Q67Z3.js} +1 -1
  54. package/dist/bundle/{chunk-FZMRHNOP.js → chunk-KMQUZ4YM.js} +3 -3
  55. package/dist/bundle/{chunk-VLE3FWE3.js → chunk-LXYC75D3.js} +120 -32
  56. package/dist/bundle/{chunk-V53IB5AU.js → chunk-M2WQWF3I.js} +47 -47
  57. package/dist/bundle/{chunk-X7YPTYM4.js → chunk-M6FCCVYZ.js} +16 -3
  58. package/dist/bundle/{chunk-4TCQT57W.js → chunk-M7YNOK4D.js} +408 -420
  59. package/dist/bundle/chunk-MI3JK6MW.js +335 -0
  60. package/dist/bundle/{chunk-ES6UWVTM.js → chunk-MIUPH3WA.js} +6 -6
  61. package/dist/bundle/{chunk-VJBVNDFR.js → chunk-MLNC5N7H.js} +3 -3
  62. package/dist/bundle/{chunk-UWVNY5CA.js → chunk-N3KQ7XND.js} +2 -2
  63. package/dist/bundle/{chunk-VKUS2V4L.js → chunk-NQCFUYC2.js} +8 -8
  64. package/dist/bundle/{chunk-KYUIU5UR.js → chunk-Q4ZE2LXE.js} +2 -2
  65. package/dist/bundle/{chunk-VVKHF6VJ.js → chunk-QLQ7VVLK.js} +49 -24
  66. package/dist/bundle/{chunk-K6NPOZUP.js → chunk-QUWMFBMS.js} +7 -7
  67. package/dist/bundle/{chunk-WWNZS7ZY.js → chunk-RWG44LQD.js} +16 -4
  68. package/dist/bundle/{chunk-R4SRXI7M.js → chunk-SB47UAW2.js} +187 -113
  69. package/dist/bundle/{chunk-N27LOY3D.js → chunk-SEH7DBAM.js} +7 -7
  70. package/dist/bundle/{chunk-YEZQ7SD7.js → chunk-SPJJCD2A.js} +13 -13
  71. package/dist/bundle/{chunk-CGCJ6P3A.js → chunk-TILW3EJY.js} +696 -418
  72. package/dist/bundle/{chunk-XLJV3ZOH.js → chunk-TQFCPUIM.js} +1 -1
  73. package/dist/bundle/{chunk-ZDRDCANC.js → chunk-TZE6WXID.js} +693 -336
  74. package/dist/bundle/{chunk-XX7KVQIG.js → chunk-UD4FKICZ.js} +4 -4
  75. package/dist/bundle/{chunk-MFS52LTZ.js → chunk-UIPT6IAU.js} +1 -1
  76. package/dist/bundle/{chunk-QKSCDALS.js → chunk-URJZK4GX.js} +1 -1
  77. package/dist/bundle/{decode-CTQJQYNU.js → chunk-VFJ3MOIR.js} +21 -18
  78. package/dist/bundle/{chunk-REC3AZP6.js → chunk-XAXXEZZ5.js} +2 -2
  79. package/dist/bundle/{chunk-Z4D6M62I.js → chunk-YBMOFCY5.js} +2 -2
  80. package/dist/bundle/{chunk-PPHUBORC.js → chunk-YF2PT5KA.js} +32 -34
  81. package/dist/bundle/chunk-YFIUXE25.js +217 -0
  82. package/dist/bundle/{chunk-7IDNHVJS.js → chunk-YI6ZNDPC.js} +22 -12
  83. package/dist/bundle/{chunk-HYZ545ON.js → chunk-YJN4XYNA.js} +2 -2
  84. package/dist/bundle/{cli-CYKEKT5P.js → cli-AHPIESAC.js} +70 -54
  85. package/dist/bundle/command-contract-HVLI3OKU.js +38 -0
  86. package/dist/bundle/config-UW6W34I2.js +78 -0
  87. package/dist/bundle/decode-ZU7WLMMV.js +20 -0
  88. package/dist/bundle/{dist-YLSQKPPY.js → dist-LTS7VI3S.js} +14 -14
  89. package/dist/bundle/{echarts-4OQHS575.js → echarts-YNGCOYHW.js} +2 -2
  90. package/dist/bundle/{embed-P2BKRRJD.js → embed-VWWOW7PP.js} +4 -4
  91. package/dist/bundle/{embedder-HC6ZARP5.js → embedder-T5GJC7M2.js} +7 -7
  92. package/dist/bundle/{first-run-UERFFXBV.js → first-run-PX3SHPUU.js} +8 -8
  93. package/dist/bundle/first-screen-RAPEZG57.js +36 -0
  94. package/dist/bundle/{folders-RSLPTZLJ.js → folders-VXMDFC2D.js} +2 -2
  95. package/dist/bundle/{instructions-3QZBKKPF.js → instructions-GJHHFV64.js} +1 -1
  96. package/dist/bundle/{main-2T6D77JC.js → main-IYCD6MBH.js} +16 -16
  97. package/dist/bundle/{mcp-OQBZXELQ.js → mcp-EMNFFY4N.js} +2 -2
  98. package/dist/bundle/{meetings-ZIDSQZBJ.js → meetings-GHYNIOHG.js} +4 -4
  99. package/dist/bundle/{node-R2BLYUSB.js → node-GFOH6FKP.js} +2 -2
  100. package/dist/bundle/{node-sqlite-7CGHAHIS.js → node-sqlite-QXKSPHTP.js} +3 -3
  101. package/dist/bundle/{oauth-UBCYXTWV.js → oauth-A6I2OMDD.js} +5 -5
  102. package/dist/bundle/{open-AWUB4Q7Z.js → open-TQKCU447.js} +2 -2
  103. package/dist/bundle/openai-XE3BJXOI.js +22 -0
  104. package/dist/bundle/{output-file-SN22HAVL.js → output-file-FQNFCUKE.js} +3 -3
  105. package/dist/bundle/{process-IX5YWGDP.js → process-XVDX4SPD.js} +1 -1
  106. package/dist/bundle/{program-STYPTNT3.js → program-UYK4AD2W.js} +415 -428
  107. package/dist/bundle/{prompt-MAYUHEGN.js → prompt-ISYG5RWM.js} +3 -3
  108. package/dist/bundle/{recognize-FVTNXRTF.js → recognize-KENPECLZ.js} +4 -2
  109. package/dist/bundle/{remote-WCPRU73L.js → remote-ZP5XTDCC.js} +5 -5
  110. package/dist/bundle/{rerank-6CBLZBCV.js → rerank-SG653RHT.js} +5 -5
  111. package/dist/bundle/{run-log-G4WZTOBW.js → run-log-HYKGQ42E.js} +53 -53
  112. package/dist/bundle/{chunk-XNUFDYR6.js → serve-6UJCZD7Z.js} +8 -6
  113. package/dist/bundle/server-AXE37E6Q.js +66 -0
  114. package/dist/bundle/{chunk-INARC5O7.js → server-ZAYEDPFR.js} +43 -10
  115. package/dist/bundle/{services-326Z3TNE.js → services-KMH7XZPY.js} +37 -26
  116. package/dist/bundle/{speech-KSZ7RKM3.js → speech-LINBLG5E.js} +28 -5
  117. package/dist/bundle/{state-EPB3L2JM.js → state-4RKZNHE7.js} +4 -4
  118. package/dist/bundle/{store-7WX7SW2R.js → store-253N7NUC.js} +15 -15
  119. package/dist/bundle/{store-KO242JBK.js → store-JTBHRQZK.js} +13 -13
  120. package/dist/bundle/store-connection-PWLUMCP7.js +76 -0
  121. package/dist/bundle/store-maintenance-command-XRNECVDU.js +55 -0
  122. package/dist/bundle/{streaming-M6VDKBBH.js → streaming-YW64OKKQ.js} +4 -4
  123. package/dist/bundle/{tokens-BTNXHR7T.js → tokens-DPBC2P3I.js} +4 -4
  124. package/dist/bundle/zm.js +1 -1
  125. package/dist/commands.d.ts +1 -2
  126. package/dist/commands.d.ts.map +1 -1
  127. package/dist/commands.js +3 -16
  128. package/dist/commands.js.map +1 -1
  129. package/dist/contract-overrides.d.ts +0 -2
  130. package/dist/contract-overrides.d.ts.map +1 -1
  131. package/dist/contract-overrides.js +0 -158
  132. package/dist/contract-overrides.js.map +1 -1
  133. package/dist/program-bindings.d.ts +1 -1
  134. package/dist/program-bindings.d.ts.map +1 -1
  135. package/dist/program-bindings.js +16 -18
  136. package/dist/program-bindings.js.map +1 -1
  137. package/dist/program.d.ts +2 -4
  138. package/dist/program.d.ts.map +1 -1
  139. package/dist/program.js.map +1 -1
  140. package/dist/read-only.d.ts.map +1 -1
  141. package/dist/read-only.js +3 -0
  142. package/dist/read-only.js.map +1 -1
  143. package/dist/run.d.ts.map +1 -1
  144. package/dist/run.js +82 -32
  145. package/dist/run.js.map +1 -1
  146. package/dist/setup-commands.d.ts.map +1 -1
  147. package/dist/setup-commands.js +8 -46
  148. package/dist/setup-commands.js.map +1 -1
  149. package/dist/store-commands.d.ts.map +1 -1
  150. package/dist/store-commands.js +4 -1
  151. package/dist/store-commands.js.map +1 -1
  152. package/dist/tokens.d.ts +6 -1
  153. package/dist/tokens.d.ts.map +1 -1
  154. package/dist/tokens.js +21 -10
  155. package/dist/tokens.js.map +1 -1
  156. package/dist/version.d.ts +1 -1
  157. package/dist/version.js +1 -1
  158. package/package.json +3 -3
  159. package/dist/bundle/all-profiles-E6KXASLY.js +0 -25
  160. package/dist/bundle/answer-policy-YWCC55NB.js +0 -96
  161. package/dist/bundle/chunk-DBSWVZES.js +0 -48
  162. package/dist/bundle/chunk-WYRYLBST.js +0 -390
  163. package/dist/bundle/chunk-YLBNPI7H.js +0 -2
  164. package/dist/bundle/command-contract-P45QCCXM.js +0 -38
  165. package/dist/bundle/config-JYKTLEA3.js +0 -79
  166. package/dist/bundle/first-screen-VFIS7FX3.js +0 -36
  167. package/dist/bundle/mcp-4VHVUMCR.js +0 -92
  168. package/dist/bundle/mcp-6CLW2IZM.js +0 -189
  169. package/dist/bundle/serve-3IDUVTZL.js +0 -19
  170. package/dist/bundle/server-7GU36TER.js +0 -66
  171. package/dist/bundle/server-VHRS5UAL.js +0 -53
  172. package/dist/bundle/store-connection-K3MNDCQQ.js +0 -76
  173. package/dist/bundle/store-maintenance-command-GJDJYI2U.js +0 -54
  174. package/dist/mcp-command.d.ts +0 -33
  175. package/dist/mcp-command.d.ts.map +0 -1
  176. package/dist/mcp-command.js +0 -143
  177. package/dist/mcp-command.js.map +0 -1
  178. package/dist/mcp.d.ts +0 -30
  179. package/dist/mcp.d.ts.map +0 -1
  180. package/dist/mcp.js +0 -110
  181. package/dist/mcp.js.map +0 -1
  182. /package/dist/bundle/{chunk-O5EHUB2V.js → chunk-NPGVOZVK.js} +0 -0
@@ -0,0 +1,335 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ encodeWav
5
+ } from "./chunk-YFIUXE25.js";
6
+ import {
7
+ SAMPLE_RATE,
8
+ toModelRate
9
+ } from "./chunk-QLQ7VVLK.js";
10
+ import {
11
+ OPENAI_URL
12
+ } from "./chunk-KMQUZ4YM.js";
13
+ import {
14
+ OPENAI_TRANSCRIBE_MODEL,
15
+ VAD,
16
+ filesPresent,
17
+ modelsDirectory,
18
+ vadPath
19
+ } from "./chunk-BPMKLWHV.js";
20
+ import {
21
+ CliError,
22
+ DEFAULT_RETRY,
23
+ backoffMs,
24
+ isCliError
25
+ } from "./chunk-SB47UAW2.js";
26
+ import {
27
+ __name
28
+ } from "./chunk-ZVVMGPBJ.js";
29
+
30
+ // 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
31
+ import { setTimeout as wait } from "node:timers/promises";
32
+
33
+ // 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/body.js
34
+ var interrupted = /* @__PURE__ */ __name((signal) => isCliError(signal.reason) ? signal.reason : new CliError(signal.reason instanceof Error && signal.reason.name === "TimeoutError" ? "timeout" : "cancelled", "HTTP response read was interrupted"), "interrupted");
35
+ var checked = /* @__PURE__ */ __name((signal) => {
36
+ if (signal?.aborted)
37
+ throw interrupted(signal);
38
+ }, "checked");
39
+ var abortable = /* @__PURE__ */ __name(async (pending, signal) => {
40
+ if (!signal)
41
+ return pending;
42
+ let abort = /* @__PURE__ */ __name(() => {
43
+ }, "abort");
44
+ const stopped = new Promise((_, reject) => {
45
+ abort = /* @__PURE__ */ __name(() => reject(interrupted(signal)), "abort");
46
+ signal.addEventListener("abort", abort, { once: true });
47
+ if (signal.aborted)
48
+ abort();
49
+ });
50
+ try {
51
+ return await Promise.race([pending, stopped]);
52
+ } finally {
53
+ signal.removeEventListener("abort", abort);
54
+ }
55
+ }, "abortable");
56
+ var readJsonResponse = /* @__PURE__ */ __name(async (response, options) => {
57
+ const { maxBytes, signal } = options ?? {};
58
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
59
+ throw new CliError("validation_error", "maxBytes must be a positive safe integer");
60
+ if (signal !== void 0 && !(signal instanceof AbortSignal))
61
+ throw new CliError("validation_error", "signal must be an AbortSignal");
62
+ if (signal?.aborted) {
63
+ void response.body?.cancel().catch(() => {
64
+ });
65
+ throw interrupted(signal);
66
+ }
67
+ const length = response.headers.get("content-length");
68
+ if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
69
+ void response.body?.cancel().catch(() => {
70
+ });
71
+ throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
72
+ }
73
+ if (!response.body)
74
+ throw new CliError("invalid_response", "HTTP response has no body");
75
+ if (response.body.locked)
76
+ throw new CliError("invalid_response", "HTTP response body is already in use");
77
+ const reader = response.body.getReader();
78
+ const chunks = [];
79
+ let bytes = 0;
80
+ try {
81
+ for (; ; ) {
82
+ checked(signal);
83
+ const part = await abortable(reader.read(), signal);
84
+ checked(signal);
85
+ if (part.done)
86
+ break;
87
+ if (!(part.value instanceof Uint8Array))
88
+ throw new CliError("invalid_response", "HTTP response is not bytes");
89
+ bytes += part.value.byteLength;
90
+ if (bytes > maxBytes)
91
+ throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
92
+ if (part.value.byteLength)
93
+ chunks.push(new Uint8Array(part.value));
94
+ }
95
+ const body = new Uint8Array(bytes);
96
+ let offset = 0;
97
+ for (const chunk of chunks) {
98
+ body.set(chunk, offset);
99
+ offset += chunk.byteLength;
100
+ }
101
+ try {
102
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
103
+ } catch {
104
+ throw new CliError("invalid_response", "HTTP response is not valid UTF-8 JSON");
105
+ }
106
+ } catch (error) {
107
+ checked(signal);
108
+ if (isCliError(error))
109
+ throw error;
110
+ throw new CliError("network_error", "HTTP response could not be read");
111
+ } finally {
112
+ void reader.cancel().catch(() => {
113
+ });
114
+ reader.releaseLock();
115
+ }
116
+ }, "readJsonResponse");
117
+
118
+ // 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
119
+ var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
120
+ if (!header)
121
+ return void 0;
122
+ const trimmed = header.trim();
123
+ if (/^\d+$/.test(trimmed))
124
+ return Number(trimmed) * 1e3;
125
+ const at = Date.parse(trimmed);
126
+ if (Number.isNaN(at))
127
+ return void 0;
128
+ const delta = at - now().getTime();
129
+ return delta > 0 ? delta : void 0;
130
+ }, "parseRetryAfter");
131
+ var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
132
+ if (!header)
133
+ return void 0;
134
+ const seconds = Number(header.trim());
135
+ if (!Number.isFinite(seconds))
136
+ return void 0;
137
+ const delta = seconds * 1e3 - now().getTime();
138
+ return delta > 0 ? delta : void 0;
139
+ }, "parseRateLimitReset");
140
+ var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
141
+ var retryableStatus = /* @__PURE__ */ __name((status) => status === 408 || status === 429 || status >= 500, "retryableStatus");
142
+ var statusToCode = /* @__PURE__ */ __name((status) => {
143
+ if (status === 400 || status === 422)
144
+ return "validation_error";
145
+ if (status === 401)
146
+ return "authentication_error";
147
+ if (status === 403)
148
+ return "permission_error";
149
+ if (status === 404)
150
+ return "not_found";
151
+ if (status === 408)
152
+ return "timeout";
153
+ if (status === 429)
154
+ return "rate_limited";
155
+ if (status === 502 || status === 503 || status === 504)
156
+ return "provider_unavailable";
157
+ return "provider_error";
158
+ }, "statusToCode");
159
+
160
+ // 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
161
+ var LONGEST_REQUEST_SECONDS = 600;
162
+ var JOINED_SECONDS = 0.2;
163
+ var PAD_SECONDS = 0.2;
164
+ var LEAD = SAMPLE_RATE / 2;
165
+ var EXHAUSTED = /* @__PURE__ */ new Set([
166
+ "insufficient_quota",
167
+ "credit_balance_exhausted",
168
+ "organization_spend_limit_exceeded",
169
+ "project_spend_limit_exceeded",
170
+ "organization_usage_limit_exceeded"
171
+ ]);
172
+ var RETRY = { ...DEFAULT_RETRY, retries: 4 };
173
+ var interrupted2 = /* @__PURE__ */ __name((signal) => {
174
+ if (!signal?.aborted)
175
+ return;
176
+ if (signal.reason instanceof CliError)
177
+ throw signal.reason;
178
+ const timeout = signal.reason instanceof Error && signal.reason.name === "TimeoutError";
179
+ throw new CliError(timeout ? "timeout" : "cancelled", "the transcription was interrupted");
180
+ }, "interrupted");
181
+ var sleeping = /* @__PURE__ */ __name((ms, signal) => wait(ms, void 0, signal ? { signal } : {}).then(() => void 0, (error) => {
182
+ interrupted2(signal);
183
+ throw error;
184
+ }), "sleeping");
185
+ var formOf = /* @__PURE__ */ __name((wav, options) => {
186
+ const form = new FormData();
187
+ form.append("file", new Blob([wav], { type: "audio/wav" }), "audio.wav");
188
+ form.append("model", options.model ?? OPENAI_TRANSCRIBE_MODEL);
189
+ for (const language of options.languages ?? [])
190
+ form.append("languages[]", language);
191
+ for (const keyword of options.keywords ?? [])
192
+ form.append("keywords[]", keyword);
193
+ if (options.prompt)
194
+ form.append("prompt", options.prompt);
195
+ return form;
196
+ }, "formOf");
197
+ var safe = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[\w.-]{1,64}$/.test(value) ? value : void 0, "safe");
198
+ var failureOf = /* @__PURE__ */ __name(async (response) => {
199
+ try {
200
+ const body = await response.json();
201
+ const code = safe(body.error?.code);
202
+ const type = safe(body.error?.type);
203
+ return { ...code ? { code } : {}, ...type ? { type } : {} };
204
+ } catch {
205
+ return {};
206
+ }
207
+ }, "failureOf");
208
+ var send = /* @__PURE__ */ __name(async (wav, options) => {
209
+ const post = options.fetch ?? fetch;
210
+ const retry = options.retry ?? RETRY;
211
+ const sleep = options.sleep ?? sleeping;
212
+ const random = options.random ?? Math.random;
213
+ const url = `${(options.baseUrl ?? OPENAI_URL).replace(/\/+$/, "")}/audio/transcriptions`;
214
+ for (let attempt = 1; ; attempt++) {
215
+ interrupted2(options.signal);
216
+ let response;
217
+ try {
218
+ response = await post(url, {
219
+ method: "POST",
220
+ headers: { authorization: `Bearer ${options.apiKey}` },
221
+ body: formOf(wav, options),
222
+ ...options.signal ? { signal: options.signal } : {}
223
+ });
224
+ } catch {
225
+ interrupted2(options.signal);
226
+ if (attempt > retry.retries)
227
+ throw new CliError("network_error", "OpenAI could not be reached", { reason: "network.failed" });
228
+ await sleep(backoffMs(attempt, retry, random), options.signal);
229
+ continue;
230
+ }
231
+ if (response.ok) {
232
+ const body = await response.json().catch(() => interrupted2(options.signal));
233
+ if (typeof body?.text !== "string")
234
+ throw new CliError("invalid_response", "OpenAI answered without a transcript", {
235
+ reason: "provider.invalid-response"
236
+ });
237
+ return body.text.trim();
238
+ }
239
+ const { code, type } = await failureOf(response);
240
+ const status = response.status;
241
+ const said = `HTTP ${status}${code ? `, ${code}` : type ? `, ${type}` : ""}`;
242
+ if (status === 401)
243
+ throw new CliError("authentication_error", `OpenAI refused the key (${said}) \u2014 set it again with \`models keys set openai\``, { reason: "auth.failed" });
244
+ if (status === 403)
245
+ 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" });
246
+ if (status === 413)
247
+ throw new CliError("validation_error", `OpenAI refused the audio as too large (${said})`, {
248
+ reason: "transcription.too-large"
249
+ });
250
+ if (EXHAUSTED.has(code ?? "") || EXHAUSTED.has(type ?? ""))
251
+ 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" });
252
+ const again = status === 408 || status === 429 || status >= 500;
253
+ const asked = providerWaitMs(response.headers, () => /* @__PURE__ */ new Date());
254
+ if (again && attempt <= retry.retries && (asked === void 0 || asked <= retry.maxRetryAfterMs)) {
255
+ await sleep(asked ?? backoffMs(attempt, retry, random), options.signal);
256
+ continue;
257
+ }
258
+ if (status === 429)
259
+ throw new CliError("rate_limited", `OpenAI answered ${said}`, {
260
+ reason: "provider.rate-limited",
261
+ ...asked === void 0 ? {} : { retry_after_ms: asked }
262
+ });
263
+ if (status >= 500)
264
+ 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" });
265
+ throw new CliError("provider_error", `OpenAI answered ${said}`, { reason: "provider.refused" });
266
+ }
267
+ }, "send");
268
+ var piecesOf = /* @__PURE__ */ __name((spans, limit) => {
269
+ const pieces = [];
270
+ for (const span of spans) {
271
+ const last = pieces.at(-1);
272
+ const joined = last !== void 0 && span.start - last.end < JOINED_SECONDS;
273
+ const fits = last !== void 0 && limit !== void 0 && span.end - last.start <= limit;
274
+ if (last && (fits || joined && span.end - last.start <= LONGEST_REQUEST_SECONDS))
275
+ last.end = span.end;
276
+ else
277
+ pieces.push({ start: span.start, end: span.end });
278
+ }
279
+ return pieces;
280
+ }, "piecesOf");
281
+ var openCutter = /* @__PURE__ */ __name(async (vadModel) => {
282
+ const { openSpeechCutter } = await import("./recognize-KENPECLZ.js");
283
+ return openSpeechCutter(vadModel);
284
+ }, "openCutter");
285
+ var checkKeywords = /* @__PURE__ */ __name((keywords = []) => {
286
+ const bad = keywords.find((keyword) => typeof keyword !== "string" || !keyword.trim() || /[<>\r\n]/.test(keyword));
287
+ if (bad !== void 0)
288
+ throw new CliError("validation_error", "a keyword must be a non-empty single line without < or > \u2014 OpenAI refuses the whole request otherwise");
289
+ }, "checkKeywords");
290
+ var transcribeOpenAI = /* @__PURE__ */ __name(async (audio, options) => {
291
+ if (!options.apiKey)
292
+ throw new CliError("authentication_error", "no OpenAI key \u2014 `models keys set openai`, or OPENAI_API_KEY", {
293
+ reason: "transcription.no-key"
294
+ });
295
+ checkKeywords(options.keywords);
296
+ interrupted2(options.signal);
297
+ const pcm = toModelRate(audio.samples, audio.rate);
298
+ const duration = (pcm.length - LEAD) / SAMPLE_RATE;
299
+ if (options.bundle && duration <= LONGEST_REQUEST_SECONDS) {
300
+ const text = await send(encodeWav(pcm.subarray(LEAD)), options);
301
+ return text ? [{ start: 0, end: duration, text }] : [];
302
+ }
303
+ const vadModel = options.vadModel ?? vadPath(modelsDirectory(options.env));
304
+ if (!options.cutter && !filesPresent([[VAD, vadModel]]))
305
+ 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" });
306
+ const cutter = await (options.cutter ?? openCutter)(vadModel);
307
+ let spans;
308
+ try {
309
+ spans = cutter.cut(pcm);
310
+ } finally {
311
+ cutter.free();
312
+ }
313
+ const pieces = piecesOf(spans, options.bundle ? LONGEST_REQUEST_SECONDS : void 0);
314
+ const heard = [];
315
+ for (const [index, piece] of pieces.entries()) {
316
+ const end = Math.min(piece.end, duration);
317
+ const from = Math.max(piece.start - PAD_SECONDS, pieces[index - 1]?.end ?? 0);
318
+ const to = Math.min(end + PAD_SECONDS, pieces[index + 1]?.start ?? duration);
319
+ const samples = pcm.subarray(LEAD + Math.floor(from * SAMPLE_RATE), LEAD + Math.ceil(to * SAMPLE_RATE));
320
+ const text = await send(encodeWav(samples), options);
321
+ if (text)
322
+ heard.push({ start: Math.min(piece.start, end), end, text });
323
+ }
324
+ return heard;
325
+ }, "transcribeOpenAI");
326
+
327
+ export {
328
+ readJsonResponse,
329
+ providerWaitMs,
330
+ retryableStatus,
331
+ statusToCode,
332
+ LONGEST_REQUEST_SECONDS,
333
+ piecesOf,
334
+ transcribeOpenAI
335
+ };
@@ -3,12 +3,12 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError,
5
5
  singleLine
6
- } from "./chunk-R4SRXI7M.js";
6
+ } from "./chunk-SB47UAW2.js";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-ZVVMGPBJ.js";
10
10
 
11
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/domain/providers.js
11
+ // 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/domain/providers.js
12
12
  var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events"];
13
13
  var PROVIDERS = [
14
14
  { name: "telegram", kind: "messages", aliases: ["tg"] },
@@ -102,7 +102,7 @@ var providerNamed = /* @__PURE__ */ __name((word) => {
102
102
  var kindIn = /* @__PURE__ */ __name((provider) => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind, "kindIn");
103
103
  var kindOf = /* @__PURE__ */ __name((provider) => kindIn(provider) ?? "messages", "kindOf");
104
104
 
105
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/domain/locator.js
105
+ // 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/domain/locator.js
106
106
  var SCHEME = "msg:";
107
107
  var formatLocator = /* @__PURE__ */ __name(({ provider, account, chat, message }) => SCHEME + [provider, account, chat, message].map(encodeURIComponent).join("/"), "formatLocator");
108
108
  var isLocator = /* @__PURE__ */ __name((reference) => reference.trim().startsWith(SCHEME), "isLocator");
@@ -116,7 +116,7 @@ var parseLocator = /* @__PURE__ */ __name((reference) => {
116
116
  return { provider, account, chat, message };
117
117
  }, "parseLocator");
118
118
 
119
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/domain/references.js
119
+ // 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/domain/references.js
120
120
  var SIMPLE_REFERENCES = [
121
121
  "note",
122
122
  "document",
@@ -188,7 +188,7 @@ var folderPath = /* @__PURE__ */ __name((path) => {
188
188
  }, "folderPath");
189
189
  var canonicalReference = /* @__PURE__ */ __name((text) => formatReference(parseReference(text)), "canonicalReference");
190
190
 
191
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/domain/counters.js
191
+ // 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/domain/counters.js
192
192
  var COUNTER_FIELDS = ["views", "reactions", "comments"];
193
193
  var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
194
194
  var counterValue = /* @__PURE__ */ __name((message, field) => {
@@ -225,7 +225,7 @@ var counterFreshness = /* @__PURE__ */ __name((states) => {
225
225
  return states.some((one) => one.freshness === "stale") ? "stale" : "fresh";
226
226
  }, "counterFreshness");
227
227
 
228
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
228
+ // 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/domain/rankings-options.js
229
229
  var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
230
230
  var AUTHOR_MEASURES = [
231
231
  "messages",
@@ -4,15 +4,15 @@ import {
4
4
  MAX_SECRET_INPUT,
5
5
  bufferedInput,
6
6
  inputPolicy
7
- } from "./chunk-AZZPMHP2.js";
7
+ } from "./chunk-6SK5SHCR.js";
8
8
  import {
9
9
  CliError
10
- } from "./chunk-R4SRXI7M.js";
10
+ } from "./chunk-SB47UAW2.js";
11
11
  import {
12
12
  __name
13
13
  } from "./chunk-ZVVMGPBJ.js";
14
14
 
15
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/terminal/prompt.js
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/terminal/prompt.js
16
16
  import { createInterface } from "node:readline";
17
17
  import { Writable } from "node:stream";
18
18
  var readSecret = /* @__PURE__ */ __name(async (prompt, { input = process.stdin, output = process.stderr, echo = false, signal: givenSignal } = {}) => {
@@ -4,7 +4,7 @@ import {
4
4
  ACCESS_SECONDS,
5
5
  REFRESH_SECONDS,
6
6
  readStored
7
- } from "./chunk-XX7KVQIG.js";
7
+ } from "./chunk-UD4FKICZ.js";
8
8
  import {
9
9
  OAuthError,
10
10
  OAuthErrorCode
@@ -13,7 +13,7 @@ import {
13
13
  __name
14
14
  } from "./chunk-ZVVMGPBJ.js";
15
15
 
16
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/mcp/http/oauth.js
16
+ // 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/mcp/http/oauth.js
17
17
  import { createHash, randomBytes, randomInt, timingSafeEqual } from "node:crypto";
18
18
  import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
19
19
  import { dirname } from "node:path";
@@ -2,15 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  isCliFailure
5
- } from "./chunk-IQENQXUJ.js";
5
+ } from "./chunk-7LQLJ7LW.js";
6
6
  import {
7
7
  isContentKey
8
- } from "./chunk-R4SRXI7M.js";
8
+ } from "./chunk-SB47UAW2.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/runs/events.js
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/runs/events.js
14
14
  var providerErrorKey = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(value) ? value : void 0, "providerErrorKey");
15
15
  var renderEvent = /* @__PURE__ */ __name((event) => {
16
16
  if (event.event === "warning") {
@@ -58,14 +58,14 @@ var MARK = { request: "\u2192", response: "\u2190", cache: "\u2022", warning: "!
58
58
  var age = /* @__PURE__ */ __name((ms) => ms < 1e3 ? `${ms}ms` : `${Math.round(ms / 1e3)}s`, "age");
59
59
  var size = /* @__PURE__ */ __name((bytes) => bytes < 1e3 ? `${bytes} B` : `${(bytes / 1e3).toFixed(1)} kB`, "size");
60
60
 
61
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/runs/run-context.js
61
+ // 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/runs/run-context.js
62
62
  import { AsyncLocalStorage } from "node:async_hooks";
63
63
  import { createHash } from "node:crypto";
64
64
 
65
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
65
+ // 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/runs/error-detail.js
66
66
  import { homedir } from "node:os";
67
67
 
68
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/runs/secrets.js
68
+ // 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/runs/secrets.js
69
69
  var SECRET_WORDS = /* @__PURE__ */ new Set([
70
70
  "authorization",
71
71
  "cookie",
@@ -146,7 +146,7 @@ var withoutSecrets = /* @__PURE__ */ __name((text, mark = "[redacted]") => text.
146
146
  var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
147
147
  var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
148
148
 
149
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
149
+ // 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/runs/error-detail.js
150
150
  var MESSAGE_AT_MOST = 500;
151
151
  var CAUSES_AT_MOST = 5;
152
152
  var FRAMES_AT_MOST = 15;
@@ -254,7 +254,7 @@ var redactText = /* @__PURE__ */ __name((text) => {
254
254
  return out.length > MESSAGE_AT_MOST ? `${out.slice(0, MESSAGE_AT_MOST)}\u2026` : out;
255
255
  }, "redactText");
256
256
 
257
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/runs/run-context.js
257
+ // 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/runs/run-context.js
258
258
  var REDACTED = "[redacted]";
259
259
  var keepsSuccess = /* @__PURE__ */ __name(({ record, fromFlag, env, caller, persistent = false }) => {
260
260
  if (!record)
@@ -2,12 +2,12 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError
5
- } from "./chunk-R4SRXI7M.js";
5
+ } from "./chunk-SB47UAW2.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/ports/app.js
10
+ // 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/ports/app.js
11
11
  var envName = /* @__PURE__ */ __name((app, name) => `${app.envPrefix}_${name}`, "envName");
12
12
  var readOnlyLockOf = /* @__PURE__ */ __name((app, env) => {
13
13
  const name = envName(app, "READ_ONLY");
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError
5
- } from "./chunk-R4SRXI7M.js";
5
+ } from "./chunk-SB47UAW2.js";
6
6
  import {
7
7
  importFrom
8
8
  } from "./chunk-Y5E2WNWB.js";
@@ -10,10 +10,10 @@ import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/speech/recognize.js
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/speech/recognize.js
14
14
  import { createRequire } from "node:module";
15
15
 
16
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/speech/ogg-limit.js
16
+ // 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/ogg-limit.js
17
17
  var invalid = /* @__PURE__ */ __name(() => new CliError("validation_error", "local transcription needs a complete mono or stereo Ogg Opus recording"), "invalid");
18
18
  var checkOggDuration = /* @__PURE__ */ __name((bytes) => {
19
19
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
@@ -70,7 +70,7 @@ var checkOggDuration = /* @__PURE__ */ __name((bytes) => {
70
70
  throw invalid();
71
71
  }, "checkOggDuration");
72
72
 
73
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_1193098e908042dfe6f4070222ac0245/node_modules/@wirecat/cli-core/dist/speech/recognize.js
73
+ // 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/recognize.js
74
74
  var SAMPLE_RATE = 16e3;
75
75
  var LEAD = SAMPLE_RATE / 2;
76
76
  var toModelRate = /* @__PURE__ */ __name((samples, rate) => {
@@ -94,10 +94,9 @@ var decodeOgg = /* @__PURE__ */ __name(async (bytes) => {
94
94
  await decoder.ready;
95
95
  try {
96
96
  const { channelData, sampleRate, samplesDecoded } = await decoder.decodeFile(bytes);
97
- const samples = channelData[0];
98
- if (!samples || samplesDecoded === 0)
97
+ if (!channelData[0] || samplesDecoded === 0)
99
98
  throw new Error("no Ogg Opus audio in it");
100
- return { samples, rate: sampleRate };
99
+ return channelData.map((samples) => ({ samples, rate: sampleRate }));
101
100
  } finally {
102
101
  decoder.free();
103
102
  }
@@ -120,6 +119,37 @@ var detector = /* @__PURE__ */ __name((vadModel) => ({
120
119
  debug: 0,
121
120
  bufferSizeInSeconds: 30
122
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");
123
153
  var loaded;
124
154
  var loadSherpa = /* @__PURE__ */ __name(() => {
125
155
  if (loaded)
@@ -156,24 +186,18 @@ var openRecognizer = /* @__PURE__ */ __name((model, path, vadModel) => {
156
186
  stream.free();
157
187
  }
158
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");
159
198
  return {
160
- recognize: /* @__PURE__ */ __name((pcm) => {
161
- vad.reset();
162
- const parts = [];
163
- const drain = /* @__PURE__ */ __name(() => {
164
- while (!vad.isEmpty()) {
165
- parts.push(piece(vad.front().samples));
166
- vad.pop();
167
- }
168
- }, "drain");
169
- for (let i = 0; i + WINDOW <= pcm.length; i += WINDOW) {
170
- vad.acceptWaveform(pcm.subarray(i, i + WINDOW));
171
- drain();
172
- }
173
- vad.flush();
174
- drain();
175
- return parts.filter(Boolean).join(" ");
176
- }, "recognize"),
199
+ recognize: /* @__PURE__ */ __name((pcm) => pieces(pcm).map(({ text }) => text).join(" "), "recognize"),
200
+ pieces,
177
201
  free: /* @__PURE__ */ __name(() => {
178
202
  vad.free();
179
203
  engine.free();
@@ -186,6 +210,7 @@ export {
186
210
  toModelRate,
187
211
  decodeOgg,
188
212
  detector,
213
+ openSpeechCutter,
189
214
  loadSherpa,
190
215
  openRecognizer
191
216
  };