@wirecat/tg-cli 0.117.0 → 0.119.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 (137) hide show
  1. package/contracts/wirecat.json +7621 -0
  2. package/dist/bin/tg.js +2 -2
  3. package/dist/bot/transport.d.ts.map +1 -1
  4. package/dist/bot/transport.js +15 -8
  5. package/dist/bot/transport.js.map +1 -1
  6. package/dist/bundle/{adapter-VNQ72MBK.js → adapter-NEQQOANM.js} +47 -48
  7. package/dist/bundle/{all-profiles-3W2UQTCK.js → all-profiles-QFT46FTF.js} +10 -10
  8. package/dist/bundle/{anthropic-DFUW2KTG.js → anthropic-UJ4RYCWU.js} +10 -8
  9. package/dist/bundle/{app-server-5XJIMLHB.js → app-server-NE3EL5IK.js} +43 -43
  10. package/dist/bundle/{bot-api-HRRBF3W6.js → bot-api-D4H5SCP5.js} +49 -49
  11. package/dist/bundle/{bot-history-GBH5XE4N.js → bot-history-KF2PUMWA.js} +18 -18
  12. package/dist/bundle/{bun-ZMOYGG6F.js → bun-F7MH5YKA.js} +2 -2
  13. package/dist/bundle/{bun-sqlite-6FZFMA7K.js → bun-sqlite-FYDJXUHF.js} +5 -5
  14. package/dist/bundle/{chunk-HZZGOLGP.js → chunk-23JGV5FQ.js} +11 -11
  15. package/dist/bundle/{chunk-PTIB7NEE.js → chunk-2BAJ6ORN.js} +1 -1
  16. package/dist/bundle/{chunk-L5WNE4WS.js → chunk-3EQ7USKJ.js} +2 -2
  17. package/dist/bundle/{chunk-YIXXH74F.js → chunk-3K65KTXD.js} +16 -3
  18. package/dist/bundle/{chunk-66FZBLRJ.js → chunk-4AACB23H.js} +13 -13
  19. package/dist/bundle/{chunk-NUCDEOFC.js → chunk-5EHJWIW4.js} +2 -2
  20. package/dist/bundle/{chunk-VW6BF6M7.js → chunk-5FEEFXJA.js} +1 -1
  21. package/dist/bundle/{chunk-HWYSRB64.js → chunk-65BWMPCI.js} +2 -2
  22. package/dist/bundle/{chunk-Q7O4CQDO.js → chunk-6ERQJRL2.js} +2 -2
  23. package/dist/bundle/{chunk-3GRX7WP6.js → chunk-6K5R3YPN.js} +2 -2
  24. package/dist/bundle/{chunk-KVTLT4V7.js → chunk-6OE5I3PR.js} +6 -6
  25. package/dist/bundle/{chunk-B2YPB5AE.js → chunk-72QLHHSO.js} +93 -29
  26. package/dist/bundle/{chunk-FEKXHILZ.js → chunk-7C6POLLO.js} +1 -1
  27. package/dist/bundle/{chunk-F6KBVIJP.js → chunk-7VUNJDYU.js} +22 -14
  28. package/dist/bundle/{chunk-EZTYJ43A.js → chunk-BXIPT2BO.js} +1 -1
  29. package/dist/bundle/{chunk-GFHNQBD2.js → chunk-CIDFV3IT.js} +1 -1
  30. package/dist/bundle/{chunk-C6TUVV7E.js → chunk-CX2WCEQU.js} +552 -222
  31. package/dist/bundle/{chunk-UYK5AXSW.js → chunk-D4Y2KL5V.js} +4 -4
  32. package/dist/bundle/{chunk-EL6I4WTB.js → chunk-D6YTBJY6.js} +1 -1
  33. package/dist/bundle/{chunk-X3CD475M.js → chunk-DQELQ7BL.js} +419 -198
  34. package/dist/bundle/{chunk-4JDGN6OD.js → chunk-F223KYWG.js} +1 -1
  35. package/dist/bundle/{chunk-RDH2QBUE.js → chunk-FJKP6MMP.js} +5 -3
  36. package/dist/bundle/{chunk-2452HCIV.js → chunk-FQ3C6DFV.js} +3 -3
  37. package/dist/bundle/{chunk-7Y3RUEVY.js → chunk-FQZSS3AB.js} +6 -6
  38. package/dist/bundle/{chunk-V47NPSSV.js → chunk-FRW3CWC7.js} +31 -29
  39. package/dist/bundle/{chunk-AG6HWPQP.js → chunk-G3MQOH6Z.js} +3 -3
  40. package/dist/bundle/{chunk-RDSLSV4M.js → chunk-HGMMRT4G.js} +2 -2
  41. package/dist/bundle/{chunk-SQXB5ZUZ.js → chunk-HPQQ76WF.js} +23 -5
  42. package/dist/bundle/{chunk-3RJYLN5V.js → chunk-HV5YYAJX.js} +158 -20
  43. package/dist/bundle/{chunk-3MQOLYAN.js → chunk-IAGX5VFL.js} +4 -4
  44. package/dist/bundle/{chunk-TFBHDIGY.js → chunk-JKKEMVW3.js} +18 -4
  45. package/dist/bundle/{chunk-P3ASN72F.js → chunk-KBHK5UGL.js} +1 -1
  46. package/dist/bundle/{chunk-EPCFXKTX.js → chunk-KC4MQRAB.js} +34 -8
  47. package/dist/bundle/{chunk-VMCQGZIA.js → chunk-L33G5ARH.js} +2801 -718
  48. package/dist/bundle/{chunk-V2T7NYNU.js → chunk-MDLSI3EN.js} +25 -23
  49. package/dist/bundle/chunk-NDSRND3E.js +138 -0
  50. package/dist/bundle/{chunk-HORGORHK.js → chunk-OG2CG2GS.js} +12 -12
  51. package/dist/bundle/{chunk-ZPILMEFY.js → chunk-QD27C3BG.js} +8 -21
  52. package/dist/bundle/{chunk-QOGYHU3Q.js → chunk-QG5U6HCI.js} +61 -21
  53. package/dist/bundle/{chunk-TG6ZYL4B.js → chunk-QQ3QZFFD.js} +8 -8
  54. package/dist/bundle/{chunk-56Q5JV3Z.js → chunk-QTFXYR5W.js} +24 -2
  55. package/dist/bundle/{chunk-FAHHERJ7.js → chunk-RGU2G3KL.js} +4 -4
  56. package/dist/bundle/{chunk-Z4QKLHJW.js → chunk-ROOUBFUW.js} +10148 -3906
  57. package/dist/bundle/{chunk-MLHKQDUN.js → chunk-RUNFFBJU.js} +872 -562
  58. package/dist/bundle/{chunk-G7B5UIE7.js → chunk-S3HAFJVC.js} +37 -11
  59. package/dist/bundle/{chunk-BXTDAGM4.js → chunk-SMHLQEE2.js} +2 -2
  60. package/dist/bundle/{chunk-JWIUK3SK.js → chunk-TEZKCH5B.js} +2 -2
  61. package/dist/bundle/{chunk-VRDVXXXD.js → chunk-TKHEVAEG.js} +9 -8
  62. package/dist/bundle/{chunk-MP7M6FFU.js → chunk-TT4CIXVH.js} +6 -6
  63. package/dist/bundle/{chunk-M7V5XRM6.js → chunk-UBCLVM7C.js} +3 -3
  64. package/dist/bundle/{chunk-YHZFGUAP.js → chunk-V5Z2JO6X.js} +19 -19
  65. package/dist/bundle/{chunk-6GFUL4OU.js → chunk-W2BIBPRU.js} +237 -38
  66. package/dist/bundle/{chunk-6HRN7BW6.js → chunk-X5PDWCG7.js} +1 -1
  67. package/dist/bundle/{chunk-AUBRELCM.js → chunk-XDMJVWWR.js} +3 -3
  68. package/dist/bundle/{chunk-EA2PGDER.js → chunk-XM3P7LLT.js} +2 -2
  69. package/dist/bundle/{chunk-UGPZCNYC.js → chunk-YMWPRHXG.js} +1411 -809
  70. package/dist/bundle/{chunk-2XLKZL6K.js → chunk-Z4CGZAFQ.js} +65 -31
  71. package/dist/bundle/{chunk-XW5C4TI7.js → chunk-ZEQ7ONPZ.js} +47 -1
  72. package/dist/bundle/command-contract-7TGMZRBE.js +33 -0
  73. package/dist/bundle/{decode-YMSOY2AY.js → decode-5N4ERCHC.js} +5 -5
  74. package/dist/bundle/{dispatch-OP27MWX5.js → dispatch-TBGXBDHE.js} +10 -10
  75. package/dist/bundle/{echarts-7XS55TQY.js → echarts-YDEBAMXT.js} +2 -2
  76. package/dist/bundle/{embed-QTOE7NN3.js → embed-T7H62XFR.js} +6 -6
  77. package/dist/bundle/{embedder-KBBRYSNH.js → embedder-AW3O2TR3.js} +9 -9
  78. package/dist/bundle/{entry-HGEUYYMX.js → entry-L2LJ2VPY.js} +7 -7
  79. package/dist/bundle/{failure-4JUQFXJT.js → failure-AWHPW2HE.js} +2 -2
  80. package/dist/bundle/{first-run-CSGMEJXY.js → first-run-6PBZSRZU.js} +11 -11
  81. package/dist/bundle/first-screen-UKCD7D2R.js +31 -0
  82. package/dist/bundle/{instructions-S6ZXCTFH.js → instructions-C3NJERO7.js} +1 -1
  83. package/dist/bundle/{mcp-M4QN2E7R.js → mcp-CWLASTLV.js} +2 -2
  84. package/dist/bundle/{node-LCIUWXXG.js → node-P3CIIYWU.js} +2 -2
  85. package/dist/bundle/{node-sqlite-HL4WY4N2.js → node-sqlite-YVHMNRVA.js} +6 -6
  86. package/dist/bundle/{oauth-U4KIMDKG.js → oauth-5OQYA2SV.js} +7 -7
  87. package/dist/bundle/{open-EH7OS7M7.js → open-YGWUVSU7.js} +5 -5
  88. package/dist/bundle/{openai-W5TB3NA5.js → openai-U45JBQ6F.js} +16 -37
  89. package/dist/bundle/{process-3CVLTCTA.js → process-DCYX5EDG.js} +1 -1
  90. package/dist/bundle/{program-LOIZTK2P.js → program-UZBFH2EZ.js} +55 -52
  91. package/dist/bundle/{prompt-IDNH7N3W.js → prompt-HPVTPTFI.js} +7 -5
  92. package/dist/bundle/{proxy-transport-4DPZB2W2.js → proxy-transport-D7MCHGSV.js} +5 -5
  93. package/dist/bundle/{recognize-G5EWYXIF.js → recognize-IJCPFJ76.js} +4 -4
  94. package/dist/bundle/{remote-4XTBZVZD.js → remote-MWDYQWFW.js} +7 -7
  95. package/dist/bundle/{rerank-OWSTDLZN.js → rerank-SXG64475.js} +7 -7
  96. package/dist/bundle/{serve-YCPSEWP3.js → serve-KJQENHEH.js} +9 -9
  97. package/dist/bundle/{server-ODG4A2KK.js → server-MXVXZWN6.js} +35 -35
  98. package/dist/bundle/server-RTMCRKQF.js +60 -0
  99. package/dist/bundle/{state-OL2235G5.js → state-CKKJWH27.js} +6 -6
  100. package/dist/bundle/{store-5AACYNDM.js → store-R3BE4V56.js} +44 -13
  101. package/dist/bundle/store-maintenance-command-KDGBSBNU.js +49 -0
  102. package/dist/bundle/tg.js +38 -14
  103. package/dist/commands/account-removal.d.ts +3 -0
  104. package/dist/commands/account-removal.d.ts.map +1 -0
  105. package/dist/commands/account-removal.js +57 -0
  106. package/dist/commands/account-removal.js.map +1 -0
  107. package/dist/commands/context.d.ts.map +1 -1
  108. package/dist/commands/context.js +2 -0
  109. package/dist/commands/context.js.map +1 -1
  110. package/dist/http.d.ts +6 -0
  111. package/dist/http.d.ts.map +1 -0
  112. package/dist/http.js +8 -0
  113. package/dist/http.js.map +1 -0
  114. package/dist/identity.d.ts +4 -0
  115. package/dist/identity.d.ts.map +1 -1
  116. package/dist/identity.js +14 -0
  117. package/dist/identity.js.map +1 -1
  118. package/dist/telegram/map.d.ts.map +1 -1
  119. package/dist/telegram/map.js +3 -0
  120. package/dist/telegram/map.js.map +1 -1
  121. package/dist/telegram/registration.d.ts +1 -1
  122. package/dist/telegram/registration.d.ts.map +1 -1
  123. package/dist/telegram/registration.js +4 -1
  124. package/dist/telegram/registration.js.map +1 -1
  125. package/dist/version.d.ts +1 -1
  126. package/dist/version.js +1 -1
  127. package/dist/wcat.d.ts +3 -0
  128. package/dist/wcat.d.ts.map +1 -0
  129. package/dist/wcat.js +4 -0
  130. package/dist/wcat.js.map +1 -0
  131. package/package.json +7 -6
  132. package/dist/bundle/chunk-7NBUT62O.js +0 -33
  133. package/dist/bundle/command-contract-KMMHARMR.js +0 -33
  134. package/dist/bundle/first-screen-K2PBNJNE.js +0 -31
  135. package/dist/bundle/server-KELKX6S3.js +0 -60
  136. package/dist/bundle/store-maintenance-command-3J7WZYVN.js +0 -50
  137. /package/dist/bundle/{chunk-VOXIGICJ.js → chunk-DWX4DE2I.js} +0 -0
@@ -1,5 +1,8 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ hostFetch
5
+ } from "./chunk-NDSRND3E.js";
3
6
  import {
4
7
  ADMIN_RIGHTS,
5
8
  BotTokenStore,
@@ -13,45 +16,46 @@ import {
13
16
  privateFiles,
14
17
  providerRequest,
15
18
  withSqliteSidecars
16
- } from "./chunk-VMCQGZIA.js";
19
+ } from "./chunk-L33G5ARH.js";
17
20
  import {
18
21
  parseProxy,
19
22
  proxyAddress,
20
23
  proxyError,
21
24
  proxyLabel,
22
25
  proxySetting
23
- } from "./chunk-JWIUK3SK.js";
26
+ } from "./chunk-TEZKCH5B.js";
24
27
  import {
25
28
  messengerContext
26
- } from "./chunk-V2T7NYNU.js";
29
+ } from "./chunk-MDLSI3EN.js";
27
30
  import {
28
31
  uploadBlob
29
- } from "./chunk-UGPZCNYC.js";
32
+ } from "./chunk-YMWPRHXG.js";
30
33
  import {
31
34
  asFirstWord,
32
35
  currentAttempt,
33
36
  environmentOf,
34
37
  fromFile,
35
38
  settingsFor
36
- } from "./chunk-X3CD475M.js";
39
+ } from "./chunk-DQELQ7BL.js";
37
40
  import {
41
+ DESKTOP,
38
42
  TG
39
- } from "./chunk-YIXXH74F.js";
43
+ } from "./chunk-3K65KTXD.js";
40
44
  import {
41
45
  Credentials,
42
46
  pathsAreOverridden,
43
47
  resolvePaths
44
- } from "./chunk-YHZFGUAP.js";
48
+ } from "./chunk-V5Z2JO6X.js";
45
49
  import {
46
50
  optional
47
- } from "./chunk-EPCFXKTX.js";
51
+ } from "./chunk-KC4MQRAB.js";
48
52
  import {
49
53
  importFrom
50
54
  } from "./chunk-Y5E2WNWB.js";
51
55
  import {
52
56
  CliError,
53
57
  isCliError
54
- } from "./chunk-BXTDAGM4.js";
58
+ } from "./chunk-SMHLQEE2.js";
55
59
  import {
56
60
  __name
57
61
  } from "./chunk-ZVVMGPBJ.js";
@@ -61,7 +65,7 @@ var CONFIG = settingsFor(TG, { profile: { proxy: optional(proxySetting) } });
61
65
  var { resolveSettings, configuredProfiles, changeSetting } = CONFIG;
62
66
 
63
67
  // dist/commands/context.js
64
- import { existsSync } from "node:fs";
68
+ import { existsSync as existsSync2 } from "node:fs";
65
69
  import { dirname } from "node:path";
66
70
 
67
71
  // dist/paths.js
@@ -151,6 +155,55 @@ var resolveProxy = /* @__PURE__ */ __name((settings, { env = process.env, keyrin
151
155
  return { proxy: secret ? { ...proxy, secret } : proxy, from };
152
156
  }, "resolveProxy");
153
157
 
158
+ // dist/commands/account-removal.js
159
+ import { existsSync, rmSync } from "node:fs";
160
+ import { join as join2 } from "node:path";
161
+ var SUFFIXES = ["", "-wal", "-shm"];
162
+ var alreadyEnded = /* @__PURE__ */ __name((error) => error instanceof CliError && error.details?.reason === "login.revoked", "alreadyEnded");
163
+ var logOut = /* @__PURE__ */ __name(async (profile, sessionPath, context) => {
164
+ const { env, keyring } = context;
165
+ const credentials = apiCredentials({ profile, env, ...keyring ? { keyring } : {} }).read();
166
+ if (!credentials)
167
+ return false;
168
+ const settings = resolveSettings({ profile }, { env });
169
+ const through = resolveProxy(settings, {
170
+ env,
171
+ checks: checkWords("tg", profile),
172
+ ...keyring ? { keyring } : {}
173
+ });
174
+ const { TelegramAdapter } = await import("./adapter-NEQQOANM.js");
175
+ const adapter = await TelegramAdapter.open({ credentials, sessionPath, ...through ? { proxy: through.proxy } : {} });
176
+ try {
177
+ await adapter.logout();
178
+ return true;
179
+ } catch (error) {
180
+ if (alreadyEnded(error))
181
+ return true;
182
+ throw error;
183
+ } finally {
184
+ await adapter.close().catch(() => {
185
+ });
186
+ }
187
+ }, "logOut");
188
+ var TELEGRAM_REMOVAL = {
189
+ signOut: /* @__PURE__ */ __name(async (profile, context) => {
190
+ const sessionPath = sessionFile(profile, context.env);
191
+ if (!existsSync(sessionPath))
192
+ return { revoked: null, removed: [] };
193
+ const revoked = context.mayRevoke ? await logOut(profile, sessionPath, context) : false;
194
+ for (const suffix of SUFFIXES)
195
+ rmSync(`${sessionPath}${suffix}`, { force: true });
196
+ return { revoked, removed: ["the Telegram session"] };
197
+ }, "signOut"),
198
+ secrets: /* @__PURE__ */ __name((profile, { env }) => [
199
+ {
200
+ credentials: { configDir: pathsFor(env).config, service: APP, isolated: isolated(env), env },
201
+ accounts: [`${profile}:api`, `proxy:profile:${profile}`]
202
+ }
203
+ ], "secrets"),
204
+ stateFiles: /* @__PURE__ */ __name((profile, { env }) => [join2(pathsFor(env).state, "bots", profile)], "stateFiles")
205
+ };
206
+
154
207
  // dist/commands/context.js
155
208
  var sessionFiles = /* @__PURE__ */ __name((sessionPath) => privateFiles({ files: withSqliteSidecars(sessionPath), dirs: [dirname(sessionPath)] }), "sessionFiles");
156
209
  var telegramOf = /* @__PURE__ */ __name((command, base) => {
@@ -175,13 +228,13 @@ var telegramOf = /* @__PURE__ */ __name((command, base) => {
175
228
  const open = /* @__PURE__ */ __name(async (given, connecting = {}) => {
176
229
  const resolved = given ?? credentials.read();
177
230
  if (!resolved) {
178
- const loggedIn = existsSync(sessionPath);
231
+ const loggedIn = existsSync2(sessionPath);
179
232
  const background = command.name() === "serve" || base.env.TG_SCHEDULED !== void 0;
180
233
  const temporary = loggedIn && background;
181
234
  throw new CliError(temporary ? "provider_unavailable" : "authentication_error", loggedIn ? `no Telegram app credentials found for profile "${profile}", although it has logged in on this machine \u2014 the keyring is probably out of reach (cron, ssh, an MCP client that trims the environment: set XDG_RUNTIME_DIR); \`tg ${asFirstWord(profile)}doctor\` shows it. Log in again only if they were removed` : `no Telegram app credentials for profile "${profile}" \u2014 run ${setup} in a local terminal first, or sign in from ${desktop}; agents: read \`tg skill show\``, temporary ? { reason: "credentials.unreachable" } : {});
182
235
  }
183
236
  const options = { credentials: resolved, sessionPath, ...connecting };
184
- return environment.adapter ? await environment.adapter(options) : await (await import("./adapter-VNQ72MBK.js")).TelegramAdapter.open({
237
+ return environment.adapter ? await environment.adapter(options) : await (await import("./adapter-NEQQOANM.js")).TelegramAdapter.open({
185
238
  ...options,
186
239
  ...proxyOption(proxy()),
187
240
  diagnostic: /* @__PURE__ */ __name((line) => base.streams.diagnostic(line), "diagnostic"),
@@ -192,7 +245,7 @@ var telegramOf = /* @__PURE__ */ __name((command, base) => {
192
245
  });
193
246
  }, "open");
194
247
  const connect = /* @__PURE__ */ __name(async (options = {}) => {
195
- if (!environment.adapter && !existsSync(sessionPath)) {
248
+ if (!environment.adapter && !existsSync2(sessionPath)) {
196
249
  throw new CliError("authentication_error", `no session for profile "${profile}" \u2014 run ${setup} in a local terminal, or sign in from ${desktop}`);
197
250
  }
198
251
  return open(void 0, options);
@@ -209,7 +262,7 @@ var TELEGRAM = {
209
262
  resolveSettings,
210
263
  connect: /* @__PURE__ */ __name((command, base, options) => telegramOf(command, base).connect(options), "connect"),
211
264
  // Bots sign in on a personal profile and keep their own session, so a tg profile is never a bot alone.
212
- profileState: /* @__PURE__ */ __name((profile, env) => existsSync(sessionFile(profile, env)) ? "signed-in" : "signed-out", "profileState"),
265
+ profileState: /* @__PURE__ */ __name((profile, env) => existsSync2(sessionFile(profile, env)) ? "signed-in" : "signed-out", "profileState"),
213
266
  chatArgument: "a chat: its title or part of it, its id, @username, or `me` for Saved Messages",
214
267
  groupSettings: GROUP_SETTINGS,
215
268
  mediaOptions: ["spoiler", "captionAbove", "fileName"],
@@ -239,7 +292,7 @@ var TELEGRAM = {
239
292
  diagnose: /* @__PURE__ */ __name(async (command, base) => {
240
293
  const { sessionPath, credentials, proxy } = telegramOf(command, base);
241
294
  return {
242
- session: { path: sessionPath, exists: existsSync(sessionPath), files: sessionFiles(sessionPath) },
295
+ session: { path: sessionPath, exists: existsSync2(sessionPath), files: sessionFiles(sessionPath) },
243
296
  proxy: proxyState(proxy),
244
297
  app_credentials: appCredentialsState(() => credentials.read(), base.env),
245
298
  // The one failure with no other symptom: a login made without these variables is invisible with them.
@@ -251,7 +304,8 @@ var TELEGRAM = {
251
304
  // Telegram names a deletion without its chat only where ids count per account. A chat stored by
252
305
  // its id alone has no kind yet, but `-100…` marks a channel's or a supergroup's.
253
306
  deletedWithoutChat: /* @__PURE__ */ __name((chat) => chat.kind !== "channel" && !(chat.kind === "unknown" && chat.id.startsWith("-100")) && !OWN_NUMBERING.includes(String(chat.providerMetadata?.chatType ?? "")), "deletedWithoutChat"),
254
- skill: SKILL
307
+ skill: SKILL,
308
+ accountRemoval: TELEGRAM_REMOVAL
255
309
  };
256
310
  var forCommand = /* @__PURE__ */ __name((command) => {
257
311
  const context = messengerContext(command, TELEGRAM);
@@ -291,7 +345,7 @@ var proxyState = /* @__PURE__ */ __name((resolve) => {
291
345
  }, "proxyState");
292
346
 
293
347
  // dist/commands/bot.js
294
- import { existsSync as existsSync2 } from "node:fs";
348
+ import { existsSync as existsSync3 } from "node:fs";
295
349
 
296
350
  // dist/bot/map.js
297
351
  var KINDS = {
@@ -692,9 +746,17 @@ var proxyRefusal = /* @__PURE__ */ __name((proxy, error) => {
692
746
  return void 0;
693
747
  }, "proxyRefusal");
694
748
 
749
+ // dist/http.js
750
+ var guardedFetch = /* @__PURE__ */ __name((hosts, send, timeoutMs) => hostFetch({
751
+ hosts,
752
+ ...send ? { fetch: /* @__PURE__ */ __name((input, init) => send(input instanceof Request ? input.url : String(input), init ?? {}), "fetch") } : {},
753
+ ...timeoutMs === void 0 ? {} : { timeoutMs }
754
+ }), "guardedFetch");
755
+
695
756
  // dist/bot/transport.js
696
757
  var API = "https://api.telegram.org";
697
758
  var DEFAULT_TIMEOUT_MS = 3e4;
759
+ var GUARD_MARGIN_MS = 5e3;
698
760
  var TelegramBotTransport = class {
699
761
  static {
700
762
  __name(this, "TelegramBotTransport");
@@ -708,7 +770,7 @@ var TelegramBotTransport = class {
708
770
  constructor(options) {
709
771
  this.#token = options.token;
710
772
  this.#baseUrl = options.baseUrl ?? API;
711
- this.#fetch = options.fetch ?? fetch;
773
+ this.#fetch = options.fetch;
712
774
  this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
713
775
  this.#signal = options.signal;
714
776
  this.#events = options.events;
@@ -741,7 +803,8 @@ var TelegramBotTransport = class {
741
803
  const signals = [deadline, ...this.#signal ? [this.#signal] : []];
742
804
  let response;
743
805
  try {
744
- response = await this.#fetch(`${this.#baseUrl}/bot${this.#token}/${method}`, {
806
+ const send = guardedFetch(DESKTOP.hosts, this.#fetch, timeoutMs + GUARD_MARGIN_MS);
807
+ response = await send(`${this.#baseUrl}/bot${this.#token}/${method}`, {
745
808
  method: "POST",
746
809
  ...file || files.length ? {
747
810
  headers: { Accept: "application/json" },
@@ -753,7 +816,7 @@ var TelegramBotTransport = class {
753
816
  signal: AbortSignal.any(signals)
754
817
  });
755
818
  } catch (error) {
756
- const failure = this.#unanswered(method, error, reads, timeoutMs);
819
+ const failure = this.#unanswered(method, error, reads, timeoutMs, deadline);
757
820
  end({ errorCode: failure.code });
758
821
  throw failure;
759
822
  }
@@ -761,7 +824,7 @@ var TelegramBotTransport = class {
761
824
  try {
762
825
  text = await response.text();
763
826
  } catch (error) {
764
- const failure = this.#unanswered(method, error, reads, timeoutMs);
827
+ const failure = this.#unanswered(method, error, reads, timeoutMs, deadline);
765
828
  end({ status: response.status, errorCode: failure.code });
766
829
  throw failure;
767
830
  }
@@ -798,8 +861,8 @@ var TelegramBotTransport = class {
798
861
  return refusal;
799
862
  return new CliError("outcome_unknown", `Telegram failed on ${method}; it may or may not have carried it out \u2014 check before repeating it`, { ...refusal.details, retryable: false });
800
863
  }
801
- #unanswered(method, error, reads, timeoutMs) {
802
- if (isCliError(error) && error.details.proxy !== void 0)
864
+ #unanswered(method, error, reads, timeoutMs, deadline) {
865
+ if (isCliError(error) && (error.details.proxy !== void 0 || error.details.sent === false))
803
866
  return error;
804
867
  if (!reads) {
805
868
  return new CliError("outcome_unknown", `${method} got no answer; Telegram may or may not have carried it out \u2014 check before repeating it`, { operation: method, retryable: false });
@@ -807,7 +870,7 @@ var TelegramBotTransport = class {
807
870
  if (this.#signal?.aborted && this.#signal.reason?.name !== "TimeoutError") {
808
871
  return new CliError("cancelled", `${method} was cancelled`, { operation: method });
809
872
  }
810
- const timedOut = error?.name === "TimeoutError";
873
+ const timedOut = deadline.aborted || error?.name === "TimeoutError";
811
874
  return new CliError(timedOut ? "timeout" : "network_error", timedOut ? `${method} got no answer within ${timeoutMs} ms` : `${method} could not reach Telegram`, { operation: method, retryable: true });
812
875
  }
813
876
  };
@@ -880,10 +943,10 @@ var TELEGRAM_BOT = {
880
943
  checks: words,
881
944
  ...environment.keyring ? { keyring: environment.keyring } : {}
882
945
  });
883
- const fetch2 = environment.botFetch ?? (through ? proxiedFetch(through.proxy) : void 0);
946
+ const fetch = environment.botFetch ?? (through ? proxiedFetch(through.proxy) : void 0);
884
947
  const adapter = telegramBotAdapter(new TelegramBotTransport({
885
948
  token,
886
- ...fetch2 ? { fetch: fetch2 } : {},
949
+ ...fetch ? { fetch } : {},
887
950
  ...stop ? { signal: stop } : {},
888
951
  ...events ? { events } : {}
889
952
  }));
@@ -896,7 +959,7 @@ var TELEGRAM_BOT = {
896
959
  const botId = token.split(":", 1)[0] ?? "";
897
960
  if (!/^\d+$/.test(botId))
898
961
  throw new CliError("authentication_error", "the bot token has no valid bot id");
899
- const reader = await (environment.botHistory ?? (await import("./bot-history-GBH5XE4N.js")).openBotHistory)({
962
+ const reader = await (environment.botHistory ?? (await import("./bot-history-KF2PUMWA.js")).openBotHistory)({
900
963
  credentials,
901
964
  sessionPath: botSessionFile(profile, botId, env),
902
965
  token,
@@ -912,11 +975,11 @@ var TELEGRAM_BOT = {
912
975
  if (known.items[0])
913
976
  return known.items[0].id;
914
977
  const personalPath = sessionFile(profile, env);
915
- if (!existsSync2(personalPath) && !environment.adapter)
978
+ if (!existsSync3(personalPath) && !environment.adapter)
916
979
  return void 0;
917
980
  let personal;
918
981
  try {
919
- personal = environment.adapter ? await environment.adapter({ credentials, sessionPath: personalPath }) : await (await import("./adapter-VNQ72MBK.js")).TelegramAdapter.open({
982
+ personal = environment.adapter ? await environment.adapter({ credentials, sessionPath: personalPath }) : await (await import("./adapter-NEQQOANM.js")).TelegramAdapter.open({
920
983
  credentials,
921
984
  sessionPath: personalPath,
922
985
  checks: words,
@@ -943,6 +1006,7 @@ export {
943
1006
  CONFIG,
944
1007
  resolveSettings,
945
1008
  proxiedFetch,
1009
+ guardedFetch,
946
1010
  pathsFor,
947
1011
  parseApiId,
948
1012
  parseApiHash,
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
8
8
  var botInstructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => [
9
9
  `The owner's ${name} bot "${profile}", through the official Bot API \u2014 not the owner's personal account. What it writes, people see as the bot.`,
10
10
  "Use these tools to read the chats this bot is in, find a message or a person, and \u2014 when the profile allows \u2014 write as the bot.",
@@ -2,15 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  wirecatDirectory
5
- } from "./chunk-3GRX7WP6.js";
5
+ } from "./chunk-6K5R3YPN.js";
6
6
  import {
7
7
  CliError
8
- } from "./chunk-BXTDAGM4.js";
8
+ } from "./chunk-SMHLQEE2.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/speech/models.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/speech/models.js
14
14
  var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/csukuangfj/${repository}/resolve/${commit}/${name}`, "huggingFace");
15
15
  var gigaam = huggingFace("sherpa-onnx-nemo-transducer-punct-giga-am-v3-russian-2025-12-16", "a6039be7cee829a9044a69ac0ebaf1c191217c97");
16
16
  var gigaamCtc = huggingFace("sherpa-onnx-nemo-ctc-punct-giga-am-v3-russian-2025-12-16", "4fb5407ff028a69fec516cdf4c10fac9ddea7c16");
@@ -137,7 +137,7 @@ var speechModel = /* @__PURE__ */ __name((id) => {
137
137
  return model;
138
138
  }, "speechModel");
139
139
 
140
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/speech/install.js
140
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/speech/install.js
141
141
  import { createHash, randomUUID } from "node:crypto";
142
142
  import { createReadStream, createWriteStream, mkdirSync, statSync } from "node:fs";
143
143
  import { rename, rm } from "node:fs/promises";
@@ -175,11 +175,12 @@ var sizeOf = /* @__PURE__ */ __name((path) => {
175
175
  }
176
176
  }, "sizeOf");
177
177
  var installedBytes = /* @__PURE__ */ __name((model) => model.files.reduce((sum, file) => sum + file.bytes, 0), "installedBytes");
178
- var install = /* @__PURE__ */ __name(async (model, directory, { fetch: get = fetch, progress, verifyExisting } = {}) => {
178
+ var install = /* @__PURE__ */ __name(async (model, directory, { fetch: get = fetch, progress, bytes, verifyExisting } = {}) => {
179
179
  mkdirSync(join(directory, model.id), { recursive: true, mode: 448 });
180
- await installFiles(placed(model, directory), { fetch: get, progress, verifyExisting });
180
+ await installFiles(placed(model, directory), { fetch: get, progress, bytes, verifyExisting });
181
181
  }, "install");
182
- var installFiles = /* @__PURE__ */ __name(async (files, { fetch: get = fetch, progress, verifyExisting } = {}) => {
182
+ var installFiles = /* @__PURE__ */ __name(async (files, { fetch: get = fetch, progress, bytes = /* @__PURE__ */ __name(() => {
183
+ }, "bytes"), verifyExisting } = {}) => {
183
184
  if (verifyExisting)
184
185
  for (const [file, path] of files) {
185
186
  if (sizeOf(path) !== void 0) {
@@ -192,18 +193,24 @@ var installFiles = /* @__PURE__ */ __name(async (files, { fetch: get = fetch, pr
192
193
  }
193
194
  }
194
195
  }
195
- for (const [file, path] of files) {
196
- if (sizeOf(path) === file.bytes)
197
- continue;
196
+ const total = files.reduce((sum, [file]) => sum + file.bytes, 0);
197
+ const missing = files.filter(([file, path]) => sizeOf(path) !== file.bytes);
198
+ let done = total - missing.reduce((sum, [file]) => sum + file.bytes, 0);
199
+ bytes(done, total);
200
+ for (const [file, path] of missing) {
198
201
  mkdirSync(dirname(path), { recursive: true, mode: 448 });
199
202
  progress?.(`downloading ${file.name} (${megabytes(file.bytes)})`);
200
- await fetchVerified(file, path, get);
203
+ const before = done;
204
+ await fetchVerified(file, path, get, (received) => {
205
+ done = before + received;
206
+ bytes(done, total);
207
+ });
201
208
  }
202
209
  }, "installFiles");
203
- var fetchVerified = /* @__PURE__ */ __name(async (file, path, get) => {
210
+ var fetchVerified = /* @__PURE__ */ __name(async (file, path, get, received) => {
204
211
  const stalled = watchdog(STALL_MS);
205
212
  try {
206
- await fetchInto(file, path, get, stalled);
213
+ await fetchInto(file, path, get, stalled, received);
207
214
  } catch (error) {
208
215
  if (stalled.signal.aborted) {
209
216
  throw new CliError("timeout", `${file.name} stopped downloading for ${STALL_MS / 1e3} s \u2014 nothing was installed`);
@@ -213,7 +220,7 @@ var fetchVerified = /* @__PURE__ */ __name(async (file, path, get) => {
213
220
  stalled.stop();
214
221
  }
215
222
  }, "fetchVerified");
216
- var fetchInto = /* @__PURE__ */ __name(async (file, path, get, stalled) => {
223
+ var fetchInto = /* @__PURE__ */ __name(async (file, path, get, stalled, received) => {
217
224
  const response = await get(file.url, { signal: stalled.signal });
218
225
  if (!response.ok || !response.body) {
219
226
  await response.body?.cancel();
@@ -231,6 +238,7 @@ var fetchInto = /* @__PURE__ */ __name(async (file, path, get, stalled) => {
231
238
  return;
232
239
  }
233
240
  hash.update(chunk);
241
+ received(bytes);
234
242
  done(null, chunk);
235
243
  }
236
244
  });
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/store/driver.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/store/driver.js
8
8
  var TIME_LIMIT_FUNCTION = "wc_time_limit";
9
9
  var TimeLimitReached = class extends Error {
10
10
  static {
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
8
8
  var instructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => {
9
9
  const all = typeof profile !== "string";
10
10
  const offers = /* @__PURE__ */ __name((key) => all || writes.includes(key), "offers");