@wirecat/tg-cli 0.101.0 → 0.102.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 (95) hide show
  1. package/dist/bin/tg.js +1 -1
  2. package/dist/bot/transport.d.ts.map +1 -1
  3. package/dist/bot/transport.js +14 -17
  4. package/dist/bot/transport.js.map +1 -1
  5. package/dist/bundle/{adapter-A3VD4Y6Z.js → adapter-M2HRSFFL.js} +90 -28
  6. package/dist/bundle/{all-profiles-UPVNHXB2.js → all-profiles-GOD2QNTK.js} +29 -8
  7. package/dist/bundle/{anthropic-IRKNWPIB.js → anthropic-LKU7RWMA.js} +3 -3
  8. package/dist/bundle/{bot-api-UNTQG2M5.js → bot-api-X3MPFVPL.js} +42 -46
  9. package/dist/bundle/{bot-history-V4RTY5K7.js → bot-history-OUMVVG22.js} +10 -10
  10. package/dist/bundle/{bun-2JZPG2NL.js → bun-LIZ6MKFS.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-TZHKM225.js → bun-sqlite-2IFQYQ44.js} +2 -2
  12. package/dist/bundle/{chunk-VA5YEJS3.js → chunk-264DAFJV.js} +4 -4
  13. package/dist/bundle/{chunk-ZV24I2UJ.js → chunk-2SUTCDGO.js} +1 -1
  14. package/dist/bundle/{chunk-BX6HH4F6.js → chunk-334UBWOB.js} +10 -10
  15. package/dist/bundle/{chunk-2DGOFLDA.js → chunk-4PDEQL6T.js} +1 -1
  16. package/dist/bundle/chunk-4QB4WDLT.js +922 -0
  17. package/dist/bundle/{chunk-MLLJ74LM.js → chunk-5D6OJREA.js} +1 -1
  18. package/dist/bundle/{chunk-RF54YDBB.js → chunk-5DFGJPT6.js} +4 -4
  19. package/dist/bundle/{chunk-TGREFJVA.js → chunk-5VSR5ENL.js} +7 -7
  20. package/dist/bundle/{chunk-VCGL2ETF.js → chunk-AUOXTGTU.js} +1 -1
  21. package/dist/bundle/{chunk-X4Y2ROJI.js → chunk-BBC546ZA.js} +91 -2
  22. package/dist/bundle/{chunk-QOWSVDPZ.js → chunk-BQYTIYGB.js} +106 -95
  23. package/dist/bundle/{chunk-XCKD54TN.js → chunk-CLWYQNSC.js} +5 -5
  24. package/dist/bundle/{chunk-7CBUCTB6.js → chunk-CRZPQQHE.js} +27 -33
  25. package/dist/bundle/chunk-DE7LFMY2.js +440 -0
  26. package/dist/bundle/{chunk-ODSVNH3H.js → chunk-ENE5CSVY.js} +2373 -1266
  27. package/dist/bundle/{chunk-G2US6LJB.js → chunk-ERQDBK5I.js} +1 -1
  28. package/dist/bundle/{chunk-W2336E7Y.js → chunk-F2TG3BA2.js} +4 -4
  29. package/dist/bundle/{chunk-DYNSP6FW.js → chunk-FBWOQMPE.js} +1442 -769
  30. package/dist/bundle/{chunk-5TPT2S2Z.js → chunk-FOUE7XLK.js} +1 -1
  31. package/dist/bundle/{chunk-RVCS7Q3A.js → chunk-GSKFAE3I.js} +1287 -512
  32. package/dist/bundle/{chunk-6IPY2QRG.js → chunk-HLAZ65AW.js} +1 -1
  33. package/dist/bundle/{chunk-A5JSTZZZ.js → chunk-JFSVXMN6.js} +2 -2
  34. package/dist/bundle/{chunk-N5UFBWDM.js → chunk-M5UH5CF3.js} +5 -7
  35. package/dist/bundle/{chunk-F7TDFWXY.js → chunk-MGG7JSNO.js} +2 -2
  36. package/dist/bundle/{chunk-H6OXALTJ.js → chunk-OCWARAFE.js} +1 -1
  37. package/dist/bundle/{chunk-S7ZNLLY5.js → chunk-OHBHHBYL.js} +2 -2
  38. package/dist/bundle/{chunk-5GKXETRP.js → chunk-PSH7K6TL.js} +610 -51
  39. package/dist/bundle/{chunk-VYDTI254.js → chunk-Q2NYEX4A.js} +53 -34
  40. package/dist/bundle/{chunk-G3ZRY436.js → chunk-QEPZUFPL.js} +46 -46
  41. package/dist/bundle/{chunk-BXQS5RCE.js → chunk-QL7CQ6VZ.js} +253 -78
  42. package/dist/bundle/{chunk-NC5WS7OP.js → chunk-SRU3OF4R.js} +1 -1
  43. package/dist/bundle/{chunk-PUBS2F5J.js → chunk-TV5DGHBT.js} +242 -242
  44. package/dist/bundle/{chunk-ZEOCU24Z.js → chunk-TXBUDJ3P.js} +1 -1
  45. package/dist/bundle/{chunk-ACGTFLEB.js → chunk-U4RRZUNP.js} +8 -8
  46. package/dist/bundle/{chunk-LPB2MDUW.js → chunk-UK3GAN7Q.js} +6 -6
  47. package/dist/bundle/{chunk-UN6CKIBN.js → chunk-UR6ASUSG.js} +8 -5
  48. package/dist/bundle/{chunk-U46UNBMT.js → chunk-V52SBQYF.js} +236 -13
  49. package/dist/bundle/{chunk-S2JSZWEC.js → chunk-VUJ34PEQ.js} +9 -9
  50. package/dist/bundle/{chunk-QYVVRQTN.js → chunk-W5EB4JLV.js} +2 -2
  51. package/dist/bundle/{chunk-3KHKYYCR.js → chunk-WMOEOVWZ.js} +1 -0
  52. package/dist/bundle/{chunk-VRSN7VLO.js → chunk-WVEHUKCZ.js} +1 -1
  53. package/dist/bundle/{chunk-64DK7S4F.js → chunk-XXTJUZMB.js} +1 -1
  54. package/dist/bundle/{chunk-54R2GDQ3.js → chunk-Y4XSWI22.js} +3 -3
  55. package/dist/bundle/{chunk-4ZS73HTJ.js → chunk-YHB57PFN.js} +1 -1
  56. package/dist/bundle/{chunk-G77QOTXE.js → chunk-ZRNRQFTF.js} +1 -1
  57. package/dist/bundle/{command-contract-TKDI7E56.js → command-contract-A6VZN3ZR.js} +11 -11
  58. package/dist/bundle/{echarts-QZ6PR3VC.js → echarts-27W2CIBD.js} +2 -2
  59. package/dist/bundle/{embed-UBXCXSRD.js → embed-FGJ273X2.js} +2 -2
  60. package/dist/bundle/{embedder-B4ZTKC23.js → embedder-7ELL3CQ3.js} +5 -5
  61. package/dist/bundle/{entry-BTUTHO5M.js → entry-SEE5YWIX.js} +3 -3
  62. package/dist/bundle/{first-run-UC4HRIFV.js → first-run-BD7FEC3W.js} +5 -5
  63. package/dist/bundle/{first-screen-SMCX6YKY.js → first-screen-ASZV6LSA.js} +12 -12
  64. package/dist/bundle/{identity-QSDEGDH7.js → identity-QR4F42T6.js} +1 -1
  65. package/dist/bundle/{instructions-BBGLZKO3.js → instructions-L74K64PV.js} +1 -1
  66. package/dist/bundle/{node-LZZX22VR.js → node-RSL3HANO.js} +2 -2
  67. package/dist/bundle/{node-sqlite-BPGT6T5U.js → node-sqlite-7R3PYQGJ.js} +2 -2
  68. package/dist/bundle/{oauth-XNE2KPKJ.js → oauth-4ESGXF6U.js} +5 -5
  69. package/dist/bundle/{open-SXGYZLB5.js → open-DFYEUGTA.js} +1 -1
  70. package/dist/bundle/{process-GPUXC4PG.js → process-RMV3AKLB.js} +1 -1
  71. package/dist/bundle/{program-NEXEAL7T.js → program-PIUYQHBF.js} +54 -59
  72. package/dist/bundle/{prompt-SORGLEYI.js → prompt-H7GYQQLL.js} +2 -2
  73. package/dist/bundle/{recognize-UJBXORVD.js → recognize-3GMOLZF4.js} +3 -3
  74. package/dist/bundle/{remote-W72AR7KH.js → remote-IRWTCI2B.js} +3 -3
  75. package/dist/bundle/{rerank-3Y2VZM3J.js → rerank-W3OSXXBN.js} +3 -3
  76. package/dist/bundle/{serve-VDZIVOPR.js → serve-ZCPO44NO.js} +7 -7
  77. package/dist/bundle/{server-ZFHN4GUF.js → server-FXU4QFRB.js} +35 -32
  78. package/dist/bundle/{server-BERXP4GW.js → server-YWL4HDOP.js} +68 -59
  79. package/dist/bundle/{state-DGR4EE3E.js → state-MJPTDIB5.js} +3 -3
  80. package/dist/bundle/{store-MRCFSCZD.js → store-6VNQG56O.js} +7 -7
  81. package/dist/bundle/store-maintenance-command-62TQTMER.js +43 -0
  82. package/dist/bundle/tg.js +2 -2
  83. package/dist/telegram/sending.d.ts.map +1 -1
  84. package/dist/telegram/sending.js +52 -3
  85. package/dist/telegram/sending.js.map +1 -1
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +2 -2
  89. package/dist/bundle/chunk-22PQUX72.js +0 -190
  90. package/dist/bundle/chunk-CJ6IYCYP.js +0 -583
  91. package/dist/bundle/chunk-NKJJJAIJ.js +0 -237
  92. package/dist/bundle/chunk-NMGO6LW6.js +0 -1950
  93. package/dist/bundle/chunk-OILBDLWL.js +0 -724
  94. package/dist/bundle/chunk-OPBTNQ35.js +0 -1007
  95. package/dist/bundle/store-maintenance-command-DCMZDMYS.js +0 -46
@@ -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
- };