blun-king-cli 9.1.124 → 9.1.125

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/LIESMICH.txt CHANGED
@@ -226,6 +226,16 @@ Im automatisch angebundenen Telegram-Kanal werden ausschließlich /loop, /goal,
226
226
  sie in der Warteschlange. Andere Slash-Eingaben werden aus Sicherheitsgründen
227
227
  als normale Chatnachrichten behandelt.
228
228
 
229
+ Rechner aus Telegram prüfen
230
+ ----------------------------
231
+ Der Telegram-Befehl /status prüft die lokale Verbindung ohne Modellaufruf. Er
232
+ zeigt den Rechnernamen, die installierte BLUN-Version, die Laufzeit der
233
+ Telegram-Brücke, die Verbindung zur Konsole, den aktuellen Zustellweg und die
234
+ Größe der Eingangswarteschlange. Damit bleibt der Zustand auch dann abfragbar,
235
+ wenn die Konsole hängt oder der Modellanbieter ausgelastet ist. Die Ausgabe enthält keine
236
+ Chat-IDs, Dateipfade, Zugangsdaten oder Nachrichteninhalte. Nicht verbundene
237
+ Absender erhalten weiterhin nur die Kopplungsanweisung.
238
+
229
239
  Nachweisbare Arbeitsabläufe
230
240
  ---------------------------
231
241
 
package/README.md CHANGED
@@ -242,6 +242,16 @@ Im automatisch angebundenen Telegram-Kanal werden ausschließlich `/loop`,
242
242
  beschäftigt, bleiben sie in der Warteschlange. Andere Slash-Eingaben werden aus
243
243
  Sicherheitsgründen als normale Chatnachrichten behandelt.
244
244
 
245
+ ### Rechner aus Telegram prüfen
246
+
247
+ Der Telegram-Befehl `/status` prüft die lokale Verbindung ohne Modellaufruf.
248
+ Er zeigt den Rechnernamen, die installierte BLUN-Version, die Laufzeit der
249
+ Telegram-Brücke, die Verbindung zur Konsole, den aktuellen Zustellweg und die
250
+ Größe der Eingangswarteschlange. Damit bleibt der Zustand auch dann abfragbar,
251
+ wenn die Konsole hängt oder der Modellanbieter ausgelastet ist. Die Ausgabe enthält keine
252
+ Chat-IDs, Dateipfade, Zugangsdaten oder Nachrichteninhalte. Nicht verbundene
253
+ Absender erhalten weiterhin nur die Kopplungsanweisung.
254
+
245
255
  Beim ersten Start werden das Telegram-Plugin und die mitgelieferten Skills
246
256
  eingerichtet. Die Anmeldung erfolgt anschließend in der
247
257
  Konsole mit `/login` über den BLUN-OAuth-Server. Das Paket erzeugt keine
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ function formatDuration(seconds) {
4
+ const minutes = Math.max(0, Math.floor(Number(seconds) / 60));
5
+ if (minutes < 60) return `${minutes} min`;
6
+ const hours = Math.floor(minutes / 60);
7
+ return `${hours} h ${minutes % 60} min`;
8
+ }
9
+
10
+ function formatBytes(bytes) {
11
+ const value = Math.max(0, Number(bytes) || 0);
12
+ if (value < 1024) return `${Math.round(value)} B`;
13
+ if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`;
14
+ return `${(value / (1024 * 1024)).toFixed(1)} MB`;
15
+ }
16
+
17
+ function buildTelegramRemoteStatus(input) {
18
+ if (!input?.access?.allowFrom?.includes(String(input.senderId))) {
19
+ return 'Nicht verbunden. Sende eine Nachricht, um einen Verbindungscode zu erhalten.';
20
+ }
21
+
22
+ const username = input.username ? `@${String(input.username).replace(/^@/u, '')}` : 'verbundener Nutzer';
23
+ const tui = input.tuiFresh
24
+ ? `verbunden${Number.isInteger(input.tuiPid) ? ` (PID ${input.tuiPid})` : ''}`
25
+ : 'nicht verbunden';
26
+ const delivery = input.deliveryTarget === 'tui'
27
+ ? 'Konsolen-Warteschlange'
28
+ : 'Brücke ohne Konsole';
29
+ return [
30
+ `BLUN-Fernstatus für ${username}`,
31
+ `Rechner: ${input.machineName || 'unbekannt'}`,
32
+ `Version: ${input.version || 'unbekannt'}`,
33
+ `Brücke: aktiv (PID ${input.bridgePid}, ${formatDuration(input.bridgeUptimeSeconds)})`,
34
+ `Konsole: ${tui}`,
35
+ `Zustellung: ${delivery}`,
36
+ `Warteschlange: ${formatBytes(input.queueBytes)}`,
37
+ `Gemessen: ${input.capturedAt}`,
38
+ ].join('\n');
39
+ }
40
+
41
+ module.exports = { buildTelegramRemoteStatus, formatBytes, formatDuration };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.124",
3
+ "version": "9.1.125",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -5,6 +5,9 @@ import { randomBytes } from "node:crypto";
5
5
  import { spawn } from "node:child_process";
6
6
  import { Readable, Writable } from "node:stream";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { hostname } from "node:os";
9
+ import remoteStatusPolicy from "../../bin/telegram-remote-status-policy.cjs";
10
+ const { buildTelegramRemoteStatus } = remoteStatusPolicy;
8
11
  //#region ../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
9
12
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
10
13
  function normalizeWindowsPath(input = "") {
@@ -4451,7 +4454,7 @@ async function pollWithBackoff(bot, isShuttingDown, onStarted) {
4451
4454
  },
4452
4455
  {
4453
4456
  command: "status",
4454
- description: "Check your pairing status"
4457
+ description: "Check machine and delivery status"
4455
4458
  }
4456
4459
  ], { scope: { type: "all_private_chats" } }).catch(() => {});
4457
4460
  } });
@@ -4672,8 +4675,32 @@ bot.command("status", async (ctx) => {
4672
4675
  if (gated === null) return;
4673
4676
  const { access, senderId } = gated;
4674
4677
  if (access.allowFrom.includes(senderId)) {
4675
- const name = ctx.from?.username !== void 0 ? `@${ctx.from.username}` : senderId;
4676
- await ctx.reply(`Paired as ${name}.`);
4678
+ let version = "unbekannt";
4679
+ let tuiPid;
4680
+ let queueBytes = 0;
4681
+ try {
4682
+ version = JSON.parse(readFileSync(join(dirname(KING_ENTRY), "package.json"), "utf8")).version ?? version;
4683
+ } catch {}
4684
+ try {
4685
+ tuiPid = parseInt(readFileSync(tuiPidFile(), "utf8"), 10);
4686
+ } catch {}
4687
+ try {
4688
+ queueBytes = statSync(tuiInboundQueueFile()).size;
4689
+ } catch {}
4690
+ await ctx.reply(buildTelegramRemoteStatus({
4691
+ access,
4692
+ bridgePid: process.pid,
4693
+ bridgeUptimeSeconds: process.uptime(),
4694
+ capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
4695
+ deliveryTarget: deliveryTarget(),
4696
+ machineName: hostname(),
4697
+ queueBytes,
4698
+ senderId,
4699
+ tuiFresh: isTuiLeaseFresh(),
4700
+ tuiPid: Number.isInteger(tuiPid) ? tuiPid : void 0,
4701
+ username: ctx.from?.username,
4702
+ version
4703
+ }));
4677
4704
  return;
4678
4705
  }
4679
4706
  for (const [code, pending] of Object.entries(access.pending)) if (pending.senderId === senderId) {