@wirecat/tg-cli 0.118.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.
- package/contracts/wirecat.json +7621 -0
- package/dist/bin/tg.js +2 -2
- package/dist/bot/transport.d.ts.map +1 -1
- package/dist/bot/transport.js +15 -8
- package/dist/bot/transport.js.map +1 -1
- package/dist/bundle/{adapter-4YNP6VCO.js → adapter-NEQQOANM.js} +47 -48
- package/dist/bundle/{all-profiles-MIQDYAGO.js → all-profiles-QFT46FTF.js} +10 -10
- package/dist/bundle/{anthropic-NTASPJYE.js → anthropic-UJ4RYCWU.js} +10 -8
- package/dist/bundle/{app-server-UJZBJ2SK.js → app-server-NE3EL5IK.js} +43 -43
- package/dist/bundle/{bot-api-JZAD4L3N.js → bot-api-D4H5SCP5.js} +49 -49
- package/dist/bundle/{bot-history-OUDHH3NU.js → bot-history-KF2PUMWA.js} +18 -18
- package/dist/bundle/{bun-EC4HDIRD.js → bun-F7MH5YKA.js} +2 -2
- package/dist/bundle/{bun-sqlite-A4HJR6KO.js → bun-sqlite-FYDJXUHF.js} +5 -5
- package/dist/bundle/{chunk-I4TI5HDJ.js → chunk-23JGV5FQ.js} +11 -11
- package/dist/bundle/{chunk-MBH7IKLT.js → chunk-2BAJ6ORN.js} +1 -1
- package/dist/bundle/{chunk-EPXVRJAX.js → chunk-3EQ7USKJ.js} +2 -2
- package/dist/bundle/{chunk-MZNOASAW.js → chunk-3K65KTXD.js} +16 -3
- package/dist/bundle/{chunk-EQJ6NLF5.js → chunk-4AACB23H.js} +13 -13
- package/dist/bundle/{chunk-NUCDEOFC.js → chunk-5EHJWIW4.js} +2 -2
- package/dist/bundle/{chunk-VW6BF6M7.js → chunk-5FEEFXJA.js} +1 -1
- package/dist/bundle/{chunk-6RI4TEIC.js → chunk-65BWMPCI.js} +2 -2
- package/dist/bundle/{chunk-PB252TT3.js → chunk-6ERQJRL2.js} +2 -2
- package/dist/bundle/{chunk-G3RT2EQI.js → chunk-6K5R3YPN.js} +2 -2
- package/dist/bundle/{chunk-OTQDJUES.js → chunk-6OE5I3PR.js} +6 -6
- package/dist/bundle/{chunk-FHMK6OK4.js → chunk-72QLHHSO.js} +93 -29
- package/dist/bundle/{chunk-YEOSV6JC.js → chunk-7C6POLLO.js} +1 -1
- package/dist/bundle/{chunk-JPVFYMSQ.js → chunk-7VUNJDYU.js} +4 -4
- package/dist/bundle/{chunk-57LKX6N2.js → chunk-BXIPT2BO.js} +1 -1
- package/dist/bundle/{chunk-NKFTZVQU.js → chunk-CIDFV3IT.js} +1 -1
- package/dist/bundle/{chunk-4BV4UMBB.js → chunk-CX2WCEQU.js} +264 -195
- package/dist/bundle/{chunk-H6S3C3MH.js → chunk-D4Y2KL5V.js} +4 -4
- package/dist/bundle/{chunk-YPRUWRKE.js → chunk-D6YTBJY6.js} +1 -1
- package/dist/bundle/{chunk-PW3HFIJA.js → chunk-DQELQ7BL.js} +365 -192
- package/dist/bundle/{chunk-5IIU7X4S.js → chunk-F223KYWG.js} +1 -1
- package/dist/bundle/{chunk-TMTEWOQS.js → chunk-FJKP6MMP.js} +5 -3
- package/dist/bundle/{chunk-NMT2VGEI.js → chunk-FQ3C6DFV.js} +3 -3
- package/dist/bundle/{chunk-6ZMTEUVU.js → chunk-FQZSS3AB.js} +6 -6
- package/dist/bundle/{chunk-CEY43D3A.js → chunk-FRW3CWC7.js} +29 -29
- package/dist/bundle/{chunk-65XV5PPI.js → chunk-G3MQOH6Z.js} +3 -3
- package/dist/bundle/{chunk-6AXUEJGL.js → chunk-HGMMRT4G.js} +2 -2
- package/dist/bundle/{chunk-GLRRCKP6.js → chunk-HPQQ76WF.js} +23 -5
- package/dist/bundle/{chunk-RG2E7ZQZ.js → chunk-HV5YYAJX.js} +50 -15
- package/dist/bundle/{chunk-3MQOLYAN.js → chunk-IAGX5VFL.js} +4 -4
- package/dist/bundle/{chunk-BNEP5EOV.js → chunk-JKKEMVW3.js} +4 -4
- package/dist/bundle/{chunk-P3ASN72F.js → chunk-KBHK5UGL.js} +1 -1
- package/dist/bundle/{chunk-EPCFXKTX.js → chunk-KC4MQRAB.js} +34 -8
- package/dist/bundle/{chunk-GXCJ47SJ.js → chunk-L33G5ARH.js} +2664 -670
- package/dist/bundle/{chunk-PO74BDER.js → chunk-MDLSI3EN.js} +23 -23
- package/dist/bundle/chunk-NDSRND3E.js +138 -0
- package/dist/bundle/{chunk-2KQHUBTV.js → chunk-OG2CG2GS.js} +12 -12
- package/dist/bundle/{chunk-JZETEZHC.js → chunk-QD27C3BG.js} +7 -7
- package/dist/bundle/{chunk-QOGYHU3Q.js → chunk-QG5U6HCI.js} +61 -21
- package/dist/bundle/{chunk-GI4MTNA2.js → chunk-QQ3QZFFD.js} +8 -8
- package/dist/bundle/{chunk-76EKXFX2.js → chunk-QTFXYR5W.js} +24 -2
- package/dist/bundle/{chunk-ZXXTJF4Z.js → chunk-RGU2G3KL.js} +4 -4
- package/dist/bundle/{chunk-JWPSVS6C.js → chunk-ROOUBFUW.js} +2304 -1442
- package/dist/bundle/{chunk-5QYU7B27.js → chunk-RUNFFBJU.js} +656 -461
- package/dist/bundle/{chunk-DKFC5ZZ3.js → chunk-S3HAFJVC.js} +4 -4
- package/dist/bundle/{chunk-BXTDAGM4.js → chunk-SMHLQEE2.js} +2 -2
- package/dist/bundle/{chunk-JWIUK3SK.js → chunk-TEZKCH5B.js} +2 -2
- package/dist/bundle/{chunk-HJNRIK5X.js → chunk-TKHEVAEG.js} +9 -8
- package/dist/bundle/{chunk-JLJKGKU2.js → chunk-TT4CIXVH.js} +6 -6
- package/dist/bundle/{chunk-ZMUC3UQO.js → chunk-UBCLVM7C.js} +3 -3
- package/dist/bundle/{chunk-YHZFGUAP.js → chunk-V5Z2JO6X.js} +19 -19
- package/dist/bundle/{chunk-2NA5KVP6.js → chunk-W2BIBPRU.js} +234 -38
- package/dist/bundle/{chunk-PWCQC56A.js → chunk-X5PDWCG7.js} +1 -1
- package/dist/bundle/{chunk-GIM37COQ.js → chunk-XDMJVWWR.js} +3 -3
- package/dist/bundle/{chunk-KEDHX6XG.js → chunk-XM3P7LLT.js} +2 -2
- package/dist/bundle/{chunk-DSZJREEO.js → chunk-YMWPRHXG.js} +1285 -750
- package/dist/bundle/{chunk-5LDWBEWU.js → chunk-Z4CGZAFQ.js} +45 -27
- package/dist/bundle/{chunk-Y64SI2RO.js → chunk-ZEQ7ONPZ.js} +3 -3
- package/dist/bundle/command-contract-7TGMZRBE.js +33 -0
- package/dist/bundle/{decode-NMNPLKNR.js → decode-5N4ERCHC.js} +5 -5
- package/dist/bundle/{dispatch-OP27MWX5.js → dispatch-TBGXBDHE.js} +10 -10
- package/dist/bundle/{echarts-S46LEIPS.js → echarts-YDEBAMXT.js} +2 -2
- package/dist/bundle/{embed-I5ZYHGYC.js → embed-T7H62XFR.js} +6 -6
- package/dist/bundle/{embedder-LTJI67N2.js → embedder-AW3O2TR3.js} +9 -9
- package/dist/bundle/{entry-O6BUPXF7.js → entry-L2LJ2VPY.js} +7 -7
- package/dist/bundle/{failure-4JUQFXJT.js → failure-AWHPW2HE.js} +2 -2
- package/dist/bundle/{first-run-PMZNCDGD.js → first-run-6PBZSRZU.js} +11 -11
- package/dist/bundle/first-screen-UKCD7D2R.js +31 -0
- package/dist/bundle/{instructions-AUEGY3VO.js → instructions-C3NJERO7.js} +1 -1
- package/dist/bundle/{mcp-M4QN2E7R.js → mcp-CWLASTLV.js} +2 -2
- package/dist/bundle/{node-XRA7RBCQ.js → node-P3CIIYWU.js} +2 -2
- package/dist/bundle/{node-sqlite-DEZO6LRS.js → node-sqlite-YVHMNRVA.js} +6 -6
- package/dist/bundle/{oauth-DAVC7WCD.js → oauth-5OQYA2SV.js} +7 -7
- package/dist/bundle/{open-DE2YO4T7.js → open-YGWUVSU7.js} +5 -5
- package/dist/bundle/{openai-5BKGAULH.js → openai-U45JBQ6F.js} +16 -37
- package/dist/bundle/{process-4ZHPNUIQ.js → process-DCYX5EDG.js} +1 -1
- package/dist/bundle/{program-EGTKSNB4.js → program-UZBFH2EZ.js} +55 -52
- package/dist/bundle/{prompt-HWCWHHPE.js → prompt-HPVTPTFI.js} +7 -5
- package/dist/bundle/{proxy-transport-4DPZB2W2.js → proxy-transport-D7MCHGSV.js} +5 -5
- package/dist/bundle/{recognize-NG6RXNGF.js → recognize-IJCPFJ76.js} +4 -4
- package/dist/bundle/{remote-ZKXIIGYH.js → remote-MWDYQWFW.js} +7 -7
- package/dist/bundle/{rerank-TX5QFURV.js → rerank-SXG64475.js} +7 -7
- package/dist/bundle/{serve-XAS6DECW.js → serve-KJQENHEH.js} +9 -9
- package/dist/bundle/{server-CNPIWBYU.js → server-MXVXZWN6.js} +35 -35
- package/dist/bundle/server-RTMCRKQF.js +60 -0
- package/dist/bundle/{state-3HTUETTS.js → state-CKKJWH27.js} +6 -6
- package/dist/bundle/{store-B5VZWJHN.js → store-R3BE4V56.js} +36 -13
- package/dist/bundle/store-maintenance-command-KDGBSBNU.js +49 -0
- package/dist/bundle/tg.js +38 -14
- package/dist/commands/account-removal.d.ts +3 -0
- package/dist/commands/account-removal.d.ts.map +1 -0
- package/dist/commands/account-removal.js +57 -0
- package/dist/commands/account-removal.js.map +1 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +2 -0
- package/dist/commands/context.js.map +1 -1
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +8 -0
- package/dist/http.js.map +1 -0
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +14 -0
- package/dist/identity.js.map +1 -1
- package/dist/telegram/map.d.ts.map +1 -1
- package/dist/telegram/map.js +3 -0
- package/dist/telegram/map.js.map +1 -1
- package/dist/telegram/registration.d.ts +1 -1
- package/dist/telegram/registration.d.ts.map +1 -1
- package/dist/telegram/registration.js +4 -1
- package/dist/telegram/registration.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +7 -6
- package/dist/bundle/chunk-TSTEZNSX.js +0 -33
- package/dist/bundle/command-contract-7GZ6HAA6.js +0 -33
- package/dist/bundle/first-screen-BGML5DSO.js +0 -31
- package/dist/bundle/server-FRTKLHZF.js +0 -60
- package/dist/bundle/store-maintenance-command-VG3CLELA.js +0 -50
- /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-
|
|
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-
|
|
26
|
+
} from "./chunk-TEZKCH5B.js";
|
|
24
27
|
import {
|
|
25
28
|
messengerContext
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-MDLSI3EN.js";
|
|
27
30
|
import {
|
|
28
31
|
uploadBlob
|
|
29
|
-
} from "./chunk-
|
|
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-
|
|
39
|
+
} from "./chunk-DQELQ7BL.js";
|
|
37
40
|
import {
|
|
41
|
+
DESKTOP,
|
|
38
42
|
TG
|
|
39
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-3K65KTXD.js";
|
|
40
44
|
import {
|
|
41
45
|
Credentials,
|
|
42
46
|
pathsAreOverridden,
|
|
43
47
|
resolvePaths
|
|
44
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-V5Z2JO6X.js";
|
|
45
49
|
import {
|
|
46
50
|
optional
|
|
47
|
-
} from "./chunk-
|
|
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-
|
|
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 =
|
|
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-
|
|
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 && !
|
|
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) =>
|
|
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:
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
946
|
+
const fetch = environment.botFetch ?? (through ? proxiedFetch(through.proxy) : void 0);
|
|
884
947
|
const adapter = telegramBotAdapter(new TelegramBotTransport({
|
|
885
948
|
token,
|
|
886
|
-
...
|
|
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-
|
|
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 (!
|
|
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-
|
|
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.
|
|
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-
|
|
5
|
+
} from "./chunk-6K5R3YPN.js";
|
|
6
6
|
import {
|
|
7
7
|
CliError
|
|
8
|
-
} from "./chunk-
|
|
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.
|
|
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.
|
|
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";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__name
|
|
5
5
|
} from "./chunk-ZVVMGPBJ.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
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.
|
|
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");
|