@wirecat/attio-cli 0.8.0 → 0.10.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 (207) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/contracts/wirecat.json +1 -0
  3. package/dist/bin/attio.js +11 -11
  4. package/dist/bundle/attio.js +5 -166
  5. package/dist/bundle/{chunk-UXJZISVL.js → chunk-OGWKDPR5.js} +2 -1
  6. package/dist/bundle/chunk-TQAECZFO.js +13 -0
  7. package/dist/bundle/{definitions-FODOIPM2.js → definitions-J73IBAHT.js} +1 -1
  8. package/dist/bundle/program-NSBWZ25F.js +6201 -0
  9. package/dist/bundle/{schemas-YGSTNU6F.js → schemas-G3HFAS45.js} +576 -29
  10. package/dist/commands/api.js +1 -2
  11. package/dist/commands/crm.js +1 -4
  12. package/dist/commands/schedule.js +1 -1
  13. package/dist/commands/session.js +1 -2
  14. package/dist/config.js +1 -2
  15. package/dist/context.js +1 -1
  16. package/dist/identity.js +1 -0
  17. package/dist/program.js +1 -2
  18. package/dist/version.js +1 -1
  19. package/package.json +4 -4
  20. package/dist/activities.d.ts +0 -4
  21. package/dist/activities.d.ts.map +0 -1
  22. package/dist/activities.js.map +0 -1
  23. package/dist/bin/attio.d.ts +0 -3
  24. package/dist/bin/attio.d.ts.map +0 -1
  25. package/dist/bin/attio.js.map +0 -1
  26. package/dist/bundle/agent-GUXXSLT5.js +0 -38
  27. package/dist/bundle/all-profiles-63N3EQ46.js +0 -320
  28. package/dist/bundle/anthropic-B4W7MZQE.js +0 -91
  29. package/dist/bundle/app-server-EXNGTHWO.js +0 -250
  30. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  31. package/dist/bundle/bun-sqlite-NBAY7FR2.js +0 -76
  32. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  33. package/dist/bundle/chunk-2QDUP74I.js +0 -794
  34. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  35. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  36. package/dist/bundle/chunk-3MSHGNVE.js +0 -1243
  37. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  38. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  39. package/dist/bundle/chunk-4RBMCXZT.js +0 -1337
  40. package/dist/bundle/chunk-4RSWOPKL.js +0 -323
  41. package/dist/bundle/chunk-5JKTVAXX.js +0 -2788
  42. package/dist/bundle/chunk-5N2V6XO7.js +0 -119
  43. package/dist/bundle/chunk-5WD22IXQ.js +0 -66
  44. package/dist/bundle/chunk-6K4Z6CAM.js +0 -43997
  45. package/dist/bundle/chunk-6TD3DCWC.js +0 -106
  46. package/dist/bundle/chunk-7Z53MLQP.js +0 -388
  47. package/dist/bundle/chunk-AATTOFNY.js +0 -2045
  48. package/dist/bundle/chunk-APARYILG.js +0 -743
  49. package/dist/bundle/chunk-D72URWJE.js +0 -532
  50. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  51. package/dist/bundle/chunk-DM7KWVDZ.js +0 -3752
  52. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  53. package/dist/bundle/chunk-DPD4FMHN.js +0 -388
  54. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  55. package/dist/bundle/chunk-DURNR4RO.js +0 -353
  56. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  57. package/dist/bundle/chunk-EVUMQKV7.js +0 -76
  58. package/dist/bundle/chunk-EY36BTKZ.js +0 -108
  59. package/dist/bundle/chunk-FH6OEGGN.js +0 -557
  60. package/dist/bundle/chunk-FOP6G45D.js +0 -358
  61. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  62. package/dist/bundle/chunk-GTEX4IUO.js +0 -334
  63. package/dist/bundle/chunk-HZ3C4WXD.js +0 -142
  64. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  65. package/dist/bundle/chunk-J6GVVISK.js +0 -185
  66. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  67. package/dist/bundle/chunk-JIGEJZ4I.js +0 -68943
  68. package/dist/bundle/chunk-KVTNYRDO.js +0 -1007
  69. package/dist/bundle/chunk-L45WN3AR.js +0 -80
  70. package/dist/bundle/chunk-L72WUJAS.js +0 -54
  71. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  72. package/dist/bundle/chunk-LM3W7YOM.js +0 -274
  73. package/dist/bundle/chunk-M4AC55ZB.js +0 -12733
  74. package/dist/bundle/chunk-MCLQTCGH.js +0 -1202
  75. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  76. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  77. package/dist/bundle/chunk-OYEVYOCL.js +0 -259
  78. package/dist/bundle/chunk-P7G5HFY3.js +0 -288
  79. package/dist/bundle/chunk-PAEKXVJW.js +0 -188
  80. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  81. package/dist/bundle/chunk-PLPBEWD4.js +0 -170
  82. package/dist/bundle/chunk-PMQ7GP6X.js +0 -95
  83. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  84. package/dist/bundle/chunk-QPPOIWPY.js +0 -1246
  85. package/dist/bundle/chunk-QSJKSPWF.js +0 -131
  86. package/dist/bundle/chunk-RDVTHFPP.js +0 -338
  87. package/dist/bundle/chunk-RQORQN2V.js +0 -4072
  88. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  89. package/dist/bundle/chunk-S4UUN6LD.js +0 -1410
  90. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  91. package/dist/bundle/chunk-SCI7QEHF.js +0 -362
  92. package/dist/bundle/chunk-SSA6JBPA.js +0 -778
  93. package/dist/bundle/chunk-T4J7XFXT.js +0 -9667
  94. package/dist/bundle/chunk-TTF5DP4V.js +0 -1197
  95. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  96. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  97. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  98. package/dist/bundle/chunk-UKHF37ZU.js +0 -1068
  99. package/dist/bundle/chunk-V57E7PJQ.js +0 -161
  100. package/dist/bundle/chunk-V7IF2K3P.js +0 -52
  101. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  102. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  103. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  104. package/dist/bundle/chunk-WXQGA6XK.js +0 -50
  105. package/dist/bundle/chunk-XQGN2D44.js +0 -86
  106. package/dist/bundle/chunk-XQUUANA2.js +0 -24600
  107. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  108. package/dist/bundle/chunk-YNGU36GW.js +0 -218
  109. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  110. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  111. package/dist/bundle/chunk-ZZD2YPOX.js +0 -156
  112. package/dist/bundle/command-contract-KCCW4LNI.js +0 -37
  113. package/dist/bundle/command-server-entry-3NPPABQQ.js +0 -166
  114. package/dist/bundle/decode-26M7XE2B.js +0 -297
  115. package/dist/bundle/dispatch-2FTOHA5D.js +0 -411
  116. package/dist/bundle/dist-EM7KLEG4.js +0 -7577
  117. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  118. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  119. package/dist/bundle/embed-XJLEAWXE.js +0 -38
  120. package/dist/bundle/embedder-OEL6PXEH.js +0 -111
  121. package/dist/bundle/failure-OHIXWTR6.js +0 -25
  122. package/dist/bundle/first-run-CIXGBXY6.js +0 -29
  123. package/dist/bundle/first-screen-5FK4D45F.js +0 -38
  124. package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
  125. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  126. package/dist/bundle/meeting-combined-DMVGQNJ7.js +0 -24
  127. package/dist/bundle/meeting-model-2THAT7OH.js +0 -25
  128. package/dist/bundle/meeting-semantic-Q6XYFYUD.js +0 -22
  129. package/dist/bundle/node-EGMCBAO7.js +0 -176
  130. package/dist/bundle/node-KM3CUABH.js +0 -2340
  131. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  132. package/dist/bundle/node-sqlite-2SWWGW6H.js +0 -74
  133. package/dist/bundle/oauth-V5LGTXF2.js +0 -20
  134. package/dist/bundle/open-25EKOTZA.js +0 -23
  135. package/dist/bundle/openai-VX3OLIHM.js +0 -238
  136. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  137. package/dist/bundle/program-Z5NUNXME.js +0 -34214
  138. package/dist/bundle/prompt-2VSPX5S7.js +0 -17
  139. package/dist/bundle/recognize-NA5XUFKK.js +0 -26
  140. package/dist/bundle/remote-BOME6XOE.js +0 -31
  141. package/dist/bundle/rerank-NG3XMFCV.js +0 -52
  142. package/dist/bundle/serve-MR67OBED.js +0 -199
  143. package/dist/bundle/server-4BWAGJQO.js +0 -80
  144. package/dist/bundle/server-OP2HJNXD.js +0 -213
  145. package/dist/bundle/sqlite-runtime-V5U6F5EB.js +0 -20
  146. package/dist/bundle/state-L4MWAATO.js +0 -36
  147. package/dist/bundle/store-2ALTEH55.js +0 -181
  148. package/dist/bundle/store-CXZFRG5D.js +0 -297
  149. package/dist/bundle/store-maintenance-command-LC55DRQA.js +0 -67
  150. package/dist/bundle/surface-3GRJ7473.js +0 -66
  151. package/dist/commands/api.d.ts +0 -12
  152. package/dist/commands/api.d.ts.map +0 -1
  153. package/dist/commands/api.js.map +0 -1
  154. package/dist/commands/crm.d.ts +0 -7
  155. package/dist/commands/crm.d.ts.map +0 -1
  156. package/dist/commands/crm.js.map +0 -1
  157. package/dist/commands/schedule.d.ts +0 -3
  158. package/dist/commands/schedule.d.ts.map +0 -1
  159. package/dist/commands/schedule.js.map +0 -1
  160. package/dist/commands/session.d.ts +0 -8
  161. package/dist/commands/session.d.ts.map +0 -1
  162. package/dist/commands/session.js.map +0 -1
  163. package/dist/config.d.ts +0 -13
  164. package/dist/config.d.ts.map +0 -1
  165. package/dist/config.js.map +0 -1
  166. package/dist/context.d.ts +0 -37
  167. package/dist/context.d.ts.map +0 -1
  168. package/dist/context.js.map +0 -1
  169. package/dist/generated/definitions.d.ts +0 -3
  170. package/dist/generated/definitions.d.ts.map +0 -1
  171. package/dist/generated/definitions.js.map +0 -1
  172. package/dist/generated/manifest.d.ts +0 -6
  173. package/dist/generated/manifest.d.ts.map +0 -1
  174. package/dist/generated/manifest.js.map +0 -1
  175. package/dist/generated/schemas.d.ts +0 -383
  176. package/dist/generated/schemas.d.ts.map +0 -1
  177. package/dist/generated/schemas.js.map +0 -1
  178. package/dist/generated/types.d.ts +0 -10166
  179. package/dist/generated/types.d.ts.map +0 -1
  180. package/dist/generated/types.js.map +0 -1
  181. package/dist/generated/wirecat-config.d.ts +0 -15
  182. package/dist/generated/wirecat-config.d.ts.map +0 -1
  183. package/dist/generated/wirecat-config.js.map +0 -1
  184. package/dist/hooks.d.ts +0 -33
  185. package/dist/hooks.d.ts.map +0 -1
  186. package/dist/hooks.js.map +0 -1
  187. package/dist/identity.d.ts +0 -33
  188. package/dist/identity.d.ts.map +0 -1
  189. package/dist/identity.js.map +0 -1
  190. package/dist/index.d.ts +0 -3
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js.map +0 -1
  193. package/dist/links.d.ts +0 -10
  194. package/dist/links.d.ts.map +0 -1
  195. package/dist/links.js.map +0 -1
  196. package/dist/meetings.d.ts +0 -57
  197. package/dist/meetings.d.ts.map +0 -1
  198. package/dist/meetings.js.map +0 -1
  199. package/dist/program.d.ts +0 -6
  200. package/dist/program.d.ts.map +0 -1
  201. package/dist/program.js.map +0 -1
  202. package/dist/version.d.ts +0 -2
  203. package/dist/version.d.ts.map +0 -1
  204. package/dist/version.js.map +0 -1
  205. package/dist/wcat.d.ts +0 -3
  206. package/dist/wcat.d.ts.map +0 -1
  207. package/dist/wcat.js.map +0 -1
@@ -1,21 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- child_process,
5
- crypto,
6
- fs,
7
- os,
8
- path,
9
- stream,
10
- util
11
- } from "./chunk-DFDN6AUB.js";
12
- import "./chunk-ZVVMGPBJ.js";
13
- export {
14
- child_process,
15
- crypto,
16
- fs,
17
- os,
18
- path,
19
- stream,
20
- util
21
- };
@@ -1,74 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- loadVectorExtension,
5
- vectorExtension
6
- } from "./chunk-NISH4UXM.js";
7
- import {
8
- refuseOwnerStoreInTests
9
- } from "./chunk-L72WUJAS.js";
10
- import {
11
- TIME_LIMIT_FUNCTION,
12
- beforeTimeLimit
13
- } from "./chunk-GGMAIIVE.js";
14
- import "./chunk-5JKTVAXX.js";
15
- import "./chunk-QPPOIWPY.js";
16
- import "./chunk-S4UUN6LD.js";
17
- import "./chunk-Y5E2WNWB.js";
18
- import "./chunk-S6JG4YUH.js";
19
- import {
20
- __name
21
- } from "./chunk-ZVVMGPBJ.js";
22
-
23
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/store/drivers/node-sqlite.js
24
- import { DatabaseSync } from "node:sqlite";
25
- var openWithNodeSqlite = /* @__PURE__ */ __name(async (path) => cacheOverNodeSqlite(await nodeClient(path)), "openWithNodeSqlite");
26
- var nodeClient = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
27
- refuseOwnerStoreInTests(path);
28
- const extension = await vectorExtension();
29
- const client = new DatabaseSync(path, { readOnly, allowExtension: true });
30
- try {
31
- loadVectorExtension(client, extension);
32
- return client;
33
- } catch (error) {
34
- client.close();
35
- throw error;
36
- }
37
- }, "nodeClient");
38
- var STATEMENT_CACHE_SIZE = 1e3;
39
- var cacheOverNodeSqlite = /* @__PURE__ */ __name((database, cacheSize = STATEMENT_CACHE_SIZE) => {
40
- const statements = /* @__PURE__ */ new Map();
41
- database.function(TIME_LIMIT_FUNCTION, { deterministic: false, directOnly: true }, beforeTimeLimit);
42
- const prepare = /* @__PURE__ */ __name((sql) => {
43
- const statement = database.prepare(sql);
44
- return {
45
- run: /* @__PURE__ */ __name((...parameters) => ({ changes: Number(statement.run(...parameters).changes) }), "run"),
46
- get: /* @__PURE__ */ __name((...parameters) => statement.get(...parameters), "get"),
47
- all: /* @__PURE__ */ __name((...parameters) => statement.all(...parameters), "all")
48
- };
49
- }, "prepare");
50
- return {
51
- timeLimit: true,
52
- exec: /* @__PURE__ */ __name((sql) => database.exec(sql), "exec"),
53
- prepare: /* @__PURE__ */ __name((sql) => {
54
- const cached = statements.get(sql);
55
- if (cached)
56
- statements.delete(sql);
57
- const statement = cached ?? prepare(sql);
58
- statements.set(sql, statement);
59
- if (statements.size > cacheSize)
60
- statements.delete(statements.keys().next().value);
61
- return statement;
62
- }, "prepare"),
63
- close: /* @__PURE__ */ __name(() => {
64
- statements.clear();
65
- database.close();
66
- }, "close")
67
- };
68
- }, "cacheOverNodeSqlite");
69
- export {
70
- STATEMENT_CACHE_SIZE,
71
- cacheOverNodeSqlite,
72
- nodeClient,
73
- openWithNodeSqlite
74
- };
@@ -1,20 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- ownerLogin,
5
- revokeAll
6
- } from "./chunk-P7G5HFY3.js";
7
- import "./chunk-PL5P7UKW.js";
8
- import "./chunk-V57E7PJQ.js";
9
- import "./chunk-XQGN2D44.js";
10
- import "./chunk-3YM4B2GT.js";
11
- import "./chunk-5JKTVAXX.js";
12
- import "./chunk-QPPOIWPY.js";
13
- import "./chunk-S4UUN6LD.js";
14
- import "./chunk-Y5E2WNWB.js";
15
- import "./chunk-S6JG4YUH.js";
16
- import "./chunk-ZVVMGPBJ.js";
17
- export {
18
- ownerLogin,
19
- revokeAll
20
- };
@@ -1,23 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- CAPABILITY_STATEMENTS,
5
- assertStoreCapable,
6
- openCache,
7
- openFile,
8
- storeCapable
9
- } from "./chunk-PMQ7GP6X.js";
10
- import "./chunk-GGMAIIVE.js";
11
- import "./chunk-5JKTVAXX.js";
12
- import "./chunk-QPPOIWPY.js";
13
- import "./chunk-S4UUN6LD.js";
14
- import "./chunk-Y5E2WNWB.js";
15
- import "./chunk-S6JG4YUH.js";
16
- import "./chunk-ZVVMGPBJ.js";
17
- export {
18
- CAPABILITY_STATEMENTS,
19
- assertStoreCapable,
20
- openCache,
21
- openFile,
22
- storeCapable
23
- };
@@ -1,238 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- SAMPLE_RATE,
5
- toModelRate
6
- } from "./chunk-LKH3UKLO.js";
7
- import "./chunk-JG6LCSEX.js";
8
- import {
9
- OPENAI_URL,
10
- refuseModelAddress
11
- } from "./chunk-J6GVVISK.js";
12
- import {
13
- endpointFetch,
14
- onThisComputer,
15
- providerWaitMs
16
- } from "./chunk-7Z53MLQP.js";
17
- import "./chunk-TTF5DP4V.js";
18
- import "./chunk-KVTNYRDO.js";
19
- import {
20
- OPENAI_TRANSCRIBE_MODEL,
21
- VAD,
22
- filesPresent,
23
- modelsDirectory,
24
- vadPath
25
- } from "./chunk-LM3W7YOM.js";
26
- import "./chunk-L72WUJAS.js";
27
- import {
28
- DEFAULT_RETRY,
29
- backoffMs
30
- } from "./chunk-5JKTVAXX.js";
31
- import "./chunk-QPPOIWPY.js";
32
- import "./chunk-S4UUN6LD.js";
33
- import "./chunk-Y5E2WNWB.js";
34
- import {
35
- CliError
36
- } from "./chunk-S6JG4YUH.js";
37
- import {
38
- __name
39
- } from "./chunk-ZVVMGPBJ.js";
40
-
41
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/openai.js
42
- import { setTimeout as wait } from "node:timers/promises";
43
-
44
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/wav.js
45
- var encodeWav = /* @__PURE__ */ __name((samples, sampleRate = 16e3) => {
46
- const bytes = Buffer.alloc(44 + samples.length * 2);
47
- bytes.write("RIFF", 0, "ascii");
48
- bytes.writeUInt32LE(bytes.length - 8, 4);
49
- bytes.write("WAVEfmt ", 8, "ascii");
50
- bytes.writeUInt32LE(16, 16);
51
- bytes.writeUInt16LE(1, 20);
52
- bytes.writeUInt16LE(1, 22);
53
- bytes.writeUInt32LE(sampleRate, 24);
54
- bytes.writeUInt32LE(sampleRate * 2, 28);
55
- bytes.writeUInt16LE(2, 32);
56
- bytes.writeUInt16LE(16, 34);
57
- bytes.write("data", 36, "ascii");
58
- bytes.writeUInt32LE(samples.length * 2, 40);
59
- samples.forEach((sample, index) => {
60
- bytes.writeInt16LE(Math.round(Math.max(-1, Math.min(1, sample || 0)) * 32767), 44 + index * 2);
61
- });
62
- return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.length);
63
- }, "encodeWav");
64
-
65
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/speech/openai.js
66
- var LONGEST_REQUEST_SECONDS = 600;
67
- var JOINED_SECONDS = 0.2;
68
- var PAD_SECONDS = 0.2;
69
- var LEAD = SAMPLE_RATE / 2;
70
- var EXHAUSTED = /* @__PURE__ */ new Set([
71
- "insufficient_quota",
72
- "credit_balance_exhausted",
73
- "organization_spend_limit_exceeded",
74
- "project_spend_limit_exceeded",
75
- "organization_usage_limit_exceeded"
76
- ]);
77
- var RETRY = { ...DEFAULT_RETRY, retries: 4 };
78
- var interrupted = /* @__PURE__ */ __name((signal) => {
79
- if (!signal?.aborted)
80
- return;
81
- if (signal.reason instanceof CliError)
82
- throw signal.reason;
83
- const timeout = signal.reason instanceof Error && signal.reason.name === "TimeoutError";
84
- throw new CliError(timeout ? "timeout" : "cancelled", "the transcription was interrupted");
85
- }, "interrupted");
86
- var sleeping = /* @__PURE__ */ __name((ms, signal) => wait(ms, void 0, signal ? { signal } : {}).then(() => void 0, (error) => {
87
- interrupted(signal);
88
- throw error;
89
- }), "sleeping");
90
- var formOf = /* @__PURE__ */ __name((wav, options) => {
91
- const form = new FormData();
92
- form.append("file", new Blob([wav], { type: "audio/wav" }), "audio.wav");
93
- form.append("model", options.model ?? OPENAI_TRANSCRIBE_MODEL);
94
- for (const language of options.languages ?? [])
95
- form.append("languages[]", language);
96
- for (const keyword of options.keywords ?? [])
97
- form.append("keywords[]", keyword);
98
- if (options.prompt)
99
- form.append("prompt", options.prompt);
100
- return form;
101
- }, "formOf");
102
- var safe = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[\w.-]{1,64}$/.test(value) ? value : void 0, "safe");
103
- var failureOf = /* @__PURE__ */ __name(async (response) => {
104
- try {
105
- const body = await response.json();
106
- const code = safe(body.error?.code);
107
- const type = safe(body.error?.type);
108
- return { ...code ? { code } : {}, ...type ? { type } : {} };
109
- } catch {
110
- return {};
111
- }
112
- }, "failureOf");
113
- var TRANSCRIPTION_TIMEOUT_MS = 6e5;
114
- var send = /* @__PURE__ */ __name(async (wav, options) => {
115
- const url = `${(options.baseUrl ?? OPENAI_URL).replace(/\/+$/, "")}/audio/transcriptions`;
116
- const post = options.fetch ?? endpointFetch(url, TRANSCRIPTION_TIMEOUT_MS);
117
- const retry = options.retry ?? RETRY;
118
- const sleep = options.sleep ?? sleeping;
119
- const random = options.random ?? Math.random;
120
- const who = options.label ?? "OpenAI";
121
- for (let attempt = 1; ; attempt++) {
122
- interrupted(options.signal);
123
- let response;
124
- try {
125
- response = await post(url, {
126
- method: "POST",
127
- headers: options.apiKey ? { authorization: `Bearer ${options.apiKey}` } : {},
128
- body: formOf(wav, options),
129
- ...options.signal ? { signal: options.signal } : {}
130
- });
131
- } catch {
132
- interrupted(options.signal);
133
- if (attempt > retry.retries)
134
- throw new CliError("network_error", `${who} could not be reached`, { reason: "network.failed" });
135
- await sleep(backoffMs(attempt, retry, random), options.signal);
136
- continue;
137
- }
138
- if (response.ok) {
139
- const body = await response.json().catch(() => interrupted(options.signal));
140
- if (typeof body?.text !== "string")
141
- throw new CliError("invalid_response", `${who} answered without a transcript`, {
142
- reason: "provider.invalid-response"
143
- });
144
- return body.text.trim();
145
- }
146
- const { code, type } = await failureOf(response);
147
- const status = response.status;
148
- const said = `HTTP ${status}${code ? `, ${code}` : type ? `, ${type}` : ""}`;
149
- if (status === 401)
150
- throw new CliError("authentication_error", `${who} refused the key (${said}) \u2014 set it again with \`${options.keyHint ?? "models keys set openai"}\``, { reason: "auth.failed" });
151
- if (status === 403)
152
- throw new CliError("permission_error", `${who} refused the request (${said}) \u2014 OpenAI answers this when the country or region is not supported, or the key's project may not use the model`, { reason: "access.denied" });
153
- if (status === 413)
154
- throw new CliError("validation_error", `${who} refused the audio as too large (${said})`, {
155
- reason: "transcription.too-large"
156
- });
157
- if (EXHAUSTED.has(code ?? "") || EXHAUSTED.has(type ?? ""))
158
- throw new CliError("permission_error", `${who} refused: the account's credit, spend limit or usage limit is used up (${said}) \u2014 see the billing page`, { reason: "transcription.quota-exhausted" });
159
- const again = status === 408 || status === 429 || status >= 500;
160
- const asked = providerWaitMs(response.headers, () => /* @__PURE__ */ new Date());
161
- if (again && attempt <= retry.retries && (asked === void 0 || asked <= retry.maxRetryAfterMs)) {
162
- await sleep(asked ?? backoffMs(attempt, retry, random), options.signal);
163
- continue;
164
- }
165
- if (status === 429)
166
- throw new CliError("rate_limited", `${who} answered ${said}`, {
167
- reason: "provider.rate-limited",
168
- ...asked === void 0 ? {} : { retry_after_ms: asked }
169
- });
170
- if (status >= 500)
171
- throw new CliError([502, 503, 504].includes(status) ? "provider_unavailable" : "provider_error", `${who} answered ${said}`, { reason: [502, 503, 504].includes(status) ? "provider.unavailable" : "provider.refused" });
172
- throw new CliError("provider_error", `${who} answered ${said}`, { reason: "provider.refused" });
173
- }
174
- }, "send");
175
- var piecesOf = /* @__PURE__ */ __name((spans, limit) => {
176
- const pieces = [];
177
- for (const span of spans) {
178
- const last = pieces.at(-1);
179
- const joined = last !== void 0 && span.start - last.end < JOINED_SECONDS;
180
- const fits = last !== void 0 && limit !== void 0 && span.end - last.start <= limit;
181
- if (last && (fits || joined && span.end - last.start <= LONGEST_REQUEST_SECONDS))
182
- last.end = span.end;
183
- else
184
- pieces.push({ start: span.start, end: span.end });
185
- }
186
- return pieces;
187
- }, "piecesOf");
188
- var openCutter = /* @__PURE__ */ __name(async (vadModel) => {
189
- const { openSpeechCutter } = await import("./recognize-NA5XUFKK.js");
190
- return openSpeechCutter(vadModel);
191
- }, "openCutter");
192
- var checkKeywords = /* @__PURE__ */ __name((keywords = []) => {
193
- const bad = keywords.find((keyword) => typeof keyword !== "string" || !keyword.trim() || /[<>\r\n]/.test(keyword));
194
- if (bad !== void 0)
195
- throw new CliError("validation_error", "a keyword must be a non-empty single line without < or > \u2014 OpenAI refuses the whole request otherwise");
196
- }, "checkKeywords");
197
- var transcribeOpenAI = /* @__PURE__ */ __name(async (audio, options) => {
198
- refuseModelAddress(options.env ?? process.env, options.baseUrl ?? OPENAI_URL, "audio");
199
- if (!options.apiKey && !onThisComputer(options.baseUrl ?? OPENAI_URL))
200
- throw new CliError("authentication_error", "no OpenAI key \u2014 `models keys set openai`, or OPENAI_API_KEY", {
201
- reason: "transcription.no-key"
202
- });
203
- checkKeywords(options.keywords);
204
- interrupted(options.signal);
205
- const pcm = toModelRate(audio.samples, audio.rate);
206
- const duration = (pcm.length - LEAD) / SAMPLE_RATE;
207
- if (options.bundle && duration <= LONGEST_REQUEST_SECONDS) {
208
- const text = await send(encodeWav(pcm.subarray(LEAD)), options);
209
- return text ? [{ start: 0, end: duration, text }] : [];
210
- }
211
- const vadModel = options.vadModel ?? vadPath(modelsDirectory(options.env));
212
- if (!options.cutter && !filesPresent([[VAD, vadModel]]))
213
- 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" });
214
- const cutter = await (options.cutter ?? openCutter)(vadModel);
215
- let spans;
216
- try {
217
- spans = cutter.cut(pcm);
218
- } finally {
219
- cutter.free();
220
- }
221
- const pieces = piecesOf(spans, options.bundle ? LONGEST_REQUEST_SECONDS : void 0);
222
- const heard = [];
223
- for (const [index, piece] of pieces.entries()) {
224
- const end = Math.min(piece.end, duration);
225
- const from = Math.max(piece.start - PAD_SECONDS, pieces[index - 1]?.end ?? 0);
226
- const to = Math.min(end + PAD_SECONDS, pieces[index + 1]?.start ?? duration);
227
- const samples = pcm.subarray(LEAD + Math.floor(from * SAMPLE_RATE), LEAD + Math.ceil(to * SAMPLE_RATE));
228
- const text = await send(encodeWav(samples), options);
229
- if (text)
230
- heard.push({ start: Math.min(piece.start, end), end, text });
231
- }
232
- return heard;
233
- }, "transcribeOpenAI");
234
- export {
235
- LONGEST_REQUEST_SECONDS,
236
- piecesOf,
237
- transcribeOpenAI
238
- };
@@ -1,91 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import "./chunk-Y5E2WNWB.js";
4
- import {
5
- __name
6
- } from "./chunk-ZVVMGPBJ.js";
7
-
8
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/embeddings/process.js
9
- import { spawn } from "node:child_process";
10
- import { createInterface } from "node:readline";
11
- import { fileURLToPath } from "node:url";
12
- var openProcess = /* @__PURE__ */ __name(async (model, directory, { threads }) => {
13
- const child = await modelProcess({ model, directory, threads });
14
- return {
15
- model,
16
- embed: /* @__PURE__ */ __name(async (texts, kind) => ((await child.ask({ texts, kind })).vectors ?? []).map((vector) => Float32Array.from(vector)), "embed"),
17
- close: child.close
18
- };
19
- }, "openProcess");
20
- var openRerankerProcess = /* @__PURE__ */ __name(async (model, directory, { threads }) => {
21
- const child = await modelProcess({ model, directory, threads, rerank: true });
22
- return {
23
- model,
24
- score: /* @__PURE__ */ __name(async (question, passages) => (await child.ask({ question, texts: passages })).scores ?? [], "score"),
25
- close: child.close
26
- };
27
- }, "openRerankerProcess");
28
- var modelProcess = /* @__PURE__ */ __name(async (setup) => {
29
- const child = spawn(process.execPath, [fileURLToPath(new URL("./child.js", new URL("embeddings/process.js", import.meta.resolve("@wirecat/cli-core")).href)), JSON.stringify(setup)], { stdio: ["pipe", "pipe", "pipe"] });
30
- const pending = /* @__PURE__ */ new Map();
31
- let said = "";
32
- child.stderr.setEncoding("utf8").on("data", (text) => {
33
- said = (said + text).slice(-2e3);
34
- });
35
- let ready = /* @__PURE__ */ __name(() => {
36
- }, "ready");
37
- let refused = /* @__PURE__ */ __name((_error) => {
38
- }, "refused");
39
- const started = new Promise((resolve, reject) => {
40
- ready = resolve;
41
- refused = reject;
42
- });
43
- let gone;
44
- const stopped = /* @__PURE__ */ __name((error) => {
45
- gone ??= error;
46
- refused(error);
47
- for (const job of pending.values())
48
- job.reject(error);
49
- pending.clear();
50
- }, "stopped");
51
- const exited = new Promise((resolve) => {
52
- child.once("exit", (code) => {
53
- const last = said.trim().split("\n").at(-1);
54
- stopped(new Error(`the embedding process stopped (exit ${code})${last ? `: ${last}` : ""}`));
55
- resolve();
56
- });
57
- });
58
- child.once("error", stopped);
59
- createInterface({ input: child.stdout }).on("line", (line) => {
60
- const answer = JSON.parse(line);
61
- if ("ready" in answer)
62
- return ready();
63
- const job = pending.get(answer.id);
64
- pending.delete(answer.id);
65
- if (answer.error !== void 0 || !(answer.vectors ?? answer.scores))
66
- job?.reject(new Error(answer.error ?? "no answer"));
67
- else
68
- job?.resolve(answer);
69
- });
70
- await started;
71
- let next = 0;
72
- return {
73
- ask: /* @__PURE__ */ __name((request) => new Promise((resolve, reject) => {
74
- if (gone)
75
- return reject(gone);
76
- const id = next++;
77
- pending.set(id, { resolve, reject });
78
- child.stdin.write(`${JSON.stringify({ id, ...request })}
79
- `);
80
- }), "ask"),
81
- close: /* @__PURE__ */ __name(async () => {
82
- if (child.exitCode === null && child.signalCode === null)
83
- child.stdin.end();
84
- await exited;
85
- }, "close")
86
- };
87
- }, "modelProcess");
88
- export {
89
- openProcess,
90
- openRerankerProcess
91
- };