@gonzih/cc-tg 0.2.7 → 0.2.9

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/bot.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare class CcTgBot {
38
38
  private handleReloadMcp;
39
39
  private handleMcpVersion;
40
40
  private handleClearNpxCache;
41
+ private handleRestart;
41
42
  private killSession;
42
43
  stop(): void;
43
44
  }
package/dist/bot.js CHANGED
@@ -5,7 +5,7 @@
5
5
  import TelegramBot from "node-telegram-bot-api";
6
6
  import { existsSync, createWriteStream, mkdirSync } from "fs";
7
7
  import { resolve, basename, join } from "path";
8
- import { execSync } from "child_process";
8
+ import { execSync, spawn } from "child_process";
9
9
  import https from "https";
10
10
  import http from "http";
11
11
  import { ClaudeProcess, extractText } from "./claude.js";
@@ -21,6 +21,7 @@ const BOT_COMMANDS = [
21
21
  { command: "reload_mcp", description: "Restart the cc-agent MCP server process" },
22
22
  { command: "mcp_version", description: "Show cc-agent npm version and npx cache info" },
23
23
  { command: "clear_npx_cache", description: "Clear npx cache and restart MCP to pick up latest version" },
24
+ { command: "restart", description: "Restart the bot process in-place" },
24
25
  ];
25
26
  const FLUSH_DELAY_MS = 800; // debounce streaming chunks into one Telegram message
26
27
  const TYPING_INTERVAL_MS = 4000; // re-send typing action before Telegram's 5s expiry
@@ -131,6 +132,11 @@ export class CcTgBot {
131
132
  await this.handleClearNpxCache(chatId);
132
133
  return;
133
134
  }
135
+ // /restart — restart the bot process in-place
136
+ if (text === "/restart") {
137
+ await this.handleRestart(chatId);
138
+ return;
139
+ }
134
140
  const session = this.getOrCreateSession(chatId);
135
141
  try {
136
142
  session.claude.sendPrompt(text);
@@ -606,6 +612,18 @@ export class CcTgBot {
606
612
  : " No cc-agent process found (will start fresh on next call).";
607
613
  await this.bot.sendMessage(chatId, `NPX cache cleared and MCP restarted.${pidNote} Will pick up latest npm version on next call.`);
608
614
  }
615
+ async handleRestart(chatId) {
616
+ await this.bot.sendMessage(chatId, "Restarting bot... brb.");
617
+ await new Promise(resolve => setTimeout(resolve, 1000));
618
+ this.stop();
619
+ const child = spawn(process.execPath, process.argv.slice(1), {
620
+ detached: true,
621
+ stdio: "inherit",
622
+ env: process.env,
623
+ });
624
+ child.unref();
625
+ process.exit(0);
626
+ }
609
627
  killSession(chatId, keepCrons = true) {
610
628
  const session = this.sessions.get(chatId);
611
629
  if (session) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-tg",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {