@wirecat/tg-cli 0.99.0 → 0.100.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 (112) hide show
  1. package/README.md +3 -2
  2. package/dist/bin/tg.js +23 -28
  3. package/dist/bundle/adapter-2LVPMFKF.js +2790 -0
  4. package/dist/bundle/all-profiles-BLTK2AAB.js +255 -0
  5. package/dist/bundle/anthropic-RJE4XEOO.js +71 -0
  6. package/dist/bundle/bot-api-4XM3NVWG.js +39793 -0
  7. package/dist/bundle/bot-history-WVM5GEQN.js +167 -0
  8. package/dist/bundle/bun-UZXO2LRQ.js +169 -0
  9. package/dist/bundle/bun-sqlite-GJLGSQIT.js +70 -0
  10. package/dist/bundle/chunk-2IM4M7Q2.js +98 -0
  11. package/dist/bundle/chunk-2MXQ2EUN.js +1344 -0
  12. package/dist/bundle/chunk-2XUGPE5W.js +73 -0
  13. package/dist/bundle/chunk-3KHKYYCR.js +24782 -0
  14. package/dist/bundle/chunk-3MVHRZWR.js +2 -0
  15. package/dist/bundle/chunk-3N6LXAPE.js +724 -0
  16. package/dist/bundle/chunk-3QDPV34J.js +6668 -0
  17. package/dist/bundle/chunk-3S5CL55R.js +100 -0
  18. package/dist/bundle/chunk-4U7QOFDA.js +33511 -0
  19. package/dist/bundle/chunk-4VBDVZNE.js +524 -0
  20. package/dist/bundle/chunk-4YCLWWZ3.js +277 -0
  21. package/dist/bundle/chunk-66E5QDLH.js +24 -0
  22. package/dist/bundle/chunk-6VEOR6GD.js +166 -0
  23. package/dist/bundle/chunk-6YLT4YVJ.js +45 -0
  24. package/dist/bundle/chunk-7BFO3DY6.js +21 -0
  25. package/dist/bundle/chunk-A7OBVRJV.js +738 -0
  26. package/dist/bundle/chunk-AFV74GK3.js +50 -0
  27. package/dist/bundle/chunk-ASDZHG5I.js +25 -0
  28. package/dist/bundle/chunk-ATZ44Z77.js +3253 -0
  29. package/dist/bundle/chunk-AVWK4NCW.js +24600 -0
  30. package/dist/bundle/chunk-BAIZAZ6Q.js +82 -0
  31. package/dist/bundle/chunk-BJG6JA5U.js +35 -0
  32. package/dist/bundle/chunk-BL36RR34.js +285 -0
  33. package/dist/bundle/chunk-BZANDKWT.js +71 -0
  34. package/dist/bundle/chunk-CV5ASHTW.js +8170 -0
  35. package/dist/bundle/chunk-DN4QUTWU.js +78 -0
  36. package/dist/bundle/chunk-DVOUKGFK.js +1950 -0
  37. package/dist/bundle/chunk-GTURDJJD.js +570 -0
  38. package/dist/bundle/chunk-GYEOQS2D.js +2795 -0
  39. package/dist/bundle/chunk-H3X5LS6U.js +153 -0
  40. package/dist/bundle/chunk-HKT5EOT5.js +6848 -0
  41. package/dist/bundle/chunk-HXTTDIL7.js +82 -0
  42. package/dist/bundle/chunk-I6WZJVRT.js +1123 -0
  43. package/dist/bundle/chunk-JFJVS5JC.js +41 -0
  44. package/dist/bundle/chunk-JSKT5UZX.js +2315 -0
  45. package/dist/bundle/chunk-KE6L2UEG.js +3068 -0
  46. package/dist/bundle/chunk-LI7TXFLS.js +122 -0
  47. package/dist/bundle/chunk-MQNFEVAH.js +58 -0
  48. package/dist/bundle/chunk-MUEXF4ME.js +582 -0
  49. package/dist/bundle/chunk-OOOV3JBZ.js +35527 -0
  50. package/dist/bundle/chunk-OW3COBN5.js +1275 -0
  51. package/dist/bundle/chunk-P26LWFNZ.js +35 -0
  52. package/dist/bundle/chunk-Q26JMPBP.js +215 -0
  53. package/dist/bundle/chunk-QU2FJMFB.js +18282 -0
  54. package/dist/bundle/chunk-QY3YOOTP.js +18 -0
  55. package/dist/bundle/chunk-RDQMV6EU.js +46 -0
  56. package/dist/bundle/chunk-RER6DAHP.js +3514 -0
  57. package/dist/bundle/chunk-SGJYU3SB.js +54 -0
  58. package/dist/bundle/chunk-SMJTL5U7.js +117 -0
  59. package/dist/bundle/chunk-SYPL4PHV.js +76 -0
  60. package/dist/bundle/chunk-THVNP6S6.js +31 -0
  61. package/dist/bundle/chunk-U7LXA4SO.js +1007 -0
  62. package/dist/bundle/chunk-UD4DOZCN.js +886 -0
  63. package/dist/bundle/chunk-UMLPXNJI.js +63 -0
  64. package/dist/bundle/chunk-V4JSVH4M.js +190 -0
  65. package/dist/bundle/chunk-WE3LBRMB.js +2374 -0
  66. package/dist/bundle/chunk-WKOY3POD.js +452 -0
  67. package/dist/bundle/chunk-X4Y2ROJI.js +541 -0
  68. package/dist/bundle/chunk-YG7PNCSW.js +230 -0
  69. package/dist/bundle/chunk-Z2FHEIXN.js +63 -0
  70. package/dist/bundle/chunk-ZZLKX62Z.js +928 -0
  71. package/dist/bundle/command-contract-AIVKJYIR.js +31 -0
  72. package/dist/bundle/dist-RJMT44PL.js +7577 -0
  73. package/dist/bundle/echarts-YHSYUWLY.js +42501 -0
  74. package/dist/bundle/embed-3HGI2XIW.js +35 -0
  75. package/dist/bundle/embedder-2CJMZETJ.js +108 -0
  76. package/dist/bundle/entry-UVE53OV3.js +14 -0
  77. package/dist/bundle/first-run-6GYC2QS3.js +24 -0
  78. package/dist/bundle/first-screen-HRRLVLOG.js +29 -0
  79. package/dist/bundle/identity-HEV5E57G.js +11 -0
  80. package/dist/bundle/instructions-5UVAXSQV.js +9 -0
  81. package/dist/bundle/mcp-NWXBVNUA.js +165 -0
  82. package/dist/bundle/node-IUL5HSYI.js +2340 -0
  83. package/dist/bundle/node-UPPL626U.js +21 -0
  84. package/dist/bundle/node-YHYEGYVE.js +176 -0
  85. package/dist/bundle/node-sqlite-CQ33A3R2.js +46 -0
  86. package/dist/bundle/oauth-OB3JFAD7.js +18 -0
  87. package/dist/bundle/open-JHGZIXU2.js +20 -0
  88. package/dist/bundle/process-PSKS3N5B.js +91 -0
  89. package/dist/bundle/program-RPYVPNRX.js +1060 -0
  90. package/dist/bundle/prompt-7BXUMJGG.js +13 -0
  91. package/dist/bundle/proxy-transport-3EEMW2HW.js +17 -0
  92. package/dist/bundle/recognize-YMZPL47R.js +191 -0
  93. package/dist/bundle/remote-LQ3Q22NG.js +26 -0
  94. package/dist/bundle/rerank-SM7IYVXJ.js +49 -0
  95. package/dist/bundle/serve-GHUEP5H5.js +181 -0
  96. package/dist/bundle/server-A45HVXQY.js +178 -0
  97. package/dist/bundle/server-K2BQPPHN.js +785 -0
  98. package/dist/bundle/state-WIOL52GZ.js +30 -0
  99. package/dist/bundle/store-XE5AKUJZ.js +121 -0
  100. package/dist/bundle/store-maintenance-command-YS5E7VUN.js +46 -0
  101. package/dist/bundle/tg.js +40 -0
  102. package/dist/commands/context.d.ts.map +1 -1
  103. package/dist/commands/context.js +1 -1
  104. package/dist/commands/context.js.map +1 -1
  105. package/dist/install/postinstall.js +1 -1
  106. package/dist/install/postinstall.js.map +1 -1
  107. package/dist/version.d.ts +1 -1
  108. package/dist/version.d.ts.map +1 -1
  109. package/dist/version.js +1 -1
  110. package/dist/version.js.map +1 -1
  111. package/package.json +4 -2
  112. /package/skills/{wirecat-tg → tg-cli}/SKILL.md +0 -0
