kernelbot 1.0.8 → 1.0.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/agent.js +48 -2
  3. package/src/bot.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kernelbot",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "KernelBot — AI engineering agent with full OS control",
5
5
  "type": "module",
6
6
  "author": "Abdullah Al-Taheri <abdullah@altaheri.me>",
package/src/agent.js CHANGED
@@ -13,9 +13,11 @@ export class Agent {
13
13
  this._pending = new Map(); // chatId -> pending state
14
14
  }
15
15
 
16
- async processMessage(chatId, userMessage, user) {
16
+ async processMessage(chatId, userMessage, user, onUpdate) {
17
17
  const logger = getLogger();
18
18
 
19
+ this._onUpdate = onUpdate || null;
20
+
19
21
  // Handle pending responses (confirmation or credential)
20
22
  const pending = this._pending.get(chatId);
21
23
  if (pending) {
@@ -41,6 +43,40 @@ export class Agent {
41
43
  return await this._runLoop(chatId, messages, user, 0, max_tool_depth);
42
44
  }
43
45
 
46
+ _formatToolSummary(name, input) {
47
+ const key = {
48
+ execute_command: 'command',
49
+ read_file: 'path',
50
+ write_file: 'path',
51
+ list_directory: 'path',
52
+ git_clone: 'repo',
53
+ git_checkout: 'branch',
54
+ git_commit: 'message',
55
+ git_push: 'dir',
56
+ git_diff: 'dir',
57
+ github_create_pr: 'title',
58
+ github_create_repo: 'name',
59
+ github_list_prs: 'repo',
60
+ github_get_pr_diff: 'repo',
61
+ github_post_review: 'repo',
62
+ spawn_claude_code: 'prompt',
63
+ kill_process: 'pid',
64
+ docker_exec: 'container',
65
+ docker_logs: 'container',
66
+ docker_compose: 'action',
67
+ curl_url: 'url',
68
+ check_port: 'port',
69
+ }[name];
70
+ const val = key && input[key] ? String(input[key]).slice(0, 120) : JSON.stringify(input).slice(0, 120);
71
+ return `${name}: ${val}`;
72
+ }
73
+
74
+ async _sendUpdate(text) {
75
+ if (this._onUpdate) {
76
+ try { await this._onUpdate(text); } catch {}
77
+ }
78
+ }
79
+
44
80
  async _handleCredentialResponse(chatId, userMessage, user, pending) {
45
81
  const logger = getLogger();
46
82
  const value = userMessage.trim();
@@ -186,6 +222,14 @@ export class Agent {
186
222
  if (response.stop_reason === 'tool_use') {
187
223
  messages.push({ role: 'assistant', content: response.content });
188
224
 
225
+ // Send Claude's thinking text to the user
226
+ const thinkingBlocks = response.content.filter((b) => b.type === 'text' && b.text.trim());
227
+ if (thinkingBlocks.length > 0) {
228
+ const thinking = thinkingBlocks.map((b) => b.text).join('\n');
229
+ logger.info(`Agent thinking: ${thinking.slice(0, 200)}`);
230
+ await this._sendUpdate(`💭 ${thinking}`);
231
+ }
232
+
189
233
  const toolUseBlocks = response.content.filter((b) => b.type === 'tool_use');
190
234
  const toolResults = [];
191
235
 
@@ -203,7 +247,9 @@ export class Agent {
203
247
  );
204
248
  if (pauseMsg) return pauseMsg;
205
249
 
206
- logger.info(`Tool call: ${block.name}`);
250
+ const summary = this._formatToolSummary(block.name, block.input);
251
+ logger.info(`Tool call: ${summary}`);
252
+ await this._sendUpdate(`🔧 \`${summary}\``);
207
253
 
208
254
  const result = await executeTool(block.name, block.input, {
209
255
  config: this.config,
package/src/bot.js CHANGED
@@ -50,10 +50,21 @@ export function startBot(config, agent) {
50
50
  bot.sendChatAction(chatId, 'typing').catch(() => {});
51
51
 
52
52
  try {
53
+ const onUpdate = async (text) => {
54
+ const parts = splitMessage(text);
55
+ for (const part of parts) {
56
+ try {
57
+ await bot.sendMessage(chatId, part, { parse_mode: 'Markdown' });
58
+ } catch {
59
+ await bot.sendMessage(chatId, part);
60
+ }
61
+ }
62
+ };
63
+
53
64
  const reply = await agent.processMessage(chatId, msg.text, {
54
65
  id: userId,
55
66
  username,
56
- });
67
+ }, onUpdate);
57
68
 
58
69
  clearInterval(typingInterval);
59
70