@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 +1 -0
- package/dist/bot.js +29 -7
- package/package.json +1 -1
package/dist/bot.d.ts
CHANGED
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) =>
|
|
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
|
-
|
|
74
|
-
if (
|
|
75
|
-
console.error(`[claude:${chatId}]`,
|
|
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
|
|
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
|
|
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) {
|