@@ -0,0 +1,63 @@
1
+ import { createRequire as __tgRequire } from "node:module";
2
+ const require = __tgRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-AFV74GK3.js";
6
+
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/background/processes.js
8
+ import { execFileSync } from "node:child_process";
9
+ import { readdirSync, readFileSync, readlinkSync } from "node:fs";
10
+ var alive = /* @__PURE__ */ __name((pid) => {
11
+ try {
12
+ process.kill(pid, 0);
13
+ return true;
14
+ } catch (error) {
15
+ return error.code === "EPERM";
16
+ }
17
+ }, "alive");
18
+ var carries = /* @__PURE__ */ __name((pid, marker) => {
19
+ if (pid <= 0 || !alive(pid))
20
+ return false;
21
+ try {
22
+ if (process.platform === "linux") {
23
+ return readFileSync(`/proc/${pid}/environ`, "latin1").split("\0").some((entry) => entry.endsWith(marker));
24
+ }
25
+ if (process.platform === "darwin") {
26
+ return execFileSync("ps", ["eww", "-o", "command=", "-p", String(pid)], { encoding: "utf8" }).includes(marker);
27
+ }
28
+ } catch {
29
+ return false;
30
+ }
31
+ return false;
32
+ }, "carries");
33
+ var holdersOf = /* @__PURE__ */ __name((paths) => {
34
+ if (process.platform === "linux") {
35
+ const wanted = new Set(paths);
36
+ return readdirSync("/proc").filter((entry) => /^\d+$/.test(entry) && Number(entry) !== process.pid).filter((pid) => {
37
+ try {
38
+ return readdirSync(`/proc/${pid}/fd`).some((fd) => {
39
+ try {
40
+ return wanted.has(readlinkSync(`/proc/${pid}/fd/${fd}`));
41
+ } catch {
42
+ return false;
43
+ }
44
+ });
45
+ } catch {
46
+ return false;
47
+ }
48
+ }).map(Number);
49
+ }
50
+ const pids = /* @__PURE__ */ __name((listed) => listed.split("\n").filter(Boolean).map(Number).filter((pid) => pid !== process.pid), "pids");
51
+ try {
52
+ return pids(execFileSync("lsof", ["-t", "--", ...paths], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }));
53
+ } catch (error) {
54
+ const { status, stdout } = error;
55
+ return status === 1 ? pids(stdout ?? "") : void 0;
56
+ }
57
+ }, "holdersOf");
58
+
59
+ export {
60
+ alive,
61
+ carries,
62
+ holdersOf
63
+ };
@@ -0,0 +1,190 @@
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-GYEOQS2D.js";
11
+ import {
12
+ __name
13
+ } from "./chunk-AFV74GK3.js";
14
+
15
+ // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
+ };