@locusai/locus-telegram 0.24.8 → 0.25.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.
@@ -9314,6 +9314,34 @@ import { execSync } from "node:child_process";
9314
9314
  import { existsSync } from "node:fs";
9315
9315
  import { dirname, join } from "node:path";
9316
9316
  import { fileURLToPath } from "node:url";
9317
+ function startHeartbeat(options) {
9318
+ const { processName, logger, intervalMs = DEFAULT_INTERVAL_MS } = options;
9319
+ const startedAt = Date.now();
9320
+ const tick = () => {
9321
+ const uptimeSec = Math.floor((Date.now() - startedAt) / 1000);
9322
+ const memUsage = process.memoryUsage();
9323
+ const heapMB = (memUsage.heapUsed / (1024 * 1024)).toFixed(1);
9324
+ const rssMB = (memUsage.rss / (1024 * 1024)).toFixed(1);
9325
+ logger.info(`[heartbeat] ${processName} alive — uptime: ${formatUptime(uptimeSec)}, heap: ${heapMB}MB, rss: ${rssMB}MB`);
9326
+ };
9327
+ tick();
9328
+ const timer = setInterval(tick, intervalMs);
9329
+ timer.unref();
9330
+ return () => clearInterval(timer);
9331
+ }
9332
+ function formatUptime(seconds) {
9333
+ const d = Math.floor(seconds / 86400);
9334
+ const h = Math.floor(seconds % 86400 / 3600);
9335
+ const m = Math.floor(seconds % 3600 / 60);
9336
+ const s = seconds % 60;
9337
+ if (d > 0)
9338
+ return `${d}d ${h}h ${m}m`;
9339
+ if (h > 0)
9340
+ return `${h}h ${m}m ${s}s`;
9341
+ if (m > 0)
9342
+ return `${m}m ${s}s`;
9343
+ return `${s}s`;
9344
+ }
9317
9345
  function getPm2Bin() {
9318
9346
  let dir = process.cwd();
9319
9347
  while (dir !== dirname(dir)) {
@@ -9417,7 +9445,10 @@ function resolvePackageScript(importMetaUrl, binName) {
9417
9445
  const packageRoot = dirname(dirname(currentFile));
9418
9446
  return join(packageRoot, "bin", `${binName}.js`);
9419
9447
  }
9420
- var init_dist = () => {};
9448
+ var DEFAULT_INTERVAL_MS;
9449
+ var init_dist = __esm(() => {
9450
+ DEFAULT_INTERVAL_MS = 5 * 60 * 1000;
9451
+ });
9421
9452
 
9422
9453
  // ../sdk/dist/index.js
9423
9454
  import { existsSync as existsSync2, readFileSync } from "node:fs";
@@ -9456,7 +9487,11 @@ function readLocusConfig(cwd) {
9456
9487
  const globalRaw = readJsonFile(globalPath) ?? {};
9457
9488
  const projectRaw = readJsonFile(projectPath) ?? {};
9458
9489
  const merged = deepMerge(deepMerge(DEFAULT_CONFIG, globalRaw), projectRaw);
9459
- return merged;
9490
+ const config = merged;
9491
+ if (config.sprint && "active" in config.sprint) {
9492
+ delete config.sprint.active;
9493
+ }
9494
+ return config;
9460
9495
  }
9461
9496
  function invokeLocusStream(args, cwd) {
9462
9497
  return spawn("locus", args, {
@@ -9515,8 +9550,7 @@ var init_dist2 = __esm(() => {
9515
9550
  rebaseBeforeTask: true
9516
9551
  },
9517
9552
  sprint: {
9518
- active: null,
9519
- stopOnFailure: true
9553
+ stopOnFailure: false
9520
9554
  },
9521
9555
  logging: {
9522
9556
  level: "normal",
@@ -10375,7 +10409,7 @@ function prCreatedMessage(prNumber, url) {
10375
10409
  `);
10376
10410
  }
10377
10411
  function serviceStatusMessage(status, pid, uptime, memory, restarts) {
10378
- const uptimeStr = uptime ? formatUptime(uptime) : "N/A";
10412
+ const uptimeStr = uptime ? formatUptime2(uptime) : "N/A";
10379
10413
  const memoryStr = memory ? formatMemory(memory) : "N/A";
10380
10414
  return [
10381
10415
  `\uD83E\uDD16 ${bold3("Locus Telegram Bot")}`,
@@ -10397,7 +10431,7 @@ function serviceNotRunningMessage() {
10397
10431
  ].join(`
10398
10432
  `);
10399
10433
  }
10400
- function formatUptime(startTimeMs) {
10434
+ function formatUptime2(startTimeMs) {
10401
10435
  const diff = Date.now() - startTimeMs;
10402
10436
  const seconds = Math.floor(diff / 1000);
10403
10437
  const minutes = Math.floor(seconds / 60);
@@ -11233,8 +11267,13 @@ async function handleBot() {
11233
11267
  }
11234
11268
  await bot.api.deleteWebhook({ drop_pending_updates: true });
11235
11269
  const runner = import_runner.run(bot);
11270
+ const stopHeartbeat = startHeartbeat({
11271
+ processName: "locus-telegram",
11272
+ logger: logger3
11273
+ });
11236
11274
  const shutdown = () => {
11237
11275
  logger3.info("Shutting down bot...");
11276
+ stopHeartbeat();
11238
11277
  runner.stop();
11239
11278
  process.exit(0);
11240
11279
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/locus-telegram",
3
- "version": "0.24.8",
3
+ "version": "0.25.0",
4
4
  "description": "Remote-control Locus via Telegram with full CLI mapping, git operations, and PM2 management",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@grammyjs/runner": "^2.0.3",
30
- "@locusai/locus-gateway": "^0.24.8",
31
- "@locusai/locus-pm2": "^0.24.8",
32
- "@locusai/sdk": "^0.24.8",
30
+ "@locusai/locus-gateway": "^0.25.0",
31
+ "@locusai/locus-pm2": "^0.25.0",
32
+ "@locusai/sdk": "^0.25.0",
33
33
  "grammy": "^1.35.0"
34
34
  },
35
35
  "devDependencies": {