@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
@@ -5,15 +5,15 @@ import {
5
5
  readLock,
6
6
  releaseLock,
7
7
  takeLock
8
- } from "./chunk-IQSBMAYB.js";
8
+ } from "./chunk-GOESXUJQ.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/mcp/http/state.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/mcp/http/state.js
14
14
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
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/activity.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/activity.js
17
17
  import { randomBytes } from "node:crypto";
18
18
  import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
19
19
  import { dirname } from "node:path";
@@ -86,7 +86,7 @@ var activityRecorder = /* @__PURE__ */ __name((path, now = Date.now) => {
86
86
  };
87
87
  }, "activityRecorder");
88
88
 
89
- // 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/state.js
89
+ // 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/state.js
90
90
  var ACCESS_SECONDS = 60 * 60;
91
91
  var REFRESH_SECONDS = 30 * 24 * 60 * 60;
92
92
  var readStored = /* @__PURE__ */ __name((path) => existsSync2(path) ? JSON.parse(readFileSync2(path, "utf8")) : { clients: [], tokens: [] }, "readStored");
@@ -527,7 +527,7 @@ var require_cross_spawn = __commonJS({
527
527
  }
528
528
  });
529
529
 
530
- // node_modules/.pnpm/@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/executable.js
530
+ // 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/executable.js
531
531
  import { existsSync } from "node:fs";
532
532
  import { win32 } from "node:path";
533
533
  var variable = /* @__PURE__ */ __name((env, name) => Object.entries(env).find(([key]) => key.toUpperCase() === name)?.[1], "variable");
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  resolvePaths
5
- } from "./chunk-R4SRXI7M.js";
5
+ } from "./chunk-SB47UAW2.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
@@ -3,10 +3,10 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  SAMPLE_RATE,
5
5
  decodeOgg
6
- } from "./chunk-VVKHF6VJ.js";
6
+ } from "./chunk-QLQ7VVLK.js";
7
7
  import {
8
8
  CliError
9
- } from "./chunk-R4SRXI7M.js";
9
+ } from "./chunk-SB47UAW2.js";
10
10
  import {
11
11
  importFrom
12
12
  } from "./chunk-Y5E2WNWB.js";
@@ -14,7 +14,7 @@ import {
14
14
  __name
15
15
  } from "./chunk-ZVVMGPBJ.js";
16
16
 
17
- // 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/decode.js
17
+ // 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
18
18
  import { spawn } from "node:child_process";
19
19
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
20
20
  import { createRequire } from "node:module";
@@ -41,19 +41,18 @@ var formatOf = /* @__PURE__ */ __name((bytes) => {
41
41
  return "mp3";
42
42
  return "other";
43
43
  }, "formatOf");
44
- var firstChannel = /* @__PURE__ */ __name((decoded) => {
45
- const samples = decoded.channelData[0];
46
- if (!samples || decoded.samplesDecoded === 0)
44
+ var everyChannel = /* @__PURE__ */ __name((decoded) => {
45
+ if (!decoded.channelData[0] || decoded.samplesDecoded === 0)
47
46
  throw new CliError("validation_error", "no audio in that file");
48
- return { samples, rate: decoded.sampleRate };
49
- }, "firstChannel");
47
+ return decoded.channelData.map((samples) => ({ samples, rate: decoded.sampleRate }));
48
+ }, "everyChannel");
50
49
  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");
51
50
  var decodeVorbis = /* @__PURE__ */ __name(async (bytes) => {
52
51
  const { OggVorbisDecoder } = await load("@wasm-audio-decoders/ogg-vorbis");
53
52
  const decoder = new OggVorbisDecoder();
54
53
  await decoder.ready;
55
54
  try {
56
- return firstChannel(await decoder.decodeFile(bytes));
55
+ return everyChannel(await decoder.decodeFile(bytes));
57
56
  } finally {
58
57
  decoder.free();
59
58
  }
@@ -63,7 +62,7 @@ var decodeFlac = /* @__PURE__ */ __name(async (bytes) => {
63
62
  const decoder = new FLACDecoder();
64
63
  await decoder.ready;
65
64
  try {
66
- return firstChannel(await decoder.decodeFile(bytes));
65
+ return everyChannel(await decoder.decodeFile(bytes));
67
66
  } finally {
68
67
  decoder.free();
69
68
  }
@@ -73,7 +72,7 @@ var decodeMp3 = /* @__PURE__ */ __name(async (bytes) => {
73
72
  const decoder = new MPEGDecoder();
74
73
  await decoder.ready;
75
74
  try {
76
- return firstChannel(decoder.decode(bytes));
75
+ return everyChannel(decoder.decode(bytes));
77
76
  } finally {
78
77
  decoder.free();
79
78
  }
@@ -141,18 +140,22 @@ var BUNDLED = {
141
140
  flac: decodeFlac,
142
141
  mp3: decodeMp3
143
142
  };
144
- var decodeAudio = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => {
143
+ var tooLong = /* @__PURE__ */ __name((pcm) => pcm.samples.length / pcm.rate > LONGEST_AUDIO_SECONDS, "tooLong");
144
+ var decodeChannels = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => {
145
145
  const format = formatOf(bytes);
146
- const pcm = format === "other" ? await ffmpeg(bytes) : await BUNDLED[format](bytes).catch((error) => ffmpeg(bytes).catch(() => {
146
+ 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 }), () => {
147
147
  throw error;
148
148
  }));
149
- if (pcm.samples.length / pcm.rate > LONGEST_AUDIO_SECONDS)
149
+ if (decoded.channels.some(tooLong))
150
150
  throw new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`);
151
- return pcm;
152
- }, "decodeAudio");
151
+ return decoded;
152
+ }, "decodeChannels");
153
+ var decodeAudio = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => (await decodeChannels(bytes, ffmpeg)).channels[0], "decodeAudio");
154
+
153
155
  export {
154
156
  LONGEST_AUDIO_SECONDS,
155
- decodeAudio,
156
157
  formatOf,
157
- runFfmpeg
158
+ runFfmpeg,
159
+ decodeChannels,
160
+ decodeAudio
158
161
  };
@@ -10,12 +10,12 @@ import {
10
10
  optional,
11
11
  pipe,
12
12
  safeParse
13
- } from "./chunk-R4SRXI7M.js";
13
+ } from "./chunk-SB47UAW2.js";
14
14
  import {
15
15
  __name
16
16
  } from "./chunk-ZVVMGPBJ.js";
17
17
 
18
- // 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/models/options.js
18
+ // 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/models/options.js
19
19
  var checkedOptions = /* @__PURE__ */ __name((provider, schema, options) => {
20
20
  const parsed = safeParse(schema, options);
21
21
  if (!parsed.success) {
@@ -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/tags.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/tags.js
12
12
  var TAG_TYPES = ["chat", "contact", "message", "task"];
13
13
  var TAG = /^[a-z0-9-]{1,32}$/;
14
14
  var tagOf = /* @__PURE__ */ __name((value) => {
@@ -20,7 +20,7 @@ import {
20
20
  tool,
21
21
  toolKey,
22
22
  toolsFromCommands
23
- } from "./chunk-6BJQBVMN.js";
23
+ } from "./chunk-5MYLM6SU.js";
24
24
  import {
25
25
  CHART_KINDS,
26
26
  CHART_SIZE,
@@ -29,32 +29,30 @@ import {
29
29
  chartRenderer,
30
30
  chatChart,
31
31
  keepRefreshedRefs,
32
+ mcpUrlOf,
32
33
  refuseWriteBeforeConnecting,
33
34
  registerPrompts,
34
35
  stdinFieldOf,
35
36
  syncsFirst
36
- } from "./chunk-VLE3FWE3.js";
37
- import {
38
- mcpUrlOf
39
- } from "./chunk-DBSWVZES.js";
37
+ } from "./chunk-LXYC75D3.js";
40
38
  import {
41
39
  agentJson,
42
40
  skillResource
43
- } from "./chunk-YEZQ7SD7.js";
41
+ } from "./chunk-SPJJCD2A.js";
44
42
  import {
45
43
  instructions
46
- } from "./chunk-XLJV3ZOH.js";
44
+ } from "./chunk-TQFCPUIM.js";
47
45
  import {
48
46
  mcpHttpMarker
49
- } from "./chunk-XX7KVQIG.js";
47
+ } from "./chunk-UD4FKICZ.js";
50
48
  import {
51
49
  answeredWire
52
- } from "./chunk-EF2RCQ3L.js";
50
+ } from "./chunk-JBBZCTTF.js";
53
51
  import {
54
52
  StdioServerTransport,
55
53
  callerOf,
56
54
  serveStdio
57
- } from "./chunk-KNAS4VEA.js";
55
+ } from "./chunk-BNTAQADF.js";
58
56
  import {
59
57
  McpServer,
60
58
  ResourceTemplate
@@ -62,21 +60,21 @@ import {
62
60
  import {
63
61
  connectedFor,
64
62
  guardFor
65
- } from "./chunk-EUHQ5D4K.js";
63
+ } from "./chunk-6URISMGR.js";
66
64
  import {
67
65
  lackedNeed,
68
66
  wholeList
69
- } from "./chunk-WFT2GGFH.js";
67
+ } from "./chunk-ECXRRW7J.js";
70
68
  import {
71
69
  capability,
72
70
  dateWindow,
73
71
  imageSize,
74
72
  servicesFor,
75
73
  storedDeps
76
- } from "./chunk-Z5H47R4G.js";
74
+ } from "./chunk-5NLFQ644.js";
77
75
  import {
78
76
  findCommand
79
- } from "./chunk-OEEMCNAO.js";
77
+ } from "./chunk-JDJDVYGS.js";
80
78
  import {
81
79
  DEFAULT_OUTPUT_BYTES,
82
80
  changesAuthorityAt,
@@ -89,33 +87,33 @@ import {
89
87
  rootOf2 as rootOf,
90
88
  sealed,
91
89
  snakeKeys
92
- } from "./chunk-Y3YURIZF.js";
90
+ } from "./chunk-IOUPXUFH.js";
93
91
  import {
94
92
  readOnlyLockOf
95
- } from "./chunk-KYUIU5UR.js";
93
+ } from "./chunk-Q4ZE2LXE.js";
96
94
  import {
97
95
  withCaller
98
- } from "./chunk-VKUS2V4L.js";
96
+ } from "./chunk-NQCFUYC2.js";
99
97
  import {
100
98
  typedCommand
101
- } from "./chunk-WEUXLXOZ.js";
99
+ } from "./chunk-4OQVRDTG.js";
102
100
  import {
103
101
  isCliFailure
104
- } from "./chunk-IQENQXUJ.js";
102
+ } from "./chunk-7LQLJ7LW.js";
105
103
  import {
106
104
  levelFor,
107
105
  readKeysForCommand
108
- } from "./chunk-AOZGGGUK.js";
106
+ } from "./chunk-HIZQYFY3.js";
109
107
  import {
110
108
  warmEmbedders
111
- } from "./chunk-GEVHI226.js";
109
+ } from "./chunk-EJFSS65P.js";
112
110
  import {
113
111
  openStore,
114
112
  pdfPreviewLimits
115
- } from "./chunk-CGCJ6P3A.js";
113
+ } from "./chunk-TILW3EJY.js";
116
114
  import {
117
115
  timezoneOf
118
- } from "./chunk-LVHZQCP4.js";
116
+ } from "./chunk-D6FTCPXA.js";
119
117
  import {
120
118
  CliError,
121
119
  description,
@@ -133,15 +131,15 @@ import {
133
131
  strictObject,
134
132
  string,
135
133
  visibleControls
136
- } from "./chunk-R4SRXI7M.js";
134
+ } from "./chunk-SB47UAW2.js";
137
135
  import {
138
136
  __name
139
137
  } from "./chunk-ZVVMGPBJ.js";
140
138
 
141
- // 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/server.js
139
+ // 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/server.js
142
140
  import { randomUUID } from "node:crypto";
143
141
 
144
- // 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/agent-log.js
142
+ // 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/agent-log.js
145
143
  var agentLog = /* @__PURE__ */ __name((open) => {
146
144
  let held;
147
145
  return {
@@ -160,7 +158,7 @@ var agentLog = /* @__PURE__ */ __name((open) => {
160
158
  };
161
159
  }, "agentLog");
162
160
 
163
- // 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/resources.js
161
+ // 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/resources.js
164
162
  var LISTED = 100;
165
163
  var registerResources = /* @__PURE__ */ __name((server, session, { command, name, limit, recorded, withStore, messenger, guard, assertRead }) => {
166
164
  server.registerResource("chat", new ResourceTemplate(`${command}://chat/{id}`, {
@@ -198,7 +196,7 @@ var registerResources = /* @__PURE__ */ __name((server, session, { command, name
198
196
  });
199
197
  }, "registerResources");
200
198
 
201
- // 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/session.js
199
+ // 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/session.js
202
200
  var HARMLESS = /* @__PURE__ */ new Set(["validation_error", "not_found", "permission_error", "confirmation_required", "rate_limited"]);
203
201
  var harmless = /* @__PURE__ */ __name((code) => HARMLESS.has(code), "harmless");
204
202
  var MessengerSession = class {
@@ -273,7 +271,7 @@ var MessengerSession = class {
273
271
  }
274
272
  };
275
273
 
276
- // 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/tools/attachments.js
274
+ // 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/tools/attachments.js
277
275
  var attachmentsTools = /* @__PURE__ */ __name((messenger) => {
278
276
  const _command = messenger.app.command;
279
277
  return {
@@ -327,7 +325,7 @@ var attachmentsTools = /* @__PURE__ */ __name((messenger) => {
327
325
  };
328
326
  }, "attachmentsTools");
329
327
 
330
- // 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/tools/messages-photo.js
328
+ // 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/tools/messages-photo.js
331
329
  var PHOTO_LIMIT = 512 * 1024;
332
330
  var IMAGE_TYPES = [
333
331
  ["image/jpeg", (b) => b[0] === 255 && b[1] === 216 && b[2] === 255],
@@ -381,7 +379,7 @@ var readUpTo = /* @__PURE__ */ __name(async (file, limit, saveIt) => {
381
379
  return new Uint8Array(Buffer.concat(chunks));
382
380
  }, "readUpTo");
383
381
 
384
- // 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/tools/stats.js
382
+ // 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/tools/stats.js
385
383
  var statsTools = /* @__PURE__ */ __name((messenger) => ({
386
384
  stats_charts: tool({
387
385
  title: "A chart from a chat's statistics",
@@ -418,14 +416,14 @@ var statsTools = /* @__PURE__ */ __name((messenger) => ({
418
416
  })
419
417
  }), "statsTools");
420
418
 
421
- // 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/tools.js
419
+ // 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/tools.js
422
420
  var pictureTools = /* @__PURE__ */ __name((messenger) => Object.fromEntries(Object.entries({
423
421
  ...messagesPhotoTools(messenger),
424
422
  ...attachmentsTools(messenger),
425
423
  ...statsTools(messenger)
426
424
  }).map(([name, definition]) => [name, { ...definition, input: strictObject(definition.input.entries) }])), "pictureTools");
427
425
 
428
- // 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/server.js
426
+ // 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/server.js
429
427
  var PER_RUN = /* @__PURE__ */ new Set([
430
428
  "streams",
431
429
  "stdin",
@@ -749,7 +747,7 @@ var serveOverStdio = /* @__PURE__ */ __name(async (command, context, messenger,
749
747
  }, "serveOverStdio");
750
748
  var serveOverHttpUntilStopped = /* @__PURE__ */ __name(async (command, context, messenger, options, http) => {
751
749
  const { session, embedders, build, log } = createServer(command, context, messenger, options);
752
- const { serveOverHttp } = await import("./serve-3IDUVTZL.js");
750
+ const { serveOverHttp } = await import("./serve-6UJCZD7Z.js");
753
751
  const appName = messenger.app.command;
754
752
  const appEnvPrefix = messenger.app.envPrefix;
755
753
  const listening = await serveOverHttp(build, {
@@ -0,0 +1,217 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ openOrdinaryFile
5
+ } from "./chunk-CXPHUOJR.js";
6
+ import {
7
+ CliError
8
+ } from "./chunk-SB47UAW2.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/speech/wav.js
14
+ import { createHash } from "node:crypto";
15
+ import { basename, resolve } from "node:path";
16
+ var prepared = /* @__PURE__ */ new WeakMap();
17
+ var checkCancelled = /* @__PURE__ */ __name((signal) => {
18
+ if (!signal?.aborted)
19
+ return;
20
+ if (signal.reason instanceof CliError)
21
+ throw signal.reason;
22
+ const timedOut = signal.reason instanceof Error && signal.reason.name === "TimeoutError";
23
+ throw new CliError(timedOut ? "timeout" : "cancelled", timedOut ? "command timed out" : "command cancelled");
24
+ }, "checkCancelled");
25
+ var invalid = /* @__PURE__ */ __name(() => {
26
+ throw new CliError("validation_error", "local transcription requires PCM16 mono/stereo WAV at 16 or 48 kHz; convert the media locally to PCM WAV first");
27
+ }, "invalid");
28
+ var validate = /* @__PURE__ */ __name((options) => {
29
+ if (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 1 || options.maxBytes > 4 * 1024 ** 3 || !Number.isSafeInteger(options.maxDurationMs) || options.maxDurationMs < 1 || options.maxDurationMs > 24 * 36e5)
30
+ throw new CliError("validation_error", "audio byte and duration budgets must be positive bounded integers");
31
+ checkCancelled(options.signal);
32
+ }, "validate");
33
+ var exact = /* @__PURE__ */ __name(async (file, offset, size, signal) => {
34
+ const bytes = Buffer.alloc(size);
35
+ let read = 0;
36
+ while (read < size) {
37
+ checkCancelled(signal);
38
+ const result = await file.read(bytes, read, size - read, offset + read);
39
+ if (!result.bytesRead)
40
+ throw new CliError("validation_error", "WAV changed or was truncated while reading");
41
+ read += result.bytesRead;
42
+ }
43
+ return bytes;
44
+ }, "exact");
45
+ var layoutOf = /* @__PURE__ */ __name(async (file, size, options) => {
46
+ if (size < 44 || size > options.maxBytes)
47
+ invalid();
48
+ const header = await exact(file, 0, 12, options.signal);
49
+ if (header.toString("ascii", 0, 4) !== "RIFF" || header.toString("ascii", 8, 12) !== "WAVE" || header.readUInt32LE(4) + 8 !== size)
50
+ invalid();
51
+ let format;
52
+ let data;
53
+ let at = 12;
54
+ let chunks = 0;
55
+ while (at < size) {
56
+ checkCancelled(options.signal);
57
+ if (++chunks > 1024 || size - at < 8)
58
+ invalid();
59
+ const chunk = await exact(file, at, 8, options.signal);
60
+ const kind = chunk.toString("ascii", 0, 4);
61
+ const length = chunk.readUInt32LE(4);
62
+ const start = at + 8;
63
+ const next = start + length + length % 2;
64
+ if (next > size)
65
+ invalid();
66
+ if (kind === "fmt ") {
67
+ if (format || ![16, 18].includes(length))
68
+ invalid();
69
+ const bytes = await exact(file, start, length, options.signal);
70
+ const channels = bytes.readUInt16LE(2);
71
+ const sampleRate = bytes.readUInt32LE(4);
72
+ if (bytes.readUInt16LE(0) !== 1 || ![1, 2].includes(channels) || ![16e3, 48e3].includes(sampleRate) || bytes.readUInt16LE(14) !== 16 || bytes.readUInt16LE(12) !== channels * 2 || bytes.readUInt32LE(8) !== sampleRate * channels * 2 || length === 18 && bytes.readUInt16LE(16) !== 0)
73
+ invalid();
74
+ format = { sampleRate, channels };
75
+ } else if (kind === "data") {
76
+ if (data || !length)
77
+ invalid();
78
+ data = { offset: start, size: length };
79
+ }
80
+ at = next;
81
+ }
82
+ if (!format || !data || data.size % (format.channels * 2) !== 0)
83
+ return invalid();
84
+ const frames = data.size / (format.channels * 2);
85
+ if (Math.ceil(frames * 1e3 / format.sampleRate) > options.maxDurationMs)
86
+ throw new CliError("validation_error", "WAV exceeds the configured duration limit");
87
+ return { ...format, dataOffset: data.offset, dataSize: data.size, frames };
88
+ }, "layoutOf");
89
+ var hashRange = /* @__PURE__ */ __name(async (file, hash, start, end, signal) => {
90
+ let at = start;
91
+ while (at < end) {
92
+ const bytes = await exact(file, at, Math.min(65536, end - at), signal);
93
+ hash.update(bytes);
94
+ at += bytes.length;
95
+ }
96
+ }, "hashRange");
97
+ var hashFile = /* @__PURE__ */ __name(async (file, size, signal) => {
98
+ const hash = createHash("sha256");
99
+ await hashRange(file, hash, 0, size, signal);
100
+ if ((await file.stat()).size !== size)
101
+ throw new CliError("validation_error", "WAV changed while verifying its content");
102
+ return hash.digest("hex");
103
+ }, "hashFile");
104
+ var preflightWavAudio = /* @__PURE__ */ __name(async (path, input) => {
105
+ const options = { ...input };
106
+ validate(options);
107
+ if (typeof path !== "string" || !path.trim() || /\0/.test(path))
108
+ throw new CliError("validation_error", "local audio file is required");
109
+ const absolute = resolve(path);
110
+ const file = await openOrdinaryFile(absolute);
111
+ try {
112
+ const stat = await file.stat({ bigint: true });
113
+ const size = Number(stat.size);
114
+ const layout = await layoutOf(file, size, options);
115
+ const contentHash = await hashFile(file, size, options.signal);
116
+ const after = await file.stat({ bigint: true });
117
+ if (stat.size !== after.size || stat.mtimeNs !== after.mtimeNs)
118
+ throw new CliError("validation_error", "WAV changed while preparing the transcription");
119
+ const media = Object.freeze({
120
+ id: createHash("sha256").update(basename(absolute)).digest("hex"),
121
+ contentHash,
122
+ size,
123
+ durationMs: Math.ceil(layout.frames * 1e3 / layout.sampleRate),
124
+ format: "wav",
125
+ sampleRate: layout.sampleRate,
126
+ channels: layout.channels
127
+ });
128
+ const plan = Object.freeze({ media });
129
+ prepared.set(plan, { path: absolute, dev: stat.dev, ino: stat.ino, layout });
130
+ return plan;
131
+ } finally {
132
+ await file.close();
133
+ }
134
+ }, "preflightWavAudio");
135
+ var openWavAudio = /* @__PURE__ */ __name(async (plan, input) => {
136
+ const options = { ...input };
137
+ validate(options);
138
+ const known = prepared.get(plan);
139
+ if (!known)
140
+ throw new CliError("validation_error", "audio plan was not prepared by this adapter");
141
+ const file = await openOrdinaryFile(known.path);
142
+ try {
143
+ const stat = await file.stat({ bigint: true });
144
+ if (stat.dev !== known.dev || stat.ino !== known.ino || Number(stat.size) !== plan.media.size)
145
+ throw new CliError("validation_error", "WAV identity changed before transcription");
146
+ const layout = await layoutOf(file, plan.media.size, options);
147
+ if (JSON.stringify(layout) !== JSON.stringify(known.layout) || await hashFile(file, plan.media.size, options.signal) !== plan.media.contentHash)
148
+ throw new CliError("validation_error", "WAV content changed before transcription");
149
+ let closed = false;
150
+ let consumed = false;
151
+ return {
152
+ async *windows() {
153
+ if (closed || consumed)
154
+ throw new CliError("configuration_error", "audio source can be consumed once before closing");
155
+ consumed = true;
156
+ const hash = createHash("sha256");
157
+ await hashRange(file, hash, 0, layout.dataOffset, options.signal);
158
+ const step = layout.sampleRate / 16e3;
159
+ for (let frame = 0; frame < layout.frames; ) {
160
+ checkCancelled(options.signal);
161
+ const count = Math.min(layout.sampleRate * 30, layout.frames - frame);
162
+ const bytes = await exact(file, layout.dataOffset + frame * layout.channels * 2, count * layout.channels * 2, options.signal);
163
+ hash.update(bytes);
164
+ const samples = new Float32Array(Math.floor(count / step));
165
+ for (let index = 0; index < samples.length; index++) {
166
+ let sum = 0;
167
+ for (let offset = 0; offset < step; offset++)
168
+ for (let channel = 0; channel < layout.channels; channel++)
169
+ sum += bytes.readInt16LE(((index * step + offset) * layout.channels + channel) * 2);
170
+ samples[index] = sum / (32768 * step * layout.channels);
171
+ }
172
+ const startMs = Math.floor(frame * 1e3 / layout.sampleRate);
173
+ frame += count;
174
+ if (samples.length)
175
+ yield { startMs, endMs: Math.ceil(frame * 1e3 / layout.sampleRate), samples };
176
+ }
177
+ await hashRange(file, hash, layout.dataOffset + layout.dataSize, plan.media.size, options.signal);
178
+ if (hash.digest("hex") !== plan.media.contentHash || (await file.stat()).size !== plan.media.size)
179
+ throw new CliError("validation_error", "WAV changed during recognition; no transcript may be stored");
180
+ },
181
+ async close() {
182
+ if (!closed) {
183
+ closed = true;
184
+ await file.close();
185
+ }
186
+ }
187
+ };
188
+ } catch (error) {
189
+ await file.close();
190
+ throw error;
191
+ }
192
+ }, "openWavAudio");
193
+ var encodeWav = /* @__PURE__ */ __name((samples, sampleRate = 16e3) => {
194
+ const bytes = Buffer.alloc(44 + samples.length * 2);
195
+ bytes.write("RIFF", 0, "ascii");
196
+ bytes.writeUInt32LE(bytes.length - 8, 4);
197
+ bytes.write("WAVEfmt ", 8, "ascii");
198
+ bytes.writeUInt32LE(16, 16);
199
+ bytes.writeUInt16LE(1, 20);
200
+ bytes.writeUInt16LE(1, 22);
201
+ bytes.writeUInt32LE(sampleRate, 24);
202
+ bytes.writeUInt32LE(sampleRate * 2, 28);
203
+ bytes.writeUInt16LE(2, 32);
204
+ bytes.writeUInt16LE(16, 34);
205
+ bytes.write("data", 36, "ascii");
206
+ bytes.writeUInt32LE(samples.length * 2, 40);
207
+ samples.forEach((sample, index) => {
208
+ bytes.writeInt16LE(Math.round(Math.max(-1, Math.min(1, sample || 0)) * 32767), 44 + index * 2);
209
+ });
210
+ return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.length);
211
+ }, "encodeWav");
212
+
213
+ export {
214
+ preflightWavAudio,
215
+ openWavAudio,
216
+ encodeWav
217
+ };