@wirecat/tg-cli 0.101.0 → 0.103.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/dist/bin/tg.js +31 -19
- package/dist/bot/transport.d.ts.map +1 -1
- package/dist/bot/transport.js +14 -17
- package/dist/bot/transport.js.map +1 -1
- package/dist/bundle/{adapter-A3VD4Y6Z.js → adapter-QG3YFFOY.js} +101 -38
- package/dist/bundle/{all-profiles-UPVNHXB2.js → all-profiles-ECXH3TBF.js} +32 -11
- package/dist/bundle/{anthropic-IRKNWPIB.js → anthropic-5MKO3QX7.js} +10 -10
- package/dist/bundle/{bot-api-UNTQG2M5.js → bot-api-4DQPIOMK.js} +55 -58
- package/dist/bundle/{bot-history-V4RTY5K7.js → bot-history-UN74XXLU.js} +19 -19
- package/dist/bundle/{bun-2JZPG2NL.js → bun-PS73VF2C.js} +5 -5
- package/dist/bundle/{bun-sqlite-TZHKM225.js → bun-sqlite-RAWGPH23.js} +8 -8
- package/dist/bundle/{chunk-ZZLKX62Z.js → chunk-2ABQZVK4.js} +3 -3
- package/dist/bundle/{chunk-MLLJ74LM.js → chunk-3CP7RK5R.js} +4 -4
- package/dist/bundle/{chunk-BXQS5RCE.js → chunk-3IXKDIPH.js} +258 -83
- package/dist/bundle/{chunk-W2336E7Y.js → chunk-3QX6SOEO.js} +9 -9
- package/dist/bundle/{chunk-F7TDFWXY.js → chunk-537O7OVE.js} +6 -6
- package/dist/bundle/{chunk-N5UFBWDM.js → chunk-57XGUIXA.js} +9 -11
- package/dist/bundle/{chunk-3KHKYYCR.js → chunk-5D4AEUVA.js} +4 -3
- package/dist/bundle/{chunk-ODSVNH3H.js → chunk-5HPAPVCB.js} +2415 -1292
- package/dist/bundle/{chunk-OEJ5DMCX.js → chunk-67SRVSPU.js} +10 -10
- package/dist/bundle/{chunk-XCKD54TN.js → chunk-6N25NZOE.js} +9 -9
- package/dist/bundle/chunk-AAMJZJYC.js +922 -0
- package/dist/bundle/{chunk-AVWK4NCW.js → chunk-ADLS6FVG.js} +13 -13
- package/dist/bundle/{chunk-ZV24I2UJ.js → chunk-AUKAZRF6.js} +5 -5
- package/dist/bundle/{chunk-S7ZNLLY5.js → chunk-BV4N333Y.js} +6 -6
- package/dist/bundle/{chunk-UN6CKIBN.js → chunk-BYYSVINK.js} +11 -8
- package/dist/bundle/{chunk-54R2GDQ3.js → chunk-CMQ34EZL.js} +6 -6
- package/dist/bundle/{chunk-G2US6LJB.js → chunk-COZ74WW4.js} +4 -4
- package/dist/bundle/{chunk-7BFO3DY6.js → chunk-DFDN6AUB.js} +2 -2
- package/dist/bundle/{chunk-VA5YEJS3.js → chunk-DLF3H6NP.js} +7 -7
- package/dist/bundle/{chunk-QOWSVDPZ.js → chunk-DWQ4QT6X.js} +111 -100
- package/dist/bundle/chunk-EMC57SOZ.js +440 -0
- package/dist/bundle/{chunk-RVCS7Q3A.js → chunk-EQHQ2AX3.js} +1390 -522
- package/dist/bundle/{chunk-64DK7S4F.js → chunk-F27OI4J2.js} +4 -4
- package/dist/bundle/{chunk-2XBSVRT2.js → chunk-FG2QTYEF.js} +4 -4
- package/dist/bundle/{chunk-BX6HH4F6.js → chunk-FSPDODVT.js} +14 -14
- package/dist/bundle/{chunk-4ZS73HTJ.js → chunk-G5IMOOPB.js} +4 -4
- package/dist/bundle/{chunk-VCGL2ETF.js → chunk-GO354DJ5.js} +4 -4
- package/dist/bundle/{chunk-5TPT2S2Z.js → chunk-H2UTBYFC.js} +4 -4
- package/dist/bundle/{chunk-U46UNBMT.js → chunk-HCDZWFXO.js} +244 -21
- package/dist/bundle/{chunk-TGREFJVA.js → chunk-KCVDWZWS.js} +11 -11
- package/dist/bundle/{chunk-PUBS2F5J.js → chunk-KQ5BUI5T.js} +248 -248
- package/dist/bundle/{chunk-ACGTFLEB.js → chunk-LAYPLF7G.js} +35 -282
- package/dist/bundle/{chunk-5KU4UQBM.js → chunk-MFS52LTZ.js} +4 -4
- package/dist/bundle/{chunk-DYNSP6FW.js → chunk-MHHDVR4G.js} +1449 -832
- package/dist/bundle/{chunk-S2JSZWEC.js → chunk-NIVZHTN4.js} +15 -15
- package/dist/bundle/{chunk-A5JSTZZZ.js → chunk-NKN54EDN.js} +6 -6
- package/dist/bundle/chunk-O5EHUB2V.js +2 -0
- package/dist/bundle/{chunk-5GKXETRP.js → chunk-OGVBRRWY.js} +615 -56
- package/dist/bundle/{chunk-VYDTI254.js → chunk-Q2LBOPKO.js} +99 -50
- package/dist/bundle/{chunk-LPB2MDUW.js → chunk-QF7VVIF4.js} +11 -11
- package/dist/bundle/{chunk-VRSN7VLO.js → chunk-RD7SSY7H.js} +4 -4
- package/dist/bundle/{chunk-ZEOCU24Z.js → chunk-RKQIEJFR.js} +5 -5
- package/dist/bundle/chunk-RMC2S3F4.js +264 -0
- package/dist/bundle/{chunk-2DGOFLDA.js → chunk-S5M4HFOZ.js} +6 -6
- package/dist/bundle/{chunk-X4Y2ROJI.js → chunk-SSALGKMJ.js} +94 -5
- package/dist/bundle/{chunk-G3ZRY436.js → chunk-SSV37M5T.js} +59 -59
- package/dist/bundle/{chunk-DG62L57H.js → chunk-T4SDOYPY.js} +20 -20
- package/dist/bundle/{chunk-6IPY2QRG.js → chunk-TEO2KP52.js} +5 -5
- package/dist/bundle/{chunk-G77QOTXE.js → chunk-TPFLD4OM.js} +5 -5
- package/dist/bundle/{chunk-PYTOIDSM.js → chunk-VMU4SGCE.js} +7 -7
- package/dist/bundle/{chunk-QYVVRQTN.js → chunk-VZN5LD26.js} +6 -6
- package/dist/bundle/{chunk-ZJVZXJOG.js → chunk-WAGDZB62.js} +5 -5
- package/dist/bundle/{chunk-7CBUCTB6.js → chunk-WULARSC4.js} +33 -39
- package/dist/bundle/{chunk-BJG6JA5U.js → chunk-Y5E2WNWB.js} +4 -4
- package/dist/bundle/{chunk-H6OXALTJ.js → chunk-YI72UVTJ.js} +5 -5
- package/dist/bundle/{chunk-NC5WS7OP.js → chunk-Z2DPNTSU.js} +5 -5
- package/dist/bundle/{chunk-RF54YDBB.js → chunk-ZHXSRYJ5.js} +6 -6
- package/dist/bundle/{chunk-AFV74GK3.js → chunk-ZVVMGPBJ.js} +2 -2
- package/dist/bundle/command-contract-ZGFJTLB2.js +32 -0
- package/dist/bundle/{dist-RJMT44PL.js → dist-I7OZPHAZ.js} +3 -3
- package/dist/bundle/{echarts-QZ6PR3VC.js → echarts-UEQDIHVQ.js} +5 -5
- package/dist/bundle/{embed-UBXCXSRD.js → embed-5DPZKRW5.js} +9 -8
- package/dist/bundle/{embedder-B4ZTKC23.js → embedder-NBQXDXAO.js} +12 -11
- package/dist/bundle/entry-EE6YRAP4.js +14 -0
- package/dist/bundle/first-run-OSEVVWNT.js +24 -0
- package/dist/bundle/first-screen-753THOU6.js +30 -0
- package/dist/bundle/identity-LNH33PN3.js +11 -0
- package/dist/bundle/instructions-PYGVIT7I.js +9 -0
- package/dist/bundle/{mcp-4Y37G2UY.js → mcp-OQBZXELQ.js} +5 -5
- package/dist/bundle/{node-LZZX22VR.js → node-3OBKCX6M.js} +5 -5
- package/dist/bundle/{node-IUL5HSYI.js → node-P4E63KXA.js} +5 -5
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/{node-sqlite-BPGT6T5U.js → node-sqlite-DMMTDRFB.js} +8 -8
- package/dist/bundle/oauth-FX5DDCRS.js +18 -0
- package/dist/bundle/open-G6QRQAAL.js +20 -0
- package/dist/bundle/{process-GPUXC4PG.js → process-47MMIFIJ.js} +5 -5
- package/dist/bundle/{program-NEXEAL7T.js → program-LBHBWRK5.js} +67 -71
- package/dist/bundle/prompt-CJ6Y4JYC.js +13 -0
- package/dist/bundle/proxy-transport-YSBYG26I.js +17 -0
- package/dist/bundle/{recognize-UJBXORVD.js → recognize-7BLTOI45.js} +9 -9
- package/dist/bundle/remote-Q4A4JY6U.js +27 -0
- package/dist/bundle/{rerank-3Y2VZM3J.js → rerank-CQAR46L3.js} +10 -9
- package/dist/bundle/{serve-VDZIVOPR.js → serve-2UO2YMMG.js} +13 -13
- package/dist/bundle/{server-BERXP4GW.js → server-6XYURULQ.js} +80 -68
- package/dist/bundle/{server-ZFHN4GUF.js → server-FMKC4RLL.js} +46 -41
- package/dist/bundle/{state-DGR4EE3E.js → state-RNWN2RDY.js} +9 -9
- package/dist/bundle/{store-MRCFSCZD.js → store-BBHTR477.js} +14 -14
- package/dist/bundle/store-maintenance-command-GD6OLRXH.js +44 -0
- package/dist/bundle/tg.js +8 -8
- package/dist/telegram/sending.d.ts.map +1 -1
- package/dist/telegram/sending.js +52 -3
- package/dist/telegram/sending.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/bundle/chunk-22PQUX72.js +0 -190
- package/dist/bundle/chunk-2SJOUK6J.js +0 -2
- package/dist/bundle/chunk-CJ6IYCYP.js +0 -583
- package/dist/bundle/chunk-NKJJJAIJ.js +0 -237
- package/dist/bundle/chunk-NMGO6LW6.js +0 -1950
- package/dist/bundle/chunk-OILBDLWL.js +0 -724
- package/dist/bundle/chunk-OPBTNQ35.js +0 -1007
- package/dist/bundle/command-contract-TKDI7E56.js +0 -31
- package/dist/bundle/entry-BTUTHO5M.js +0 -14
- package/dist/bundle/first-run-UC4HRIFV.js +0 -24
- package/dist/bundle/first-screen-SMCX6YKY.js +0 -29
- package/dist/bundle/identity-QSDEGDH7.js +0 -11
- package/dist/bundle/instructions-BBGLZKO3.js +0 -9
- package/dist/bundle/node-UPPL626U.js +0 -21
- package/dist/bundle/oauth-XNE2KPKJ.js +0 -18
- package/dist/bundle/open-SXGYZLB5.js +0 -20
- package/dist/bundle/prompt-SORGLEYI.js +0 -13
- package/dist/bundle/proxy-transport-G4MA6BGU.js +0 -17
- package/dist/bundle/remote-W72AR7KH.js +0 -26
- package/dist/bundle/store-maintenance-command-DCMZDMYS.js +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire as
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
ACCESS_SECONDS,
|
|
5
5
|
REFRESH_SECONDS,
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
readHttpLock,
|
|
13
13
|
readStored,
|
|
14
14
|
signedInClients
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-DLF3H6NP.js";
|
|
16
|
+
import "./chunk-VZN5LD26.js";
|
|
17
|
+
import "./chunk-RD7SSY7H.js";
|
|
18
|
+
import "./chunk-T4SDOYPY.js";
|
|
19
|
+
import "./chunk-67SRVSPU.js";
|
|
20
|
+
import "./chunk-Y5E2WNWB.js";
|
|
21
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
22
22
|
export {
|
|
23
23
|
ACCESS_SECONDS,
|
|
24
24
|
REFRESH_SECONDS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire as
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
AGENDA_COLUMNS,
|
|
5
5
|
BACKFILL_ON_OPEN,
|
|
@@ -53,18 +53,18 @@ import {
|
|
|
53
53
|
threadConversation,
|
|
54
54
|
titlePart,
|
|
55
55
|
vectorIndexCounts
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
import "./chunk-
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
62
|
-
import "./chunk-
|
|
63
|
-
import "./chunk-
|
|
64
|
-
import "./chunk-
|
|
65
|
-
import "./chunk-
|
|
66
|
-
import "./chunk-
|
|
67
|
-
import "./chunk-
|
|
56
|
+
} from "./chunk-KQ5BUI5T.js";
|
|
57
|
+
import "./chunk-SSV37M5T.js";
|
|
58
|
+
import "./chunk-KCVDWZWS.js";
|
|
59
|
+
import "./chunk-3QX6SOEO.js";
|
|
60
|
+
import "./chunk-O5EHUB2V.js";
|
|
61
|
+
import "./chunk-TPFLD4OM.js";
|
|
62
|
+
import "./chunk-6N25NZOE.js";
|
|
63
|
+
import "./chunk-G5IMOOPB.js";
|
|
64
|
+
import "./chunk-T4SDOYPY.js";
|
|
65
|
+
import "./chunk-67SRVSPU.js";
|
|
66
|
+
import "./chunk-Y5E2WNWB.js";
|
|
67
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
68
68
|
export {
|
|
69
69
|
AGENDA_COLUMNS,
|
|
70
70
|
BACKFILL_ON_OPEN,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
buildStems,
|
|
5
|
+
storeMaintenanceCommands,
|
|
6
|
+
storeSummary
|
|
7
|
+
} from "./chunk-3IXKDIPH.js";
|
|
8
|
+
import "./chunk-OGVBRRWY.js";
|
|
9
|
+
import "./chunk-MHHDVR4G.js";
|
|
10
|
+
import "./chunk-ZHXSRYJ5.js";
|
|
11
|
+
import "./chunk-2ABQZVK4.js";
|
|
12
|
+
import "./chunk-EQHQ2AX3.js";
|
|
13
|
+
import "./chunk-CMQ34EZL.js";
|
|
14
|
+
import "./chunk-EMC57SOZ.js";
|
|
15
|
+
import "./chunk-VMU4SGCE.js";
|
|
16
|
+
import "./chunk-MFS52LTZ.js";
|
|
17
|
+
import "./chunk-BV4N333Y.js";
|
|
18
|
+
import "./chunk-AUKAZRF6.js";
|
|
19
|
+
import "./chunk-VZN5LD26.js";
|
|
20
|
+
import "./chunk-RD7SSY7H.js";
|
|
21
|
+
import "./chunk-Z2DPNTSU.js";
|
|
22
|
+
import "./chunk-YI72UVTJ.js";
|
|
23
|
+
import "./chunk-NKN54EDN.js";
|
|
24
|
+
import "./chunk-LAYPLF7G.js";
|
|
25
|
+
import "./chunk-RMC2S3F4.js";
|
|
26
|
+
import "./chunk-KQ5BUI5T.js";
|
|
27
|
+
import "./chunk-SSV37M5T.js";
|
|
28
|
+
import "./chunk-KCVDWZWS.js";
|
|
29
|
+
import "./chunk-3QX6SOEO.js";
|
|
30
|
+
import "./chunk-O5EHUB2V.js";
|
|
31
|
+
import "./chunk-TPFLD4OM.js";
|
|
32
|
+
import "./chunk-6N25NZOE.js";
|
|
33
|
+
import "./chunk-G5IMOOPB.js";
|
|
34
|
+
import "./chunk-537O7OVE.js";
|
|
35
|
+
import "./chunk-TEO2KP52.js";
|
|
36
|
+
import "./chunk-T4SDOYPY.js";
|
|
37
|
+
import "./chunk-67SRVSPU.js";
|
|
38
|
+
import "./chunk-Y5E2WNWB.js";
|
|
39
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
40
|
+
export {
|
|
41
|
+
buildStems,
|
|
42
|
+
storeMaintenanceCommands,
|
|
43
|
+
storeSummary
|
|
44
|
+
};
|
package/dist/bundle/tg.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as
|
|
3
|
-
const require =
|
|
2
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
3
|
+
const require = __bundleRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
errorObjectOf,
|
|
6
6
|
exitCodeOfError,
|
|
7
7
|
renderError
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-T4SDOYPY.js";
|
|
9
|
+
import "./chunk-67SRVSPU.js";
|
|
10
|
+
import "./chunk-Y5E2WNWB.js";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
14
|
|
|
15
15
|
// dist/bin/tg.js
|
|
16
16
|
import { enableCompileCache } from "node:module";
|
|
17
17
|
enableCompileCache();
|
|
18
|
-
var [{ startCli }, { TG }] = await Promise.all([import("./entry-
|
|
18
|
+
var [{ startCli }, { TG }] = await Promise.all([import("./entry-EE6YRAP4.js"), import("./identity-LNH33PN3.js")]);
|
|
19
19
|
await startCli({
|
|
20
20
|
app: TG,
|
|
21
21
|
sqlite: true,
|
|
22
22
|
// A static import would load the whole program, and its SQLite, before ensureSqlite could swap it.
|
|
23
|
-
run: /* @__PURE__ */ __name(async ({ args }) => (await import("./program-
|
|
23
|
+
run: /* @__PURE__ */ __name(async ({ args }) => (await import("./program-LBHBWRK5.js")).run(args), "run"),
|
|
24
24
|
fail: /* @__PURE__ */ __name((error, { tty }) => {
|
|
25
25
|
const object = errorObjectOf(error);
|
|
26
26
|
process.stderr.write(`${renderError(object, { cli: TG.command, interactive: tty })}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sending.d.ts","sourceRoot":"","sources":["../../src/telegram/sending.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"sending.d.ts","sourceRoot":"","sources":["../../src/telegram/sending.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,iBAAiB,EAAqC,MAAM,cAAc,CAAA;AA0E5G,eAAO,MAAM,aAAa,4BACC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,OAC3D,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAC1B,iBAAiB,EAenB,CAAA;AAED,mGAAmG;AACnG,eAAO,MAAM,OAAO,GAAU,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CASlE,CAAA"}
|
package/dist/telegram/sending.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { networkMiddlewares } from "@mtcute/node";
|
|
3
|
-
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { networkMiddlewares, tl } from "@mtcute/node";
|
|
3
|
+
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
4
4
|
import { bareCheck } from "@wirecat/cli-core";
|
|
5
|
+
import { currentAttempt, providerRequest, runEvent } from "@wirecat/cli-core/cli";
|
|
5
6
|
import { toCliError } from "./errors.js";
|
|
6
7
|
const SENDS = new Set([
|
|
7
8
|
"messages.sendMessage",
|
|
@@ -22,14 +23,62 @@ const noteAcceptedSend = async (context, next) => {
|
|
|
22
23
|
current.accepted = true;
|
|
23
24
|
return answer;
|
|
24
25
|
};
|
|
26
|
+
// floodWaiter and internalErrorsHandler retry by passing the same context to `next` again.
|
|
27
|
+
const tries = new WeakMap();
|
|
28
|
+
const codeOf = (error) => {
|
|
29
|
+
const known = toCliError(error, bareCheck);
|
|
30
|
+
return isCliError(known) ? known.code : "network_error";
|
|
31
|
+
};
|
|
32
|
+
/** `FLOOD_WAIT_12` → `FLOOD_WAIT`: the seconds go into the retry's `waitMs`. */
|
|
33
|
+
const errorKey = (message) => message.replace(/_\d+(?=_|$)/g, "");
|
|
34
|
+
/**
|
|
35
|
+
* One request line and one response line per RPC that goes on the wire, into the run under way. Only the
|
|
36
|
+
* method name leaves the request: every other field of it is what the person sent or asked for.
|
|
37
|
+
*/
|
|
38
|
+
const recordRequest = async (context, next) => {
|
|
39
|
+
const tried = tries.get(context);
|
|
40
|
+
const attempt = (tried?.attempt ?? 0) + 1;
|
|
41
|
+
// mtcute's own retry names its attempt; a first try takes the attempt of a retry made above it (`patiently`).
|
|
42
|
+
const retried = attempt > 1 ? { attempt, ...(tried?.waitMs === undefined ? {} : { waitMs: tried.waitMs }) } : undefined;
|
|
43
|
+
const end = providerRequest(context.request._, runEvent, {
|
|
44
|
+
transport: "mtproto",
|
|
45
|
+
...(retried ?? currentAttempt() ?? { attempt: 1 }),
|
|
46
|
+
});
|
|
47
|
+
tries.set(context, { attempt });
|
|
48
|
+
let answer;
|
|
49
|
+
try {
|
|
50
|
+
answer = await next(context);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
end({ errorCode: codeOf(error) });
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
const failure = answer;
|
|
57
|
+
if (failure?._ === "mt_rpc_error" && typeof failure.errorMessage === "string") {
|
|
58
|
+
end({
|
|
59
|
+
errorCode: codeOf(tl.RpcError.fromTl(failure)),
|
|
60
|
+
providerError: errorKey(failure.errorMessage),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
end();
|
|
65
|
+
return answer;
|
|
66
|
+
};
|
|
25
67
|
export const middlewaresOf = ({ maxWait, maxRetries }, say) => [
|
|
26
68
|
...networkMiddlewares.basic({
|
|
27
69
|
floodWaiter: {
|
|
28
70
|
maxWait,
|
|
29
71
|
maxRetries,
|
|
30
|
-
onBeforeWait: (context, seconds) =>
|
|
72
|
+
onBeforeWait: (context, seconds) => {
|
|
73
|
+
const tried = tries.get(context);
|
|
74
|
+
if (tried)
|
|
75
|
+
tried.waitMs = seconds * 1000;
|
|
76
|
+
say(`Telegram asks to wait ${seconds} s before ${context.request._} — waiting, then going on`);
|
|
77
|
+
},
|
|
31
78
|
},
|
|
32
79
|
}),
|
|
80
|
+
// Inside the flood and internal-error waiters, so each retry they make is a line of its own.
|
|
81
|
+
recordRequest,
|
|
33
82
|
noteAcceptedSend,
|
|
34
83
|
];
|
|
35
84
|
/** One send. A rate limit before Telegram accepted it sent nothing, so `retry.safe` may say so. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sending.js","sourceRoot":"","sources":["../../src/telegram/sending.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,kBAAkB,
|
|
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,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QAC1C,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc;YAAE,MAAM,KAAK,CAAA;QAClG,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAClF,CAAC;AACH,CAAC,CAAA"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.103.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.103.0";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/tg-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.103.0",
|
|
4
4
|
"description": "A local command line interface for a personal Telegram account, built for agents and scripts",
|
|
5
5
|
"mcpName": "dev.wirecat/tg-cli",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"spec/bot/LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "tsc --build --force &&
|
|
31
|
+
"build": "tsc --build --force && cli-dev bundle --bin dist/bin/tg.js --external \"@mtcute/*\" --external undici",
|
|
32
32
|
"typecheck": "tsc --build --force --emitDeclarationOnly && tsc -p tsconfig.test.json && tsc -p tsconfig.scripts.json",
|
|
33
33
|
"lint": "biome check .",
|
|
34
34
|
"lint:fix": "biome check --write .",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@mtcute/node": "0.32.7",
|
|
73
|
-
"@wirecat/cli-base": "0.
|
|
74
|
-
"@wirecat/cli-core": "0.
|
|
73
|
+
"@wirecat/cli-base": "0.65.0",
|
|
74
|
+
"@wirecat/cli-core": "0.469.0",
|
|
75
75
|
"commander": "15.0.0",
|
|
76
76
|
"undici": "8.12.3",
|
|
77
77
|
"valibot": "1.5.0"
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tgRequire } from "node:module";
|
|
2
|
-
const require = __tgRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
stringWidth,
|
|
5
|
-
wrapAnsi
|
|
6
|
-
} from "./chunk-ZZLKX62Z.js";
|
|
7
|
-
import {
|
|
8
|
-
singleLine,
|
|
9
|
-
visibleControls
|
|
10
|
-
} from "./chunk-DG62L57H.js";
|
|
11
|
-
import {
|
|
12
|
-
__name
|
|
13
|
-
} from "./chunk-AFV74GK3.js";
|
|
14
|
-
|
|
15
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
16
|
-
import { styleText } from "node:util";
|
|
17
|
-
var TIME_WIDTH = 8;
|
|
18
|
-
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
19
|
-
var MIN_WIDTH = 40;
|
|
20
|
-
var SENDER_COLOURS = ["green", "yellow", "magenta", "blue", "red"];
|
|
21
|
-
var renderMessages = /* @__PURE__ */ __name((messages, options = {}) => {
|
|
22
|
-
if (messages.length === 0)
|
|
23
|
-
return "(nothing)";
|
|
24
|
-
const day = dayFormatter(options);
|
|
25
|
-
const paint = painter(options);
|
|
26
|
-
let previous;
|
|
27
|
-
const blocks = [];
|
|
28
|
-
for (const message of messages) {
|
|
29
|
-
const date = day(message.timestamp);
|
|
30
|
-
if (date !== previous)
|
|
31
|
-
blocks.push(paint("dim", `\u2500\u2500 ${date} \u2500\u2500`));
|
|
32
|
-
previous = date;
|
|
33
|
-
blocks.push(renderMessage(message, options));
|
|
34
|
-
}
|
|
35
|
-
return blocks.join("\n\n");
|
|
36
|
-
}, "renderMessages");
|
|
37
|
-
var renderMessage = /* @__PURE__ */ __name((message, options = {}) => {
|
|
38
|
-
const paint = painter(options);
|
|
39
|
-
const width = Math.max(MIN_WIDTH, options.width ?? 80);
|
|
40
|
-
const room = width - INDENT.length;
|
|
41
|
-
const time = timeFormatter(options);
|
|
42
|
-
const verbosity = options.verbosity ?? 0;
|
|
43
|
-
const chat = "chatTitle" in message ? paint("dim", ` \xB7 ${singleLine(message.chatTitle ?? message.chatId)}`) : "";
|
|
44
|
-
const mark = "anchor" in message && message.anchor ? paint("bold", " \u25C0") : "";
|
|
45
|
-
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message, options)}${chat}${mark}`];
|
|
46
|
-
const body = /* @__PURE__ */ __name((text) => wrapAnsi(visibleControls(text), room, { hard: true }).split("\n"), "body");
|
|
47
|
-
const email = message.email;
|
|
48
|
-
if (email)
|
|
49
|
-
lines.push(paint("dim", mailLine(email)));
|
|
50
|
-
if (message.replyTo)
|
|
51
|
-
lines.push(paint("dim", preview("\u21B3", message.replyTo, room, options)));
|
|
52
|
-
if (message.forwardedFrom) {
|
|
53
|
-
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom, options)}`));
|
|
54
|
-
if (message.forwardedFrom.text)
|
|
55
|
-
for (const line of body(message.forwardedFrom.text))
|
|
56
|
-
lines.push(line);
|
|
57
|
-
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint, options));
|
|
58
|
-
}
|
|
59
|
-
if (message.text)
|
|
60
|
-
for (const line of body(message.text))
|
|
61
|
-
lines.push(line);
|
|
62
|
-
lines.push(...attachmentLines(message.attachments, paint, options));
|
|
63
|
-
if (message.reactions && message.reactions.total > 0)
|
|
64
|
-
lines.push(paint("dim", reactionLine(message.reactions)));
|
|
65
|
-
if (message.editedAt)
|
|
66
|
-
lines.push(paint("dim", `edited ${editedAt(message, options)}`));
|
|
67
|
-
if (verbosity >= 1) {
|
|
68
|
-
const fields = [
|
|
69
|
-
["message", message.id],
|
|
70
|
-
["sender", message.senderId],
|
|
71
|
-
["chat", message.chatId],
|
|
72
|
-
["reply to", message.replyTo?.id ?? message.replyToId],
|
|
73
|
-
["thread", message.threadId],
|
|
74
|
-
["forward of", message.forwardedFrom?.id],
|
|
75
|
-
...message.attachments.map((a) => ["link", a.url])
|
|
76
|
-
];
|
|
77
|
-
if (verbosity >= 2) {
|
|
78
|
-
fields.push(["provider", options.provider], ["profile", options.profile], ["sent", message.timestamp], ["edited", message.editedAt], ["outgoing", message.outgoing === null ? "unknown" : String(message.outgoing)], ...message.attachments.map((a) => ["attachment", JSON.stringify(a)]), ["metadata", message.providerMetadata && JSON.stringify(message.providerMetadata)]);
|
|
79
|
-
}
|
|
80
|
-
const shown = fields.filter((field) => typeof field[1] === "string");
|
|
81
|
-
const label = Math.max(...shown.map(([key]) => key.length));
|
|
82
|
-
lines.push("", ...shown.map(([key, value]) => paint("dim", `${key.padEnd(label)} ${singleLine(value)}`)));
|
|
83
|
-
}
|
|
84
|
-
return lines.map((line, index) => index === 0 || line === "" ? line : `${INDENT}${line}`).join("\n");
|
|
85
|
-
}, "renderMessage");
|
|
86
|
-
var mailLine = /* @__PURE__ */ __name(({ to, cc, labels }) => {
|
|
87
|
-
const names = /* @__PURE__ */ __name((people) => people.map(({ name, address }) => singleLine(name ?? address)).join(", "), "names");
|
|
88
|
-
return [to.length ? `to ${names(to)}` : "", cc.length ? `cc ${names(cc)}` : "", labels.join(", ")].filter(Boolean).join(" \xB7 ");
|
|
89
|
-
}, "mailLine");
|
|
90
|
-
var painter = /* @__PURE__ */ __name(({ color = false }) => (style, text) => color ? styleText(style, text, { validateStream: false }) : text, "painter");
|
|
91
|
-
var senderOf = /* @__PURE__ */ __name((message, options) => {
|
|
92
|
-
const paint = painter(options);
|
|
93
|
-
if (message.outgoing === true)
|
|
94
|
-
return paint(["bold", "cyan"], you(options));
|
|
95
|
-
const name = nameOf(message, options);
|
|
96
|
-
if (!options.senderColors)
|
|
97
|
-
return paint("bold", name);
|
|
98
|
-
const colour = SENDER_COLOURS[hash(message.senderId ?? name) % SENDER_COLOURS.length] ?? "green";
|
|
99
|
-
return paint(["bold", colour], name);
|
|
100
|
-
}, "senderOf");
|
|
101
|
-
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing }, options) => outgoing === true ? you(options) : singleLine(senderName ?? senderId ?? "unknown"), "nameOf");
|
|
102
|
-
var DEFAULT_LOCALE = "ru-RU";
|
|
103
|
-
var you = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE }) => locale.startsWith("ru") ? "\u0432\u044B" : "you", "you");
|
|
104
|
-
var hash = /* @__PURE__ */ __name((value) => [...value].reduce((sum, char) => sum * 31 + char.charCodeAt(0) >>> 0, 7), "hash");
|
|
105
|
-
var preview = /* @__PURE__ */ __name((mark, quoted, room, options) => {
|
|
106
|
-
const text = singleLine(quoted.text.split("\n")[0] ?? "") || (quoted.attachments[0] ? `\u{1F4CE} ${quoted.attachments[0].kind}` : "");
|
|
107
|
-
const line = text ? `${mark} ${nameOf(quoted, options)}: ${text}` : `${mark} message ${quoted.id}`;
|
|
108
|
-
if (stringWidth(line) <= room)
|
|
109
|
-
return line;
|
|
110
|
-
return `${wrapAnsi(line, room - 1, { hard: true }).split("\n")[0]}\u2026`;
|
|
111
|
-
}, "preview");
|
|
112
|
-
var attachmentLines = /* @__PURE__ */ __name((attachments, paint, options) => {
|
|
113
|
-
const link = /* @__PURE__ */ __name((label, raw) => {
|
|
114
|
-
if (raw === void 0)
|
|
115
|
-
return label;
|
|
116
|
-
const url = singleLine(raw);
|
|
117
|
-
return options.color ? `\x1B]8;;${url}\x07${label}\x1B]8;;\x07` : `${label} ${url}`;
|
|
118
|
-
}, "link");
|
|
119
|
-
let number = 0;
|
|
120
|
-
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++number} ${singleLine(button.text)}]`, button.url)).join(" ")));
|
|
121
|
-
const polls = attachments.flatMap((attachment) => attachment.poll ? pollLines(attachment.poll) : []);
|
|
122
|
-
const groups = /* @__PURE__ */ new Map();
|
|
123
|
-
for (const attachment of attachments) {
|
|
124
|
-
if (attachment.buttons || attachment.poll)
|
|
125
|
-
continue;
|
|
126
|
-
const key = singleLine(attachment.name ?? attachment.title ?? attachment.kind);
|
|
127
|
-
groups.set(key, [...groups.get(key) ?? [], attachment]);
|
|
128
|
-
}
|
|
129
|
-
const files = [...groups].map(([label, same]) => {
|
|
130
|
-
const first = same[0];
|
|
131
|
-
const size = first?.size === void 0 ? "" : ` \xB7 ${megabytes(first.size)}`;
|
|
132
|
-
if (same.length === 1)
|
|
133
|
-
return paint("dim", `\u{1F4CE} ${link(`${label}${size}`, first?.url)}`);
|
|
134
|
-
const each = same.map((attachment, index) => link(String(index + 1), attachment.url)).join(" ");
|
|
135
|
-
return paint("dim", `\u{1F4CE} ${label} \xD7${same.length} ${each}`);
|
|
136
|
-
});
|
|
137
|
-
return [...polls, ...files, ...keyboard];
|
|
138
|
-
}, "attachmentLines");
|
|
139
|
-
var pollLines = /* @__PURE__ */ __name((poll) => {
|
|
140
|
-
const kind = [
|
|
141
|
-
poll.closed ? "closed" : "",
|
|
142
|
-
poll.multiple ? "several answers" : "",
|
|
143
|
-
poll.anonymous ? "anonymous" : "",
|
|
144
|
-
poll.quiz ? "quiz" : ""
|
|
145
|
-
].filter(Boolean);
|
|
146
|
-
const count = /* @__PURE__ */ __name((voters) => voters === null ? "?" : String(voters), "count");
|
|
147
|
-
return [
|
|
148
|
-
`\u{1F4CA} ${visibleControls(poll.question)}`,
|
|
149
|
-
...poll.answers.map((answer) => ` [${answer.id}] ${visibleControls(answer.text)} \u2014 ${count(answer.voters)}${answer.chosen ? " \u2713" : ""}`),
|
|
150
|
-
` ${[`${count(poll.voters)} voted`, ...kind].join(" \xB7 ")}`
|
|
151
|
-
];
|
|
152
|
-
}, "pollLines");
|
|
153
|
-
var megabytes = /* @__PURE__ */ __name((bytes) => bytes >= 1e6 ? `${Math.round(bytes / 1e6)} MB` : `${Math.max(1, Math.round(bytes / 1e3))} KB`, "megabytes");
|
|
154
|
-
var parts = /* @__PURE__ */ __name((format, iso) => Object.fromEntries(format.formatToParts(new Date(iso)).map(({ type, value }) => [type, value])), "parts");
|
|
155
|
-
var timeFormatter = /* @__PURE__ */ __name(({ timeZone }) => {
|
|
156
|
-
const format = new Intl.DateTimeFormat("en-GB", {
|
|
157
|
-
hour: "2-digit",
|
|
158
|
-
minute: "2-digit",
|
|
159
|
-
second: "2-digit",
|
|
160
|
-
hourCycle: "h23",
|
|
161
|
-
...timeZone ? { timeZone } : {}
|
|
162
|
-
});
|
|
163
|
-
return (iso) => {
|
|
164
|
-
const { hour, minute, second } = parts(format, iso);
|
|
165
|
-
return `${hour}:${minute}:${second}`;
|
|
166
|
-
};
|
|
167
|
-
}, "timeFormatter");
|
|
168
|
-
var dayFormatter = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE, timeZone }) => {
|
|
169
|
-
const format = new Intl.DateTimeFormat(locale, {
|
|
170
|
-
day: "numeric",
|
|
171
|
-
month: "long",
|
|
172
|
-
year: "numeric",
|
|
173
|
-
...timeZone ? { timeZone } : {}
|
|
174
|
-
});
|
|
175
|
-
return (iso) => format.format(new Date(iso)).replace(/\s*г\.$/, "");
|
|
176
|
-
}, "dayFormatter");
|
|
177
|
-
var reactionLine = /* @__PURE__ */ __name(({ counts, mine }) => {
|
|
178
|
-
const shown = counts.map(({ reaction, count }) => `${singleLine(reaction)} ${count}`).join(" ");
|
|
179
|
-
return mine ? `${shown} (you: ${singleLine(mine)})` : shown;
|
|
180
|
-
}, "reactionLine");
|
|
181
|
-
var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
182
|
-
const edited = message.editedAt ?? message.timestamp;
|
|
183
|
-
const time = timeFormatter(options)(edited);
|
|
184
|
-
const day = dayFormatter(options);
|
|
185
|
-
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
186
|
-
}, "editedAt");
|
|
187
|
-
|
|
188
|
-
export {
|
|
189
|
-
renderMessages
|
|
190
|
-
};
|