@gonzih/cc-tg 0.1.3 → 0.1.4

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
@@ -20,6 +20,7 @@ export declare class CcTgBot {
20
20
  private startTyping;
21
21
  private stopTyping;
22
22
  private flushPending;
23
+ private extractToolName;
23
24
  private killSession;
24
25
  stop(): void;
25
26
  }
package/dist/bot.js CHANGED
@@ -68,20 +68,41 @@ export class CcTgBot {
68
68
  flushTimer: null,
69
69
  typingTimer: null,
70
70
  };
71
- claude.on("message", (msg) => this.handleClaudeMessage(chatId, session, msg));
72
- claude.on("stderr", (data) => {
73
- // Only surface non-noise stderr
74
- if (data.includes("Error") || data.includes("error")) {
75
- console.error(`[claude:${chatId}]`, data.trim());
71
+ claude.on("message", (msg) => {
72
+ // Verbose logging — log every message type and subtype
73
+ const subtype = msg.payload.subtype ?? "";
74
+ const toolName = this.extractToolName(msg);
75
+ const logParts = [`[claude:${chatId}] msg=${msg.type}`];
76
+ if (subtype)
77
+ logParts.push(`subtype=${subtype}`);
78
+ if (toolName)
79
+ logParts.push(`tool=${toolName}`);
80
+ console.log(logParts.join(" "));
81
+ // Surface tool activity to Telegram as a status line
82
+ if (msg.type === "assistant" && toolName) {
83
+ this.bot.sendMessage(chatId, `⚙️ ${toolName}...`).catch(() => { });
84
+ }
85
+ if (msg.type === "system" && subtype === "task_progress") {
86
+ const desc = msg.payload.description ?? "";
87
+ if (desc)
88
+ this.bot.sendMessage(chatId, `🔍 ${desc}`).catch(() => { });
76
89
  }
90
+ this.handleClaudeMessage(chatId, session, msg);
91
+ });
92
+ claude.on("stderr", (data) => {
93
+ const line = data.trim();
94
+ if (line)
95
+ console.error(`[claude:${chatId}:stderr]`, line);
77
96
  });
78
97
  claude.on("exit", (code) => {
79
- console.log(`[claude:${chatId}] exited with code ${code}`);
98
+ console.log(`[claude:${chatId}] exited code=${code}`);
99
+ this.stopTyping(session);
80
100
  this.sessions.delete(chatId);
81
101
  });
82
102
  claude.on("error", (err) => {
83
- console.error(`[claude:${chatId}] process error:`, err.message);
103
+ console.error(`[claude:${chatId}] process error: ${err.message}`);
84
104
  this.bot.sendMessage(chatId, `Claude process error: ${err.message}`).catch(() => { });
105
+ this.stopTyping(session);
85
106
  this.sessions.delete(chatId);
86
107
  });
87
108
  this.sessions.set(chatId, session);
@@ -131,6 +152,16 @@ export class CcTgBot {
131
152
  });
132
153
  }
133
154
  }
155
+ extractToolName(msg) {
156
+ const message = msg.payload.message;
157
+ if (!message)
158
+ return "";
159
+ const content = message.content;
160
+ if (!Array.isArray(content))
161
+ return "";
162
+ const toolUse = content.find((b) => b.type === "tool_use");
163
+ return toolUse?.name ?? "";
164
+ }
134
165
  killSession(chatId) {
135
166
  const session = this.sessions.get(chatId);
136
167
  if (session) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-tg",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {