@wirecat/drive-cli 0.69.0 → 0.71.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 (228) hide show
  1. package/README.md +3 -2
  2. package/contracts/wirecat.json +14 -13
  3. package/dist/age.d.ts +0 -36
  4. package/dist/age.d.ts.map +1 -1
  5. package/dist/age.js +0 -22
  6. package/dist/age.js.map +1 -1
  7. package/dist/bin/drive.js +2 -2
  8. package/dist/bundle/{all-profiles-B4A737YW.js → all-profiles-3QJG2NAN.js} +13 -13
  9. package/dist/bundle/{anthropic-RZGPDESM.js → anthropic-PSWTEU6G.js} +8 -8
  10. package/dist/bundle/{app-server-OWEW7DY5.js → app-server-PVTA6ABR.js} +66 -58
  11. package/dist/bundle/{bun-V5QLYBZU.js → bun-LU5LP3JI.js} +2 -2
  12. package/dist/bundle/{bun-sqlite-KHLHXXGH.js → bun-sqlite-PYMKLBRU.js} +9 -9
  13. package/dist/bundle/{chunk-CAQ5GW3A.js → chunk-22QQUKWA.js} +1 -1
  14. package/dist/bundle/{chunk-3YKAFLXY.js → chunk-26DHFMGZ.js} +2 -2
  15. package/dist/bundle/{chunk-Y2QVNVHK.js → chunk-2BVVU7GG.js} +1 -1
  16. package/dist/bundle/{chunk-7JKECODO.js → chunk-2LHAVY4U.js} +1 -11
  17. package/dist/bundle/{chunk-HEBZCKMU.js → chunk-2PUNKUYJ.js} +4389 -4709
  18. package/dist/bundle/chunk-2UUWXPOB.js +31 -0
  19. package/dist/bundle/{chunk-KUQDBWPU.js → chunk-35SCQ4VI.js} +31 -32
  20. package/dist/bundle/{chunk-O6PD7RZY.js → chunk-3EBBLKIT.js} +4 -4
  21. package/dist/bundle/{chunk-PV3AWPHR.js → chunk-3N2OFXB5.js} +5 -5
  22. package/dist/bundle/{chunk-SY2HLH5R.js → chunk-3UGYFXH6.js} +82 -25
  23. package/dist/bundle/{chunk-OUM4ZO53.js → chunk-4HWJOU7N.js} +1 -1
  24. package/dist/bundle/{chunk-6D44YQ5X.js → chunk-4PA4DHYV.js} +6 -6
  25. package/dist/bundle/{chunk-EA2OB75T.js → chunk-4QNW4NK6.js} +1 -1
  26. package/dist/bundle/{chunk-GK6KXBL6.js → chunk-6SJOTNHF.js} +4 -4
  27. package/dist/bundle/{chunk-NVDR72GP.js → chunk-6TNNT2MQ.js} +250 -174
  28. package/dist/bundle/{chunk-4YECZ6CN.js → chunk-6W763DZN.js} +12 -12
  29. package/dist/bundle/{chunk-IQ2QU2X6.js → chunk-6XFIITOG.js} +1024 -598
  30. package/dist/bundle/{chunk-AD7VI3XU.js → chunk-72C4YOCH.js} +7 -7
  31. package/dist/bundle/{chunk-6EL5AVXX.js → chunk-7PDHGZN4.js} +4 -4
  32. package/dist/bundle/{chunk-22SH77TG.js → chunk-ACUAV6VX.js} +64 -64
  33. package/dist/bundle/{chunk-BBJVV4E2.js → chunk-ASMMG72J.js} +68 -38
  34. package/dist/bundle/{chunk-XUHQ7DVT.js → chunk-B5KSXHJ7.js} +1 -1
  35. package/dist/bundle/{chunk-BVVXYZSU.js → chunk-BKSQBBYG.js} +9 -9
  36. package/dist/bundle/{chunk-5SJZDEIO.js → chunk-CJLVYIOP.js} +21 -21
  37. package/dist/bundle/chunk-COJSWDNU.js +170 -0
  38. package/dist/bundle/{chunk-GTDCP5OG.js → chunk-COOOO5B3.js} +4 -4
  39. package/dist/bundle/{chunk-LUZRVBQR.js → chunk-D5TGYUVU.js} +6 -6
  40. package/dist/bundle/{chunk-CZ4UEXCE.js → chunk-EOEU3AZN.js} +6 -6
  41. package/dist/bundle/{chunk-CU6RATZH.js → chunk-FCS26CYQ.js} +4 -4
  42. package/dist/bundle/{chunk-LRCSDAYK.js → chunk-FJH7DJWK.js} +4 -4
  43. package/dist/bundle/{chunk-U3RXH6RY.js → chunk-FP54WSIR.js} +4 -4
  44. package/dist/bundle/{chunk-3URYKAJP.js → chunk-FT3LN3HP.js} +1 -1
  45. package/dist/bundle/{chunk-CDSB7WVG.js → chunk-GBKNJWOZ.js} +8 -8
  46. package/dist/bundle/{chunk-4J5GJJ2I.js → chunk-GOWXXYEF.js} +2 -2
  47. package/dist/bundle/{chunk-PB6NWKH3.js → chunk-GPQ44Y2R.js} +2 -2
  48. package/dist/bundle/{chunk-E7URRFBB.js → chunk-GZ2D4KXG.js} +10 -15
  49. package/dist/bundle/{chunk-376ZGVUZ.js → chunk-HKY7X6NY.js} +4 -4
  50. package/dist/bundle/{chunk-6XNTELM5.js → chunk-HL52XXZX.js} +1 -1
  51. package/dist/bundle/{chunk-533XOW74.js → chunk-HMS6EEQL.js} +3 -3
  52. package/dist/bundle/{chunk-F5UUJU6R.js → chunk-I4RWW3UD.js} +49 -4
  53. package/dist/bundle/{chunk-TZ75K6R7.js → chunk-ICDCAQ6K.js} +8 -8
  54. package/dist/bundle/{chunk-WOUIHZRI.js → chunk-J5Q5FS2N.js} +18 -75
  55. package/dist/bundle/{chunk-EL2E3ABX.js → chunk-JDV7HNNQ.js} +13 -13
  56. package/dist/bundle/{chunk-ZUG67442.js → chunk-JZHBZOJR.js} +3 -3
  57. package/dist/bundle/{chunk-SEJBS7SI.js → chunk-KGERXYTV.js} +1 -1
  58. package/dist/bundle/{chunk-5TK2YQCO.js → chunk-KGYVHPGE.js} +2 -2
  59. package/dist/bundle/{chunk-HCZYJMBP.js → chunk-KYKW2W6X.js} +1 -1
  60. package/dist/bundle/{chunk-RLGQMMYE.js → chunk-L46C6HQ7.js} +35 -13
  61. package/dist/bundle/chunk-LXKYKRHD.js +387 -0
  62. package/dist/bundle/{chunk-N4ACIIQB.js → chunk-MIA7P6FZ.js} +2 -2
  63. package/dist/bundle/{chunk-ZBYKCVSV.js → chunk-MNLL5YLM.js} +2 -2
  64. package/dist/bundle/{chunk-UPCEHSIZ.js → chunk-OF422U5D.js} +21 -16
  65. package/dist/bundle/{chunk-JRFKCYMW.js → chunk-OJSBWP3F.js} +23 -6
  66. package/dist/bundle/{chunk-MHXZ62CU.js → chunk-P7CUM5IB.js} +1 -1
  67. package/dist/bundle/{chunk-I55XYREN.js → chunk-PRW6SYA3.js} +1094 -2526
  68. package/dist/bundle/chunk-Q7DOMFJ4.js +259 -0
  69. package/dist/bundle/{chunk-3RLRJHAI.js → chunk-QETR5HIZ.js} +12081 -12607
  70. package/dist/bundle/{chunk-QJGFQRTL.js → chunk-QFR2PNJN.js} +12 -12
  71. package/dist/bundle/{chunk-2Q4CB4EI.js → chunk-QNRRK3CN.js} +2 -2
  72. package/dist/bundle/{chunk-5B5NOAIA.js → chunk-QXC6IEH6.js} +45 -45
  73. package/dist/bundle/{chunk-T6X6EZ5N.js → chunk-RESDD3Q4.js} +3 -3
  74. package/dist/bundle/chunk-RJOQH5YY.js +1979 -0
  75. package/dist/bundle/{chunk-AMQGKMLZ.js → chunk-RWDKMU74.js} +3 -3
  76. package/dist/bundle/{chunk-VUPWDCYV.js → chunk-SAKO3P4H.js} +1 -1
  77. package/dist/bundle/{chunk-GHFBT2ZM.js → chunk-SDKQNOL5.js} +6 -6
  78. package/dist/bundle/{chunk-25FT44S3.js → chunk-SERXSCN3.js} +287 -569
  79. package/dist/bundle/{chunk-2DS2TDGW.js → chunk-TAFHYHKA.js} +20 -118
  80. package/dist/bundle/{chunk-XVH3WZSZ.js → chunk-TAUBRNC5.js} +53 -53
  81. package/dist/bundle/{chunk-2VFAXC6O.js → chunk-UDMNY63V.js} +22 -19
  82. package/dist/bundle/{chunk-EWUQIUTB.js → chunk-UTO2GO4P.js} +5 -5
  83. package/dist/bundle/{chunk-V4FMN5A6.js → chunk-WVDCCYS3.js} +17 -17
  84. package/dist/bundle/chunk-X4TIMMKJ.js +16 -0
  85. package/dist/bundle/chunk-XF4EXO2C.js +335 -0
  86. package/dist/bundle/{chunk-OOIAJRKQ.js → chunk-XMMFBPGC.js} +2 -2
  87. package/dist/bundle/{chunk-4ZFO2CVH.js → chunk-Y2NWGNUB.js} +5 -5
  88. package/dist/bundle/{chunk-IJCUAKR5.js → chunk-YJIGGUPI.js} +4 -4
  89. package/dist/bundle/{chunk-L342KHIZ.js → chunk-YMJ6IDGT.js} +6 -6
  90. package/dist/bundle/{chunk-WNMPIRRF.js → chunk-YPFWNVHV.js} +3 -3
  91. package/dist/bundle/{chunk-T4FMXDDV.js → chunk-YPNWIB6H.js} +3 -3
  92. package/dist/bundle/{chunk-FIVFP53N.js → chunk-YVI5SQPY.js} +1 -1
  93. package/dist/bundle/{chunk-RWQ7T4Y5.js → chunk-Z3KUSRCF.js} +2 -2
  94. package/dist/bundle/{chunk-WQOGHND4.js → chunk-Z56QFOBR.js} +1 -1
  95. package/dist/bundle/chunk-ZCR3IRZ2.js +823 -0
  96. package/dist/bundle/{chunk-SYUXKV2E.js → chunk-ZM63SUHG.js} +2 -2
  97. package/dist/bundle/{chunk-M4OP5ASJ.js → chunk-ZZ32DXTH.js} +1 -1
  98. package/dist/bundle/{cli-BS4L3HAP.js → cli-556DERZL.js} +88 -69
  99. package/dist/bundle/command-contract-VRTOAV6W.js +43 -0
  100. package/dist/bundle/{command-server-entry-CJ2CV7ZV.js → command-server-entry-AYLGNZWD.js} +33 -30
  101. package/dist/bundle/decode-QU24MWMN.js +299 -0
  102. package/dist/bundle/{dispatch-WBEOHZDV.js → dispatch-4KODNOXV.js} +9 -9
  103. package/dist/bundle/drive.js +11 -11
  104. package/dist/bundle/{echarts-QIXLXS3G.js → echarts-BXX4OQWC.js} +2 -2
  105. package/dist/bundle/{embed-YNZW5X6M.js → embed-KG27KG3D.js} +9 -9
  106. package/dist/bundle/{embedder-LRC2PKTS.js → embedder-IPAVUQUV.js} +12 -12
  107. package/dist/bundle/entry-MVXQETWS.js +25 -0
  108. package/dist/bundle/{failure-X6PSLVSO.js → failure-ESL7ETL4.js} +4 -4
  109. package/dist/bundle/first-run-4UVLW2WR.js +31 -0
  110. package/dist/bundle/first-screen-JAKAIINI.js +41 -0
  111. package/dist/bundle/google-22NXXJX5.js +45 -0
  112. package/dist/bundle/{google-api-7JDZDCWE.js → google-api-VCDBSNOW.js} +70 -62
  113. package/dist/bundle/grants-MQMTVCRQ.js +118 -0
  114. package/dist/bundle/{identity-E43WKN5F.js → identity-LOWMVGZY.js} +6 -6
  115. package/dist/bundle/{instructions-MD2RZT5Z.js → instructions-2VECIDXF.js} +1 -1
  116. package/dist/bundle/{login-RBDJPQAG.js → login-7GBONT7V.js} +78 -70
  117. package/dist/bundle/{mcp-TDKGDB4V.js → mcp-O6ACR2DX.js} +2 -2
  118. package/dist/bundle/meeting-combined-LVP4AZKA.js +27 -0
  119. package/dist/bundle/meeting-model-RAY5XDXZ.js +29 -0
  120. package/dist/bundle/meeting-semantic-G7PFOKU7.js +25 -0
  121. package/dist/bundle/{node-IEVT2FSJ.js → node-MPEQSFI3.js} +2 -2
  122. package/dist/bundle/{node-sqlite-IENH4TRX.js → node-sqlite-OLQMAYB4.js} +10 -10
  123. package/dist/bundle/oauth-SGH2I2BY.js +22 -0
  124. package/dist/bundle/{open-TZ5H7NYM.js → open-OXTE672W.js} +8 -8
  125. package/dist/bundle/{openai-XF2KB7W2.js → openai-EB3TPIZY.js} +32 -30
  126. package/dist/bundle/{process-6Q23D3TO.js → process-F6TKXWWA.js} +1 -1
  127. package/dist/bundle/{program-D5XWOHV5.js → program-4IFDZ7FM.js} +1356 -1338
  128. package/dist/bundle/{prompt-KUC5D4GX.js → prompt-F5RRHPN2.js} +8 -8
  129. package/dist/bundle/{reasons-KSYP5VDJ.js → reasons-UORHJDHK.js} +5 -5
  130. package/dist/bundle/{recognize-DPFW7HO3.js → recognize-DAVNZND3.js} +7 -7
  131. package/dist/bundle/{remote-MODTSUNH.js → remote-D5EYYIAU.js} +13 -13
  132. package/dist/bundle/{rerank-JK7SERLE.js → rerank-CND2GVLZ.js} +10 -10
  133. package/dist/bundle/{serve-BV2WHZLW.js → serve-ZHSPUIGX.js} +12 -12
  134. package/dist/bundle/server-DUVJWP3Q.js +80 -0
  135. package/dist/bundle/{server-N3WPEU7Z.js → server-YMAK4LHC.js} +54 -46
  136. package/dist/bundle/{services-SV6CFUCS.js → services-ZILSFJ6E.js} +79 -54
  137. package/dist/bundle/{sqlite-runtime-RZ5PLZVQ.js → sqlite-runtime-S5VPMZQH.js} +9 -9
  138. package/dist/bundle/{start-C6EXYXAL.js → start-CR6X25RT.js} +7 -7
  139. package/dist/bundle/{state-RAZIREVG.js → state-YFPHVIIJ.js} +9 -9
  140. package/dist/bundle/{store-DQKJKX2G.js → store-CL4ZJZRI.js} +23 -19
  141. package/dist/bundle/{store-2DLGLYS6.js → store-UODRT6X4.js} +31 -26
  142. package/dist/bundle/store-maintenance-command-DY5XIBWR.js +72 -0
  143. package/dist/bundle/tokens-AF7QOFOF.js +118 -0
  144. package/dist/catalog.d.ts +0 -28
  145. package/dist/catalog.d.ts.map +1 -1
  146. package/dist/catalog.js +0 -82
  147. package/dist/catalog.js.map +1 -1
  148. package/dist/commands/catalog.d.ts +3 -8
  149. package/dist/commands/catalog.d.ts.map +1 -1
  150. package/dist/commands/catalog.js +36 -109
  151. package/dist/commands/catalog.js.map +1 -1
  152. package/dist/commands/context.d.ts +3 -0
  153. package/dist/commands/context.d.ts.map +1 -1
  154. package/dist/commands/context.js +20 -0
  155. package/dist/commands/context.js.map +1 -1
  156. package/dist/commands/documents.d.ts.map +1 -1
  157. package/dist/commands/documents.js +30 -72
  158. package/dist/commands/documents.js.map +1 -1
  159. package/dist/commands/folders.d.ts +1 -1
  160. package/dist/commands/folders.d.ts.map +1 -1
  161. package/dist/commands/folders.js +45 -48
  162. package/dist/commands/folders.js.map +1 -1
  163. package/dist/commands/knowledge.d.ts +4 -21
  164. package/dist/commands/knowledge.d.ts.map +1 -1
  165. package/dist/commands/knowledge.js +3 -241
  166. package/dist/commands/knowledge.js.map +1 -1
  167. package/dist/commands/mirrors.d.ts +2 -2
  168. package/dist/commands/mirrors.d.ts.map +1 -1
  169. package/dist/commands/mirrors.js +46 -202
  170. package/dist/commands/mirrors.js.map +1 -1
  171. package/dist/commands/search.d.ts +1 -3
  172. package/dist/commands/search.d.ts.map +1 -1
  173. package/dist/commands/search.js +20 -42
  174. package/dist/commands/search.js.map +1 -1
  175. package/dist/commands/sync.d.ts.map +1 -1
  176. package/dist/commands/sync.js +36 -53
  177. package/dist/commands/sync.js.map +1 -1
  178. package/dist/config.d.ts.map +1 -1
  179. package/dist/config.js +2 -1
  180. package/dist/config.js.map +1 -1
  181. package/dist/contract-overrides.d.ts +0 -2
  182. package/dist/contract-overrides.d.ts.map +1 -1
  183. package/dist/contract-overrides.js +0 -317
  184. package/dist/contract-overrides.js.map +1 -1
  185. package/dist/knowledge.d.ts +1 -1
  186. package/dist/knowledge.d.ts.map +1 -1
  187. package/dist/knowledge.js +4 -3
  188. package/dist/knowledge.js.map +1 -1
  189. package/dist/list-queries.d.ts +0 -31
  190. package/dist/list-queries.d.ts.map +1 -1
  191. package/dist/list-queries.js +0 -36
  192. package/dist/list-queries.js.map +1 -1
  193. package/dist/program.d.ts.map +1 -1
  194. package/dist/program.js +2 -3
  195. package/dist/program.js.map +1 -1
  196. package/dist/provider-json.d.ts.map +1 -1
  197. package/dist/provider-json.js +5 -5
  198. package/dist/provider-json.js.map +1 -1
  199. package/dist/reasons.d.ts.map +1 -1
  200. package/dist/reasons.js +0 -10
  201. package/dist/reasons.js.map +1 -1
  202. package/dist/sync.d.ts.map +1 -1
  203. package/dist/sync.js +1 -2
  204. package/dist/sync.js.map +1 -1
  205. package/dist/transcripts.d.ts +0 -6
  206. package/dist/transcripts.d.ts.map +1 -1
  207. package/dist/transcripts.js +0 -13
  208. package/dist/transcripts.js.map +1 -1
  209. package/dist/version.d.ts +1 -1
  210. package/dist/version.js +1 -1
  211. package/package.json +3 -3
  212. package/dist/bundle/command-contract-HYURWSD6.js +0 -40
  213. package/dist/bundle/decode-E2NM5SSM.js +0 -165
  214. package/dist/bundle/entry-2IMSWRJU.js +0 -25
  215. package/dist/bundle/first-run-7CPHQDM5.js +0 -30
  216. package/dist/bundle/first-screen-OKZ7GMFR.js +0 -38
  217. package/dist/bundle/google-WDKDBDD4.js +0 -45
  218. package/dist/bundle/grants-AU25GWKF.js +0 -110
  219. package/dist/bundle/oauth-3JGSN47Z.js +0 -22
  220. package/dist/bundle/server-6YDI4Y36.js +0 -72
  221. package/dist/bundle/store-maintenance-command-UJ5F5L4H.js +0 -64
  222. package/dist/bundle/tokens-LY3WML55.js +0 -110
  223. package/dist/knowledge-query.d.ts +0 -77
  224. package/dist/knowledge-query.d.ts.map +0 -1
  225. package/dist/knowledge-query.js +0 -104
  226. package/dist/knowledge-query.js.map +0 -1
  227. package/dist/bundle/{chunk-XWBPP2HX.js → chunk-VKE77B3F.js} +0 -0
  228. package/dist/bundle/{mdast-util-from-markdown-CE73EWJ2.js → mdast-util-from-markdown-FXEPSNER.js} +3 -3
@@ -0,0 +1,259 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ OPENAI_URL,
5
+ openRemote,
6
+ remoteKey,
7
+ remoteModel
8
+ } from "./chunk-Y2NWGNUB.js";
9
+ import {
10
+ isTextModelInstalled,
11
+ openEmbedder,
12
+ textModelsDirectory
13
+ } from "./chunk-UTO2GO4P.js";
14
+ import {
15
+ textModel,
16
+ vectorModelKey
17
+ } from "./chunk-XF4EXO2C.js";
18
+ import {
19
+ endpointFetch
20
+ } from "./chunk-YMJ6IDGT.js";
21
+ import {
22
+ CliError
23
+ } from "./chunk-4QNW4NK6.js";
24
+ import {
25
+ __name
26
+ } from "./chunk-ZVVMGPBJ.js";
27
+
28
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
29
+ var integer = /* @__PURE__ */ __name((value, name, max) => {
30
+ if (!Number.isSafeInteger(value) || value < 1 || value > max)
31
+ throw new CliError("validation_error", `Invalid ${name}`);
32
+ return value;
33
+ }, "integer");
34
+ var cancelled = /* @__PURE__ */ __name((signal) => {
35
+ if (signal?.aborted)
36
+ throw new CliError("cancelled", "Meeting embedding was cancelled");
37
+ }, "cancelled");
38
+ var validatedRemote = /* @__PURE__ */ __name((remote) => {
39
+ let url;
40
+ try {
41
+ url = new URL(remote.baseUrl);
42
+ } catch {
43
+ throw new CliError("validation_error", "Invalid embedding endpoint");
44
+ }
45
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash)
46
+ throw new CliError("validation_error", "Embedding endpoint requires HTTP/S without credentials, query or fragment");
47
+ if (typeof remote.model !== "string" || !/^[\w./:-]{1,200}$/.test(remote.model))
48
+ throw new CliError("validation_error", "Invalid embedding model name");
49
+ const dims = integer(remote.dims, "embedding dimensions", 8192);
50
+ const baseUrl = remote.baseUrl.replace(/\/+$/, "");
51
+ const result = remoteModel({ model: remote.model, dims, ...baseUrl === OPENAI_URL ? {} : { baseUrl } });
52
+ return result;
53
+ }, "validatedRemote");
54
+ var meetingEmbeddingModel = /* @__PURE__ */ __name((choice, env) => {
55
+ if (typeof choice === "string") {
56
+ const model = textModel(choice, env);
57
+ return { key: vectorModelKey(model), dims: model.dims, kind: "local", model: model.id };
58
+ }
59
+ if (!choice || typeof choice !== "object" || !choice.remote)
60
+ throw new CliError("validation_error", "An explicit embedding model is required");
61
+ const remote = validatedRemote(choice.remote);
62
+ if (choice.concurrency !== void 0 && choice.concurrency !== 1)
63
+ throw new CliError("validation_error", "Meeting embedding supports one remote request worker");
64
+ return { key: remoteKey(remote), dims: remote.dims, kind: "remote", model: remote.model };
65
+ }, "meetingEmbeddingModel");
66
+ var createMeetingRemoteModel = /* @__PURE__ */ __name((input) => {
67
+ try {
68
+ return validatedRemote(remoteModel(input));
69
+ } catch (error) {
70
+ if (error instanceof CliError)
71
+ throw error;
72
+ throw new CliError("validation_error", "Invalid embedding endpoint");
73
+ }
74
+ }, "createMeetingRemoteModel");
75
+ var withAbort = /* @__PURE__ */ __name(async (pending, signal) => {
76
+ cancelled(signal);
77
+ if (!signal)
78
+ return pending;
79
+ let onAbort = /* @__PURE__ */ __name(() => {
80
+ }, "onAbort");
81
+ const interrupted = new Promise((_, reject) => {
82
+ onAbort = /* @__PURE__ */ __name(() => reject(new CliError("cancelled", "Meeting embedding was cancelled")), "onAbort");
83
+ signal.addEventListener("abort", onAbort, { once: true });
84
+ });
85
+ try {
86
+ return await Promise.race([pending, interrupted]);
87
+ } finally {
88
+ signal.removeEventListener("abort", onAbort);
89
+ }
90
+ }, "withAbort");
91
+ var boundedResponse = /* @__PURE__ */ __name(async (response, maxBytes, signal) => {
92
+ const length = response.headers.get("content-length");
93
+ if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
94
+ void response.body?.cancel().catch(() => {
95
+ });
96
+ throw new CliError("invalid_response", "Embedding response exceeds the byte budget");
97
+ }
98
+ if (!response.body)
99
+ throw new CliError("invalid_response", "Embedding response has no body");
100
+ const reader = response.body.getReader();
101
+ const chunks = [];
102
+ let bytes = 0;
103
+ try {
104
+ for (; ; ) {
105
+ cancelled(signal);
106
+ const part = await withAbort(reader.read(), signal);
107
+ cancelled(signal);
108
+ if (part.done)
109
+ break;
110
+ bytes += part.value.byteLength;
111
+ if (bytes > maxBytes)
112
+ throw new CliError("invalid_response", "Embedding response exceeds the byte budget");
113
+ chunks.push(part.value);
114
+ }
115
+ const body = Buffer.concat(chunks, bytes).toString("utf8");
116
+ try {
117
+ return JSON.parse(body);
118
+ } catch {
119
+ throw new CliError("invalid_response", "Embedding response is not JSON");
120
+ }
121
+ } finally {
122
+ void reader.cancel().catch(() => {
123
+ });
124
+ reader.releaseLock();
125
+ }
126
+ }, "boundedResponse");
127
+ var openMeetingEmbedder = /* @__PURE__ */ __name(async (choice, options = {}) => {
128
+ const descriptor = meetingEmbeddingModel(choice, options.env);
129
+ const { signal } = options;
130
+ cancelled(signal);
131
+ const maxInputBytes = integer(options.maxInputBytes ?? 1024 * 1024, "input byte budget", 16 * 1024 * 1024);
132
+ const maxResponseBytes = integer(options.maxResponseBytes ?? 8 * 1024 * 1024, "response byte budget", 64 * 1024 * 1024);
133
+ if (options.threads !== void 0)
134
+ integer(options.threads, "embedding threads", 128);
135
+ let engine;
136
+ let remoteFailure;
137
+ if (typeof choice === "string") {
138
+ const model = textModel(choice, options.env);
139
+ const directory = options.directory ?? textModelsDirectory(options.env);
140
+ if (!isTextModelInstalled(model, directory))
141
+ throw new CliError("configuration_error", "The explicit local embedding model is not installed");
142
+ engine = await openEmbedder(model, directory, {
143
+ ...options.threads === void 0 ? {} : { threads: options.threads }
144
+ });
145
+ } else {
146
+ const remote = validatedRemote(choice.remote);
147
+ const key = choice.apiKey ?? (remote.provider === "openai" ? (options.env ?? process.env).OPENAI_API_KEY : void 0);
148
+ if (remote.provider === "openai" && !key)
149
+ throw new CliError("authentication_error", "The explicit remote embedding model requires an API key");
150
+ const post = options.fetch ?? endpointFetch(remote.baseUrl, 12e4);
151
+ const guarded = /* @__PURE__ */ __name(async (url, init) => {
152
+ try {
153
+ cancelled(signal);
154
+ const responseTask = post(url, { ...init, redirect: "manual", ...signal ? { signal } : {} }).then((response2) => {
155
+ if (signal?.aborted) {
156
+ void response2.body?.cancel().catch(() => {
157
+ });
158
+ cancelled(signal);
159
+ }
160
+ return response2;
161
+ });
162
+ const response = await withAbort(responseTask, signal);
163
+ if (signal?.aborted) {
164
+ void response.body?.cancel().catch(() => {
165
+ });
166
+ cancelled(signal);
167
+ }
168
+ if (response.status >= 300 && response.status < 400) {
169
+ void response.body?.cancel().catch(() => {
170
+ });
171
+ throw new CliError("invalid_response", "Embedding redirects are refused");
172
+ }
173
+ if (!response.ok) {
174
+ void response.body?.cancel().catch(() => {
175
+ });
176
+ return new Response("{}", { status: response.status });
177
+ }
178
+ const body = await boundedResponse(response, maxResponseBytes, signal);
179
+ if (!body || typeof body !== "object" || !("data" in body) || !Array.isArray(body.data) || body.data.length > 256)
180
+ throw new CliError("invalid_response", "Embedding response lacks vector data");
181
+ for (const entry of body.data) {
182
+ if (!entry || typeof entry !== "object" || !Number.isSafeInteger(entry.index) || entry.index < 0 || !Array.isArray(entry.embedding) || entry.embedding.length !== remote.dims || entry.embedding.some((value) => typeof value !== "number" || !Number.isFinite(value) || !Number.isFinite(Math.fround(value))))
183
+ throw new CliError("invalid_response", "Embedding response contains invalid vectors");
184
+ }
185
+ const indices = body.data.map((entry) => entry.index).sort((a, b) => a - b);
186
+ if (indices.some((index, position) => index !== position))
187
+ throw new CliError("invalid_response", "Embedding response contains invalid vector indices");
188
+ return new Response(JSON.stringify({ data: body.data.map((entry) => ({ index: entry.index, embedding: entry.embedding })) }), { status: response.status });
189
+ } catch (error) {
190
+ remoteFailure = error;
191
+ throw error;
192
+ }
193
+ }, "guarded");
194
+ engine = openRemote(remote, key, { concurrency: 1, fetch: guarded, tries: 1, env: options.env ?? process.env });
195
+ }
196
+ if (signal?.aborted) {
197
+ await engine.close();
198
+ cancelled(signal);
199
+ }
200
+ let closed = false;
201
+ let running = false;
202
+ let active = null;
203
+ let closing = null;
204
+ return {
205
+ ...descriptor,
206
+ async embed(texts, kind) {
207
+ cancelled(signal);
208
+ if (closed)
209
+ throw new CliError("configuration_error", "Meeting embedder is closed");
210
+ if (!Array.isArray(texts) || texts.length > 1e3 || texts.some((text) => typeof text !== "string") || !["query", "passage"].includes(kind))
211
+ throw new CliError("validation_error", "Invalid meeting embedding inputs");
212
+ if (Buffer.byteLength(JSON.stringify(texts), "utf8") > maxInputBytes || texts.length * descriptor.dims * 4 > maxResponseBytes)
213
+ throw new CliError("validation_error", "Meeting embedding input or vector payload exceeds its byte budget");
214
+ if (running)
215
+ throw new CliError("validation_error", "A meeting embedding request is already running");
216
+ running = true;
217
+ let settled = /* @__PURE__ */ __name(() => {
218
+ }, "settled");
219
+ active = new Promise((resolve) => {
220
+ settled = resolve;
221
+ });
222
+ remoteFailure = void 0;
223
+ try {
224
+ const vectors = await engine.embed([...texts], kind);
225
+ cancelled(signal);
226
+ if (vectors.length !== texts.length || vectors.some((vector) => vector.length !== descriptor.dims || !vector.some((value) => value !== 0) || [...vector].some((value) => !Number.isFinite(value))))
227
+ throw new CliError("invalid_response", "Meeting embedder returned invalid vectors");
228
+ return vectors;
229
+ } catch (error) {
230
+ cancelled(signal);
231
+ if (remoteFailure instanceof CliError)
232
+ throw remoteFailure;
233
+ if (error instanceof CliError)
234
+ throw error;
235
+ throw new CliError("provider_error", "Meeting embedding failed");
236
+ } finally {
237
+ running = false;
238
+ settled();
239
+ active = null;
240
+ }
241
+ },
242
+ async close() {
243
+ if (!closing) {
244
+ closed = true;
245
+ closing = (async () => {
246
+ await active;
247
+ await engine.close();
248
+ })();
249
+ }
250
+ await closing;
251
+ }
252
+ };
253
+ }, "openMeetingEmbedder");
254
+
255
+ export {
256
+ meetingEmbeddingModel,
257
+ createMeetingRemoteModel,
258
+ openMeetingEmbedder
259
+ };