@gonzih/cc-tg 0.1.3 → 0.1.5

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,32 @@ export class CcTgBot {
68
68
  flushTimer: null,
69
69
  typingTimer: null,
70
70
  };
71
- claude.on("message", (msg) => this.handleClaudeMessage(chatId, session, msg));
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
+ this.handleClaudeMessage(chatId, session, msg);
82
+ });
72
83
  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());
76
- }
84
+ const line = data.trim();
85
+ if (line)
86
+ console.error(`[claude:${chatId}:stderr]`, line);
77
87
  });
78
88
  claude.on("exit", (code) => {
79
- console.log(`[claude:${chatId}] exited with code ${code}`);
89
+ console.log(`[claude:${chatId}] exited code=${code}`);
90
+ this.stopTyping(session);
80
91
  this.sessions.delete(chatId);
81
92
  });
82
93
  claude.on("error", (err) => {
83
- console.error(`[claude:${chatId}] process error:`, err.message);
94
+ console.error(`[claude:${chatId}] process error: ${err.message}`);
84
95
  this.bot.sendMessage(chatId, `Claude process error: ${err.message}`).catch(() => { });
96
+ this.stopTyping(session);
85
97
  this.sessions.delete(chatId);
86
98
  });
87
99
  this.sessions.set(chatId, session);
@@ -131,6 +143,16 @@ export class CcTgBot {
131
143
  });
132
144
  }
133
145
  }
146
+ extractToolName(msg) {
147
+ const message = msg.payload.message;
148
+ if (!message)
149
+ return "";
150
+ const content = message.content;
151
+ if (!Array.isArray(content))
152
+ return "";
153
+ const toolUse = content.find((b) => b.type === "tool_use");
154
+ return toolUse?.name ?? "";
155
+ }
134
156
  killSession(chatId) {
135
157
  const session = this.sessions.get(chatId);
136
158
  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.5",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {