@wirecat/tg-cli 0.108.0 → 0.109.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 (101) hide show
  1. package/dist/bin/tg.js +2 -2
  2. package/dist/bundle/{adapter-YFWRJWL5.js → adapter-6JLFYFL5.js} +45 -44
  3. package/dist/bundle/{all-profiles-GQIZSF4W.js → all-profiles-X7Y3T5S4.js} +8 -8
  4. package/dist/bundle/{anthropic-BKWEDKPU.js → anthropic-LGVXAADT.js} +5 -5
  5. package/dist/bundle/{app-server-RJV7ICLH.js → app-server-UI3AFSJX.js} +40 -39
  6. package/dist/bundle/{bot-api-2PAH2JZ3.js → bot-api-TQYRNYJQ.js} +46 -45
  7. package/dist/bundle/{bot-history-DPPZ43F4.js → bot-history-DDNTNMNB.js} +15 -15
  8. package/dist/bundle/{bun-Q7COX3Z5.js → bun-WXGS6HML.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-YI4AYZXO.js → bun-sqlite-M6JEXKRT.js} +4 -4
  10. package/dist/bundle/{chunk-PQHYM2XC.js → chunk-25VC6U3A.js} +1 -1
  11. package/dist/bundle/{chunk-DNOJKQXQ.js → chunk-2ILQYCBY.js} +377 -286
  12. package/dist/bundle/{chunk-EWL3ZFOI.js → chunk-3PEZWXKO.js} +6 -6
  13. package/dist/bundle/{chunk-LY2LFJMU.js → chunk-4R4AH6FM.js} +117 -94
  14. package/dist/bundle/{chunk-CVWF3BFK.js → chunk-5SUFMBU5.js} +44 -44
  15. package/dist/bundle/chunk-76C5SSMR.js +379 -0
  16. package/dist/bundle/{chunk-5HPXENE5.js → chunk-7AJ2IESO.js} +1 -1
  17. package/dist/bundle/{chunk-PCMW3PW6.js → chunk-7T7ILNCU.js} +2 -2
  18. package/dist/bundle/{chunk-ZYBDAZFO.js → chunk-AD3QPYI3.js} +2 -2
  19. package/dist/bundle/{chunk-ON67U6WV.js → chunk-AGVKIJB7.js} +6 -6
  20. package/dist/bundle/{chunk-YJ6GFFEE.js → chunk-BESIMQ5U.js} +1 -1
  21. package/dist/bundle/{chunk-76OSISA3.js → chunk-BHPCZCX7.js} +2 -2
  22. package/dist/bundle/{chunk-3GXKJKIC.js → chunk-BZIZLEJN.js} +4 -4
  23. package/dist/bundle/{chunk-BOSMBW4I.js → chunk-C3RX3UOE.js} +11 -11
  24. package/dist/bundle/{chunk-KQFR7ZAA.js → chunk-CH2ESVV5.js} +22 -22
  25. package/dist/bundle/{chunk-WUF64WOG.js → chunk-CHI6D4D6.js} +4 -4
  26. package/dist/bundle/{chunk-DUWTG2GE.js → chunk-CVLDXFRP.js} +8 -8
  27. package/dist/bundle/{chunk-MFS52LTZ.js → chunk-DLAFGSTN.js} +1 -1
  28. package/dist/bundle/{chunk-XZXOGHU5.js → chunk-DO33KAMM.js} +71 -60
  29. package/dist/bundle/{chunk-77OOX2OE.js → chunk-DZVYGBZB.js} +79 -56
  30. package/dist/bundle/{chunk-WAGDZB62.js → chunk-GUFM5RLW.js} +2 -2
  31. package/dist/bundle/{chunk-REI5TPS3.js → chunk-IGIPIO4J.js} +11 -11
  32. package/dist/bundle/{chunk-LYLGLFWY.js → chunk-INYO2QFW.js} +3 -3
  33. package/dist/bundle/{chunk-3HYDKCXB.js → chunk-IULYECPC.js} +12 -12
  34. package/dist/bundle/{chunk-6MZ2ZBX4.js → chunk-IV2QWSPG.js} +2 -2
  35. package/dist/bundle/{chunk-6QTUYMGX.js → chunk-KHKC236O.js} +2 -2
  36. package/dist/bundle/{chunk-QVIT6SQ5.js → chunk-M62LF3QE.js} +613 -381
  37. package/dist/bundle/{chunk-KZPZFPGB.js → chunk-MF6NKU3Z.js} +81 -30
  38. package/dist/bundle/{chunk-WEDWIXIC.js → chunk-N56WXUCW.js} +2 -2
  39. package/dist/bundle/{chunk-T4SDOYPY.js → chunk-N5FSRC6H.js} +117 -70
  40. package/dist/bundle/{chunk-FG2QTYEF.js → chunk-NAVNCM5K.js} +1 -1
  41. package/dist/bundle/{chunk-F67VPIJL.js → chunk-OHLMHBDI.js} +28 -28
  42. package/dist/bundle/{chunk-SONKULUF.js → chunk-P55L4S6N.js} +3 -3
  43. package/dist/bundle/{chunk-OB5PPPXH.js → chunk-P57R2P75.js} +7 -7
  44. package/dist/bundle/{chunk-5P27JGGA.js → chunk-P5ILJ7MN.js} +5 -5
  45. package/dist/bundle/{chunk-AS2BVZU3.js → chunk-QQF7RDLR.js} +49 -24
  46. package/dist/bundle/{chunk-WKSLGPZQ.js → chunk-RD2NLJSU.js} +16 -4
  47. package/dist/bundle/{chunk-NCXCBVHO.js → chunk-S7B6MTXX.js} +6 -6
  48. package/dist/bundle/{chunk-CZANI3DM.js → chunk-SH63Q4QR.js} +22 -22
  49. package/dist/bundle/{chunk-BT6PWDM6.js → chunk-TMXNMO66.js} +3 -3
  50. package/dist/bundle/{chunk-4RDMNNVO.js → chunk-UIPBAT2T.js} +26 -14
  51. package/dist/bundle/{chunk-EBB7RFCW.js → chunk-UUQ3BH2Z.js} +2 -2
  52. package/dist/bundle/{chunk-VMU4SGCE.js → chunk-VFVMB3NV.js} +8 -6
  53. package/dist/bundle/{chunk-B7TFWNKJ.js → chunk-VYR2IIWW.js} +1 -1
  54. package/dist/bundle/{chunk-AOUB2QFP.js → chunk-WHYS6OSG.js} +2 -2
  55. package/dist/bundle/{chunk-ZHHVNTBJ.js → chunk-WNTXIQMB.js} +2 -2
  56. package/dist/bundle/{chunk-26PWIQPP.js → chunk-XJVGCCQE.js} +666 -782
  57. package/dist/bundle/{chunk-67SRVSPU.js → chunk-XMMWKHNY.js} +26 -9
  58. package/dist/bundle/{chunk-BL72ZIBV.js → chunk-YXCQ4DLZ.js} +1 -1
  59. package/dist/bundle/{chunk-3562DVQ7.js → chunk-YYOIULA2.js} +8 -8
  60. package/dist/bundle/{chunk-TVA3NXXO.js → chunk-ZFMS5G4H.js} +2 -2
  61. package/dist/bundle/{chunk-D6DBVPES.js → chunk-ZHP44EML.js} +3 -3
  62. package/dist/bundle/{chunk-VK2YLSK7.js → chunk-ZMZKZL3Y.js} +1 -1
  63. package/dist/bundle/{chunk-R5YOKYTE.js → chunk-ZUOS7QUB.js} +11 -11
  64. package/dist/bundle/command-contract-E2MWR3T3.js +32 -0
  65. package/dist/bundle/{decode-ZFAFVFWX.js → decode-RKPOGPBE.js} +19 -17
  66. package/dist/bundle/{echarts-SVXNTKGV.js → echarts-H5QQRBHI.js} +2 -2
  67. package/dist/bundle/{embed-V755YE7O.js → embed-7TVAPNP7.js} +5 -5
  68. package/dist/bundle/{embedder-MQAPNQBH.js → embedder-YOOHWWN6.js} +8 -8
  69. package/dist/bundle/{entry-ULQ3VOMQ.js → entry-SAKW5HEZ.js} +5 -5
  70. package/dist/bundle/{first-run-64BTWXDR.js → first-run-C744N572.js} +9 -9
  71. package/dist/bundle/first-screen-7GKUEIWS.js +30 -0
  72. package/dist/bundle/{identity-PW45VBUU.js → identity-NRWTZIQ4.js} +3 -3
  73. package/dist/bundle/{instructions-G3ZUIRRH.js → instructions-6LWRAW47.js} +1 -1
  74. package/dist/bundle/{mcp-OQBZXELQ.js → mcp-WSGVVZWI.js} +2 -2
  75. package/dist/bundle/{node-IDJXLZSX.js → node-XN4PIVWW.js} +2 -2
  76. package/dist/bundle/{node-sqlite-W22J37MG.js → node-sqlite-PCBGROGQ.js} +4 -4
  77. package/dist/bundle/{oauth-Q52LBXDE.js → oauth-PX6NGHUV.js} +6 -6
  78. package/dist/bundle/{open-YLD7VHEC.js → open-BKJGJ6GX.js} +3 -3
  79. package/dist/bundle/openai-MJP7CZXP.js +250 -0
  80. package/dist/bundle/{process-OBESF2XG.js → process-4PRR3MLT.js} +1 -1
  81. package/dist/bundle/{program-EBMWHOKQ.js → program-7YZUO42B.js} +48 -47
  82. package/dist/bundle/{prompt-FHHQF3MG.js → prompt-CILSZC2R.js} +4 -4
  83. package/dist/bundle/{proxy-transport-YSBYG26I.js → proxy-transport-FWGKTYBL.js} +4 -4
  84. package/dist/bundle/{recognize-QNHKHGKM.js → recognize-AVFDJAIL.js} +5 -3
  85. package/dist/bundle/{remote-RVZWRCCT.js → remote-2VYXGOM4.js} +6 -6
  86. package/dist/bundle/{rerank-KG2USEME.js → rerank-6FU2JPCD.js} +6 -6
  87. package/dist/bundle/{serve-I4MJKEQ4.js → serve-3YQOHBR6.js} +8 -8
  88. package/dist/bundle/server-S2K4YDDG.js +56 -0
  89. package/dist/bundle/{server-GV7SV3L6.js → server-TPK3LNEX.js} +32 -31
  90. package/dist/bundle/{state-AJKHWFBU.js → state-LLUNBLZE.js} +5 -5
  91. package/dist/bundle/{store-L3HFSSGJ.js → store-27FQ743G.js} +10 -10
  92. package/dist/bundle/store-maintenance-command-AFJMKEBK.js +45 -0
  93. package/dist/bundle/tg.js +4 -4
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +3 -3
  97. package/dist/bundle/command-contract-5GJV6EHG.js +0 -32
  98. package/dist/bundle/first-screen-YZCH4TEV.js +0 -30
  99. package/dist/bundle/server-AXMWFPNT.js +0 -55
  100. package/dist/bundle/store-maintenance-command-Y22ARSDR.js +0 -44
  101. /package/dist/bundle/{chunk-O5EHUB2V.js → chunk-62EDJKGP.js} +0 -0
@@ -18,12 +18,12 @@ import {
18
18
  jitCompatCheck,
19
19
  refineSqliteCodecs,
20
20
  sql
21
- } from "./chunk-VK2YLSK7.js";
21
+ } from "./chunk-ZMZKZL3Y.js";
22
22
  import {
23
23
  __name
24
24
  } from "./chunk-ZVVMGPBJ.js";
25
25
 
26
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._95f40a748301e48ce1af109feea5b293/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/node.js
26
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/node.js
27
27
  import { DatabaseSync } from "node:sqlite";
28
28
  var nodeSQLiteCodecs = refineSqliteCodecs({
29
29
  "integer:boolean": { normalize: booleanFromInteger },
@@ -3,15 +3,15 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  loadVectorExtension,
5
5
  vectorExtension
6
- } from "./chunk-76OSISA3.js";
7
- import "./chunk-T4SDOYPY.js";
8
- import "./chunk-67SRVSPU.js";
6
+ } from "./chunk-BHPCZCX7.js";
7
+ import "./chunk-N5FSRC6H.js";
8
+ import "./chunk-XMMWKHNY.js";
9
9
  import "./chunk-Y5E2WNWB.js";
10
10
  import {
11
11
  __name
12
12
  } from "./chunk-ZVVMGPBJ.js";
13
13
 
14
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._95f40a748301e48ce1af109feea5b293/node_modules/@wirecat/cli-core/dist/store/drivers/node-sqlite.js
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/drivers/node-sqlite.js
15
15
  import { DatabaseSync } from "node:sqlite";
16
16
  var openWithNodeSqlite = /* @__PURE__ */ __name(async (path) => cacheOverNodeSqlite(await nodeClient(path)), "openWithNodeSqlite");
17
17
  var nodeClient = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
@@ -3,13 +3,13 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  ownerLogin,
5
5
  revokeAll
6
- } from "./chunk-WEDWIXIC.js";
6
+ } from "./chunk-N56WXUCW.js";
7
7
  import "./chunk-5D4AEUVA.js";
8
- import "./chunk-WUF64WOG.js";
9
- import "./chunk-BT6PWDM6.js";
10
- import "./chunk-PQHYM2XC.js";
11
- import "./chunk-T4SDOYPY.js";
12
- import "./chunk-67SRVSPU.js";
8
+ import "./chunk-CHI6D4D6.js";
9
+ import "./chunk-TMXNMO66.js";
10
+ import "./chunk-25VC6U3A.js";
11
+ import "./chunk-N5FSRC6H.js";
12
+ import "./chunk-XMMWKHNY.js";
13
13
  import "./chunk-Y5E2WNWB.js";
14
14
  import "./chunk-ZVVMGPBJ.js";
15
15
  export {
@@ -6,9 +6,9 @@ import {
6
6
  openCache,
7
7
  openFile,
8
8
  storeCapable
9
- } from "./chunk-NCXCBVHO.js";
10
- import "./chunk-T4SDOYPY.js";
11
- import "./chunk-67SRVSPU.js";
9
+ } from "./chunk-S7B6MTXX.js";
10
+ import "./chunk-N5FSRC6H.js";
11
+ import "./chunk-XMMWKHNY.js";
12
12
  import "./chunk-Y5E2WNWB.js";
13
13
  import "./chunk-ZVVMGPBJ.js";
14
14
  export {
@@ -0,0 +1,250 @@
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-QQF7RDLR.js";
7
+ import "./chunk-76C5SSMR.js";
8
+ import {
9
+ OPENAI_URL
10
+ } from "./chunk-INYO2QFW.js";
11
+ import "./chunk-3PEZWXKO.js";
12
+ import {
13
+ OPENAI_TRANSCRIBE_MODEL,
14
+ VAD,
15
+ filesPresent,
16
+ modelsDirectory,
17
+ vadPath
18
+ } from "./chunk-IULYECPC.js";
19
+ import "./chunk-UUQ3BH2Z.js";
20
+ import {
21
+ DEFAULT_RETRY,
22
+ backoffMs
23
+ } from "./chunk-N5FSRC6H.js";
24
+ import {
25
+ CliError
26
+ } from "./chunk-XMMWKHNY.js";
27
+ import "./chunk-Y5E2WNWB.js";
28
+ import {
29
+ __name
30
+ } from "./chunk-ZVVMGPBJ.js";
31
+
32
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/speech/openai.js
33
+ import { setTimeout as wait } from "node:timers/promises";
34
+
35
+ // node_modules/.pnpm/@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
36
+ var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
37
+ if (!header)
38
+ return void 0;
39
+ const trimmed = header.trim();
40
+ if (/^\d+$/.test(trimmed))
41
+ return Number(trimmed) * 1e3;
42
+ const at = Date.parse(trimmed);
43
+ if (Number.isNaN(at))
44
+ return void 0;
45
+ const delta = at - now().getTime();
46
+ return delta > 0 ? delta : void 0;
47
+ }, "parseRetryAfter");
48
+ var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
49
+ if (!header)
50
+ return void 0;
51
+ const seconds = Number(header.trim());
52
+ if (!Number.isFinite(seconds))
53
+ return void 0;
54
+ const delta = seconds * 1e3 - now().getTime();
55
+ return delta > 0 ? delta : void 0;
56
+ }, "parseRateLimitReset");
57
+ var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
58
+
59
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/speech/wav.js
60
+ var encodeWav = /* @__PURE__ */ __name((samples, sampleRate = 16e3) => {
61
+ const bytes = Buffer.alloc(44 + samples.length * 2);
62
+ bytes.write("RIFF", 0, "ascii");
63
+ bytes.writeUInt32LE(bytes.length - 8, 4);
64
+ bytes.write("WAVEfmt ", 8, "ascii");
65
+ bytes.writeUInt32LE(16, 16);
66
+ bytes.writeUInt16LE(1, 20);
67
+ bytes.writeUInt16LE(1, 22);
68
+ bytes.writeUInt32LE(sampleRate, 24);
69
+ bytes.writeUInt32LE(sampleRate * 2, 28);
70
+ bytes.writeUInt16LE(2, 32);
71
+ bytes.writeUInt16LE(16, 34);
72
+ bytes.write("data", 36, "ascii");
73
+ bytes.writeUInt32LE(samples.length * 2, 40);
74
+ samples.forEach((sample, index) => {
75
+ bytes.writeInt16LE(Math.round(Math.max(-1, Math.min(1, sample || 0)) * 32767), 44 + index * 2);
76
+ });
77
+ return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.length);
78
+ }, "encodeWav");
79
+
80
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/speech/openai.js
81
+ var LONGEST_REQUEST_SECONDS = 600;
82
+ var JOINED_SECONDS = 0.2;
83
+ var PAD_SECONDS = 0.2;
84
+ var LEAD = SAMPLE_RATE / 2;
85
+ var EXHAUSTED = /* @__PURE__ */ new Set([
86
+ "insufficient_quota",
87
+ "credit_balance_exhausted",
88
+ "organization_spend_limit_exceeded",
89
+ "project_spend_limit_exceeded",
90
+ "organization_usage_limit_exceeded"
91
+ ]);
92
+ var RETRY = { ...DEFAULT_RETRY, retries: 4 };
93
+ var interrupted = /* @__PURE__ */ __name((signal) => {
94
+ if (!signal?.aborted)
95
+ return;
96
+ if (signal.reason instanceof CliError)
97
+ throw signal.reason;
98
+ const timeout = signal.reason instanceof Error && signal.reason.name === "TimeoutError";
99
+ throw new CliError(timeout ? "timeout" : "cancelled", "the transcription was interrupted");
100
+ }, "interrupted");
101
+ var sleeping = /* @__PURE__ */ __name((ms, signal) => wait(ms, void 0, signal ? { signal } : {}).then(() => void 0, (error) => {
102
+ interrupted(signal);
103
+ throw error;
104
+ }), "sleeping");
105
+ var formOf = /* @__PURE__ */ __name((wav, options) => {
106
+ const form = new FormData();
107
+ form.append("file", new Blob([wav], { type: "audio/wav" }), "audio.wav");
108
+ form.append("model", options.model ?? OPENAI_TRANSCRIBE_MODEL);
109
+ for (const language of options.languages ?? [])
110
+ form.append("languages[]", language);
111
+ for (const keyword of options.keywords ?? [])
112
+ form.append("keywords[]", keyword);
113
+ if (options.prompt)
114
+ form.append("prompt", options.prompt);
115
+ return form;
116
+ }, "formOf");
117
+ var safe = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[\w.-]{1,64}$/.test(value) ? value : void 0, "safe");
118
+ var failureOf = /* @__PURE__ */ __name(async (response) => {
119
+ try {
120
+ const body = await response.json();
121
+ const code = safe(body.error?.code);
122
+ const type = safe(body.error?.type);
123
+ return { ...code ? { code } : {}, ...type ? { type } : {} };
124
+ } catch {
125
+ return {};
126
+ }
127
+ }, "failureOf");
128
+ var send = /* @__PURE__ */ __name(async (wav, options) => {
129
+ const post = options.fetch ?? fetch;
130
+ const retry = options.retry ?? RETRY;
131
+ const sleep = options.sleep ?? sleeping;
132
+ const random = options.random ?? Math.random;
133
+ const url = `${(options.baseUrl ?? OPENAI_URL).replace(/\/+$/, "")}/audio/transcriptions`;
134
+ for (let attempt = 1; ; attempt++) {
135
+ interrupted(options.signal);
136
+ let response;
137
+ try {
138
+ response = await post(url, {
139
+ method: "POST",
140
+ headers: { authorization: `Bearer ${options.apiKey}` },
141
+ body: formOf(wav, options),
142
+ ...options.signal ? { signal: options.signal } : {}
143
+ });
144
+ } catch {
145
+ interrupted(options.signal);
146
+ if (attempt > retry.retries)
147
+ throw new CliError("network_error", "OpenAI could not be reached", { reason: "network.failed" });
148
+ await sleep(backoffMs(attempt, retry, random), options.signal);
149
+ continue;
150
+ }
151
+ if (response.ok) {
152
+ const body = await response.json().catch(() => interrupted(options.signal));
153
+ if (typeof body?.text !== "string")
154
+ throw new CliError("invalid_response", "OpenAI answered without a transcript", {
155
+ reason: "provider.invalid-response"
156
+ });
157
+ return body.text.trim();
158
+ }
159
+ const { code, type } = await failureOf(response);
160
+ const status = response.status;
161
+ const said = `HTTP ${status}${code ? `, ${code}` : type ? `, ${type}` : ""}`;
162
+ if (status === 401)
163
+ throw new CliError("authentication_error", `OpenAI refused the key (${said}) \u2014 set it again with \`models keys set openai\``, { reason: "auth.failed" });
164
+ if (status === 403)
165
+ throw new CliError("permission_error", `OpenAI refused the request (${said}) \u2014 it answers this when the country or region is not supported, or the key's project may not use the model`, { reason: "access.denied" });
166
+ if (status === 413)
167
+ throw new CliError("validation_error", `OpenAI refused the audio as too large (${said})`, {
168
+ reason: "transcription.too-large"
169
+ });
170
+ if (EXHAUSTED.has(code ?? "") || EXHAUSTED.has(type ?? ""))
171
+ throw new CliError("permission_error", `OpenAI refused: the account's credit, spend limit or usage limit is used up (${said}) \u2014 see the billing page`, { reason: "transcription.quota-exhausted" });
172
+ const again = status === 408 || status === 429 || status >= 500;
173
+ const asked = providerWaitMs(response.headers, () => /* @__PURE__ */ new Date());
174
+ if (again && attempt <= retry.retries && (asked === void 0 || asked <= retry.maxRetryAfterMs)) {
175
+ await sleep(asked ?? backoffMs(attempt, retry, random), options.signal);
176
+ continue;
177
+ }
178
+ if (status === 429)
179
+ throw new CliError("rate_limited", `OpenAI answered ${said}`, {
180
+ reason: "provider.rate-limited",
181
+ ...asked === void 0 ? {} : { retry_after_ms: asked }
182
+ });
183
+ if (status >= 500)
184
+ throw new CliError([502, 503, 504].includes(status) ? "provider_unavailable" : "provider_error", `OpenAI answered ${said}`, { reason: [502, 503, 504].includes(status) ? "provider.unavailable" : "provider.refused" });
185
+ throw new CliError("provider_error", `OpenAI answered ${said}`, { reason: "provider.refused" });
186
+ }
187
+ }, "send");
188
+ var piecesOf = /* @__PURE__ */ __name((spans, limit) => {
189
+ const pieces = [];
190
+ for (const span of spans) {
191
+ const last = pieces.at(-1);
192
+ const joined = last !== void 0 && span.start - last.end < JOINED_SECONDS;
193
+ const fits = last !== void 0 && limit !== void 0 && span.end - last.start <= limit;
194
+ if (last && (fits || joined && span.end - last.start <= LONGEST_REQUEST_SECONDS))
195
+ last.end = span.end;
196
+ else
197
+ pieces.push({ start: span.start, end: span.end });
198
+ }
199
+ return pieces;
200
+ }, "piecesOf");
201
+ var openCutter = /* @__PURE__ */ __name(async (vadModel) => {
202
+ const { openSpeechCutter } = await import("./recognize-AVFDJAIL.js");
203
+ return openSpeechCutter(vadModel);
204
+ }, "openCutter");
205
+ var checkKeywords = /* @__PURE__ */ __name((keywords = []) => {
206
+ const bad = keywords.find((keyword) => typeof keyword !== "string" || !keyword.trim() || /[<>\r\n]/.test(keyword));
207
+ if (bad !== void 0)
208
+ throw new CliError("validation_error", "a keyword must be a non-empty single line without < or > \u2014 OpenAI refuses the whole request otherwise");
209
+ }, "checkKeywords");
210
+ var transcribeOpenAI = /* @__PURE__ */ __name(async (audio, options) => {
211
+ if (!options.apiKey)
212
+ throw new CliError("authentication_error", "no OpenAI key \u2014 `models keys set openai`, or OPENAI_API_KEY", {
213
+ reason: "transcription.no-key"
214
+ });
215
+ checkKeywords(options.keywords);
216
+ interrupted(options.signal);
217
+ const pcm = toModelRate(audio.samples, audio.rate);
218
+ const duration = (pcm.length - LEAD) / SAMPLE_RATE;
219
+ if (options.bundle && duration <= LONGEST_REQUEST_SECONDS) {
220
+ const text = await send(encodeWav(pcm.subarray(LEAD)), options);
221
+ return text ? [{ start: 0, end: duration, text }] : [];
222
+ }
223
+ const vadModel = options.vadModel ?? vadPath(modelsDirectory(options.env));
224
+ if (!options.cutter && !filesPresent([[VAD, vadModel]]))
225
+ 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" });
226
+ const cutter = await (options.cutter ?? openCutter)(vadModel);
227
+ let spans;
228
+ try {
229
+ spans = cutter.cut(pcm);
230
+ } finally {
231
+ cutter.free();
232
+ }
233
+ const pieces = piecesOf(spans, options.bundle ? LONGEST_REQUEST_SECONDS : void 0);
234
+ const heard = [];
235
+ for (const [index, piece] of pieces.entries()) {
236
+ const end = Math.min(piece.end, duration);
237
+ const from = Math.max(piece.start - PAD_SECONDS, pieces[index - 1]?.end ?? 0);
238
+ const to = Math.min(end + PAD_SECONDS, pieces[index + 1]?.start ?? duration);
239
+ const samples = pcm.subarray(LEAD + Math.floor(from * SAMPLE_RATE), LEAD + Math.ceil(to * SAMPLE_RATE));
240
+ const text = await send(encodeWav(samples), options);
241
+ if (text)
242
+ heard.push({ start: Math.min(piece.start, end), end, text });
243
+ }
244
+ return heard;
245
+ }, "transcribeOpenAI");
246
+ export {
247
+ LONGEST_REQUEST_SECONDS,
248
+ piecesOf,
249
+ transcribeOpenAI
250
+ };
@@ -5,7 +5,7 @@ import {
5
5
  __name
6
6
  } from "./chunk-ZVVMGPBJ.js";
7
7
 
8
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._95f40a748301e48ce1af109feea5b293/node_modules/@wirecat/cli-core/dist/embeddings/process.js
8
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/embeddings/process.js
9
9
  import { spawn } from "node:child_process";
10
10
  import { createInterface } from "node:readline";
11
11
  import { fileURLToPath } from "node:url";
@@ -13,7 +13,7 @@ import {
13
13
  proxiedFetch,
14
14
  proxySecrets,
15
15
  resolveSettings
16
- } from "./chunk-REI5TPS3.js";
16
+ } from "./chunk-IGIPIO4J.js";
17
17
  import {
18
18
  AGENTS,
19
19
  MEMO_SCENARIOS,
@@ -65,27 +65,28 @@ import {
65
65
  topicsCommand,
66
66
  upgradeCommand,
67
67
  watchCommand
68
- } from "./chunk-DNOJKQXQ.js";
69
- import "./chunk-YJ6GFFEE.js";
68
+ } from "./chunk-2ILQYCBY.js";
69
+ import "./chunk-BESIMQ5U.js";
70
70
  import {
71
71
  parseProxy,
72
72
  proxyLabel
73
- } from "./chunk-FG2QTYEF.js";
74
- import "./chunk-B7TFWNKJ.js";
75
- import "./chunk-KZPZFPGB.js";
73
+ } from "./chunk-NAVNCM5K.js";
74
+ import "./chunk-VYR2IIWW.js";
75
+ import "./chunk-MF6NKU3Z.js";
76
76
  import {
77
77
  installSkill
78
- } from "./chunk-4RDMNNVO.js";
79
- import "./chunk-CVWF3BFK.js";
80
- import "./chunk-CZANI3DM.js";
81
- import "./chunk-26PWIQPP.js";
82
- import "./chunk-3GXKJKIC.js";
78
+ } from "./chunk-UIPBAT2T.js";
79
+ import "./chunk-5SUFMBU5.js";
80
+ import "./chunk-SH63Q4QR.js";
81
+ import "./chunk-XJVGCCQE.js";
82
+ import "./chunk-76C5SSMR.js";
83
+ import "./chunk-BZIZLEJN.js";
83
84
  import {
84
85
  inSection
85
- } from "./chunk-OB5PPPXH.js";
86
+ } from "./chunk-P57R2P75.js";
86
87
  import "./chunk-2ABQZVK4.js";
87
- import "./chunk-5P27JGGA.js";
88
- import "./chunk-LY2LFJMU.js";
88
+ import "./chunk-P5ILJ7MN.js";
89
+ import "./chunk-4R4AH6FM.js";
89
90
  import {
90
91
  Argument,
91
92
  Command,
@@ -107,48 +108,48 @@ import {
107
108
  runtime,
108
109
  secretInputOf,
109
110
  withDeadline
110
- } from "./chunk-77OOX2OE.js";
111
- import "./chunk-WKSLGPZQ.js";
112
- import "./chunk-DUWTG2GE.js";
113
- import "./chunk-BOSMBW4I.js";
111
+ } from "./chunk-DZVYGBZB.js";
112
+ import "./chunk-RD2NLJSU.js";
113
+ import "./chunk-CVLDXFRP.js";
114
+ import "./chunk-C3RX3UOE.js";
114
115
  import {
115
116
  installerOf,
116
117
  latestVersion,
117
118
  runUpdate,
118
119
  updateNotice
119
- } from "./chunk-VMU4SGCE.js";
120
- import "./chunk-MFS52LTZ.js";
121
- import "./chunk-SONKULUF.js";
122
- import "./chunk-R5YOKYTE.js";
123
- import "./chunk-PCMW3PW6.js";
120
+ } from "./chunk-VFVMB3NV.js";
121
+ import "./chunk-DLAFGSTN.js";
122
+ import "./chunk-P55L4S6N.js";
123
+ import "./chunk-ZUOS7QUB.js";
124
+ import "./chunk-7T7ILNCU.js";
124
125
  import {
125
126
  TG,
126
127
  VERSION
127
- } from "./chunk-TVA3NXXO.js";
128
- import "./chunk-WUF64WOG.js";
128
+ } from "./chunk-ZFMS5G4H.js";
129
+ import "./chunk-CHI6D4D6.js";
129
130
  import {
130
131
  servingProfiles
131
- } from "./chunk-BT6PWDM6.js";
132
- import "./chunk-PQHYM2XC.js";
133
- import "./chunk-ZYBDAZFO.js";
134
- import "./chunk-6QTUYMGX.js";
135
- import "./chunk-LYLGLFWY.js";
136
- import "./chunk-EWL3ZFOI.js";
137
- import "./chunk-3HYDKCXB.js";
138
- import "./chunk-QVIT6SQ5.js";
132
+ } from "./chunk-TMXNMO66.js";
133
+ import "./chunk-25VC6U3A.js";
134
+ import "./chunk-AD3QPYI3.js";
135
+ import "./chunk-KHKC236O.js";
136
+ import "./chunk-INYO2QFW.js";
137
+ import "./chunk-3PEZWXKO.js";
138
+ import "./chunk-IULYECPC.js";
139
+ import "./chunk-M62LF3QE.js";
139
140
  import {
140
141
  timezoneOf
141
- } from "./chunk-XZXOGHU5.js";
142
- import "./chunk-3562DVQ7.js";
143
- import "./chunk-ON67U6WV.js";
144
- import "./chunk-O5EHUB2V.js";
145
- import "./chunk-EBB7RFCW.js";
146
- import "./chunk-NCXCBVHO.js";
147
- import "./chunk-VK2YLSK7.js";
142
+ } from "./chunk-DO33KAMM.js";
143
+ import "./chunk-YYOIULA2.js";
144
+ import "./chunk-AGVKIJB7.js";
145
+ import "./chunk-62EDJKGP.js";
146
+ import "./chunk-UUQ3BH2Z.js";
147
+ import "./chunk-S7B6MTXX.js";
148
+ import "./chunk-ZMZKZL3Y.js";
148
149
  import {
149
150
  readSecret
150
- } from "./chunk-D6DBVPES.js";
151
- import "./chunk-AOUB2QFP.js";
151
+ } from "./chunk-ZHP44EML.js";
152
+ import "./chunk-WHYS6OSG.js";
152
153
  import {
153
154
  configFilePath,
154
155
  exitCodeFor,
@@ -157,11 +158,11 @@ import {
157
158
  renderPretty,
158
159
  resolvePaths,
159
160
  singleLine
160
- } from "./chunk-T4SDOYPY.js";
161
+ } from "./chunk-N5FSRC6H.js";
161
162
  import {
162
163
  CliError,
163
164
  isCliError
164
- } from "./chunk-67SRVSPU.js";
165
+ } from "./chunk-XMMWKHNY.js";
165
166
  import "./chunk-Y5E2WNWB.js";
166
167
  import {
167
168
  __name
@@ -236,7 +237,7 @@ var withProxySecrets = /* @__PURE__ */ __name((config) => {
236
237
  throw new CliError("validation_error", "a proxy password or MTProxy secret never goes on the command line \u2014 run `tg config set proxy -` and paste the URL");
237
238
  if (proxy.kind === "mtproxy" && proxy.secret === void 0)
238
239
  throw new CliError("validation_error", "an MTProxy link needs its secret \u2014 run `tg config set proxy -` and paste the whole link");
239
- const { checkProxy } = await import("./proxy-transport-YSBYG26I.js");
240
+ const { checkProxy } = await import("./proxy-transport-FWGKTYBL.js");
240
241
  asValidation(() => checkProxy(proxy));
241
242
  const label = proxyLabel(proxy);
242
243
  action.processedArgs[1] = label;
@@ -719,7 +720,7 @@ import { accessSync, constants, existsSync as existsSync2, mkdirSync } from "nod
719
720
  import { join } from "node:path";
720
721
  import { fileURLToPath as fileURLToPath2 } from "node:url";
721
722
 
722
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._95f40a748301e48ce1af109feea5b293/node_modules/@wirecat/cli-core/dist/update/index.js
723
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/update/index.js
723
724
  import { realpathSync } from "node:fs";
724
725
  import { fileURLToPath } from "node:url";
725
726
  var QUIET_WORDS = [
@@ -1036,7 +1037,7 @@ var definition = {
1036
1037
  };
1037
1038
  var run2 = /* @__PURE__ */ __name(async (argv, environment = {}) => {
1038
1039
  if (!botApi && needsBotApi(argv, environment.env ?? process.env))
1039
- useBotApi((await import("./bot-api-2PAH2JZ3.js")).telegramBotApiCommand);
1040
+ useBotApi((await import("./bot-api-TQYRNYJQ.js")).telegramBotApiCommand);
1040
1041
  const notice = updateNotice2(argv, {
1041
1042
  ...environment.tty === void 0 ? {} : { tty: environment.tty },
1042
1043
  ...environment.update ? { environment: environment.update } : {},
@@ -2,10 +2,10 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  readSecret
5
- } from "./chunk-D6DBVPES.js";
6
- import "./chunk-AOUB2QFP.js";
7
- import "./chunk-T4SDOYPY.js";
8
- import "./chunk-67SRVSPU.js";
5
+ } from "./chunk-ZHP44EML.js";
6
+ import "./chunk-WHYS6OSG.js";
7
+ import "./chunk-N5FSRC6H.js";
8
+ import "./chunk-XMMWKHNY.js";
9
9
  import "./chunk-Y5E2WNWB.js";
10
10
  import "./chunk-ZVVMGPBJ.js";
11
11
  export {
@@ -4,10 +4,10 @@ import {
4
4
  checkProxy,
5
5
  proxiedTransport,
6
6
  proxyFailure
7
- } from "./chunk-WAGDZB62.js";
8
- import "./chunk-FG2QTYEF.js";
9
- import "./chunk-T4SDOYPY.js";
10
- import "./chunk-67SRVSPU.js";
7
+ } from "./chunk-GUFM5RLW.js";
8
+ import "./chunk-NAVNCM5K.js";
9
+ import "./chunk-N5FSRC6H.js";
10
+ import "./chunk-XMMWKHNY.js";
11
11
  import "./chunk-Y5E2WNWB.js";
12
12
  import "./chunk-ZVVMGPBJ.js";
13
13
  export {
@@ -6,10 +6,11 @@ import {
6
6
  detector,
7
7
  loadSherpa,
8
8
  openRecognizer,
9
+ openSpeechCutter,
9
10
  toModelRate
10
- } from "./chunk-AS2BVZU3.js";
11
- import "./chunk-T4SDOYPY.js";
12
- import "./chunk-67SRVSPU.js";
11
+ } from "./chunk-QQF7RDLR.js";
12
+ import "./chunk-N5FSRC6H.js";
13
+ import "./chunk-XMMWKHNY.js";
13
14
  import "./chunk-Y5E2WNWB.js";
14
15
  import "./chunk-ZVVMGPBJ.js";
15
16
  export {
@@ -18,5 +19,6 @@ export {
18
19
  detector,
19
20
  loadSherpa,
20
21
  openRecognizer,
22
+ openSpeechCutter,
21
23
  toModelRate
22
24
  };
@@ -8,12 +8,12 @@ import {
8
8
  openRemote,
9
9
  remoteKey,
10
10
  remoteModel
11
- } from "./chunk-LYLGLFWY.js";
12
- import "./chunk-EWL3ZFOI.js";
13
- import "./chunk-3HYDKCXB.js";
14
- import "./chunk-EBB7RFCW.js";
15
- import "./chunk-T4SDOYPY.js";
16
- import "./chunk-67SRVSPU.js";
11
+ } from "./chunk-INYO2QFW.js";
12
+ import "./chunk-3PEZWXKO.js";
13
+ import "./chunk-IULYECPC.js";
14
+ import "./chunk-UUQ3BH2Z.js";
15
+ import "./chunk-N5FSRC6H.js";
16
+ import "./chunk-XMMWKHNY.js";
17
17
  import "./chunk-Y5E2WNWB.js";
18
18
  import "./chunk-ZVVMGPBJ.js";
19
19
  export {
@@ -4,17 +4,17 @@ import {
4
4
  defaultThreads,
5
5
  loadModel,
6
6
  truncated
7
- } from "./chunk-EWL3ZFOI.js";
8
- import "./chunk-3HYDKCXB.js";
9
- import "./chunk-EBB7RFCW.js";
10
- import "./chunk-T4SDOYPY.js";
11
- import "./chunk-67SRVSPU.js";
7
+ } from "./chunk-3PEZWXKO.js";
8
+ import "./chunk-IULYECPC.js";
9
+ import "./chunk-UUQ3BH2Z.js";
10
+ import "./chunk-N5FSRC6H.js";
11
+ import "./chunk-XMMWKHNY.js";
12
12
  import "./chunk-Y5E2WNWB.js";
13
13
  import {
14
14
  __name
15
15
  } from "./chunk-ZVVMGPBJ.js";
16
16
 
17
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._95f40a748301e48ce1af109feea5b293/node_modules/@wirecat/cli-core/dist/embeddings/rerank.js
17
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/embeddings/rerank.js
18
18
  var openReranker = /* @__PURE__ */ __name(async (model, directory, { threads = defaultThreads() } = {}) => {
19
19
  const { ort, tokenizer, session } = await loadModel(model, directory, threads);
20
20
  const typeIds = session.inputNames.includes("token_type_ids");
@@ -2,10 +2,10 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  listen
5
- } from "./chunk-B7TFWNKJ.js";
5
+ } from "./chunk-VYR2IIWW.js";
6
6
  import {
7
7
  ownerLogin
8
- } from "./chunk-WEDWIXIC.js";
8
+ } from "./chunk-N56WXUCW.js";
9
9
  import {
10
10
  WebStandardStreamableHTTPServerTransport,
11
11
  createMcpHandler,
@@ -20,19 +20,19 @@ import {
20
20
  calledTools,
21
21
  httpActivityFile,
22
22
  httpLock
23
- } from "./chunk-WUF64WOG.js";
24
- import "./chunk-BT6PWDM6.js";
25
- import "./chunk-PQHYM2XC.js";
26
- import "./chunk-T4SDOYPY.js";
23
+ } from "./chunk-CHI6D4D6.js";
24
+ import "./chunk-TMXNMO66.js";
25
+ import "./chunk-25VC6U3A.js";
26
+ import "./chunk-N5FSRC6H.js";
27
27
  import {
28
28
  CliError
29
- } from "./chunk-67SRVSPU.js";
29
+ } from "./chunk-XMMWKHNY.js";
30
30
  import "./chunk-Y5E2WNWB.js";
31
31
  import {
32
32
  __name
33
33
  } from "./chunk-ZVVMGPBJ.js";
34
34
 
35
- // node_modules/.pnpm/@wirecat+cli-core@0.491.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._95f40a748301e48ce1af109feea5b293/node_modules/@wirecat/cli-core/dist/mcp/http/serve.js
35
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/mcp/http/serve.js
36
36
  import { randomUUID } from "node:crypto";
37
37
  var MCP_PATH = "/mcp";
38
38
  var AS_METADATA = "/.well-known/oauth-authorization-server";