kernelbot 1.0.12 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kernelbot",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
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
@@ -99,6 +99,7 @@ export class Agent {
99
99
  const result = await executeTool(pending.block.name, pending.block.input, {
100
100
  config: this.config,
101
101
  user,
102
+ onUpdate: this._onUpdate,
102
103
  });
103
104
 
104
105
  pending.toolResults.push({
@@ -116,7 +117,7 @@ export class Agent {
116
117
 
117
118
  if (lower === 'yes' || lower === 'y' || lower === 'confirm') {
118
119
  logger.info(`User confirmed dangerous tool: ${pending.block.name}`);
119
- const result = await executeTool(pending.block.name, pending.block.input, pending.context);
120
+ const result = await executeTool(pending.block.name, pending.block.input, { ...pending.context, onUpdate: this._onUpdate });
120
121
 
121
122
  pending.toolResults.push({
122
123
  type: 'tool_result',
@@ -143,7 +144,7 @@ export class Agent {
143
144
  const pauseMsg = await this._checkPause(chatId, block, user, pending.toolResults, pending.remainingBlocks.filter((b) => b !== block), pending.messages);
144
145
  if (pauseMsg) return pauseMsg;
145
146
 
146
- const r = await executeTool(block.name, block.input, { config: this.config, user });
147
+ const r = await executeTool(block.name, block.input, { config: this.config, user, onUpdate: this._onUpdate });
147
148
  pending.toolResults.push({
148
149
  type: 'tool_result',
149
150
  tool_use_id: block.id,
@@ -254,6 +255,7 @@ export class Agent {
254
255
  const result = await executeTool(block.name, block.input, {
255
256
  config: this.config,
256
257
  user,
258
+ onUpdate: this._onUpdate,
257
259
  });
258
260
 
259
261
  toolResults.push({
package/src/coder.js CHANGED
@@ -7,7 +7,7 @@ export class ClaudeCodeSpawner {
7
7
  this.timeout = (config.claude_code?.timeout_seconds || 600) * 1000;
8
8
  }
9
9
 
10
- async run({ workingDirectory, prompt, maxTurns }) {
10
+ async run({ workingDirectory, prompt, maxTurns, onOutput }) {
11
11
  const logger = getLogger();
12
12
  const turns = maxTurns || this.maxTurns;
13
13
 
@@ -24,9 +24,24 @@ export class ClaudeCodeSpawner {
24
24
 
25
25
  let stdout = '';
26
26
  let stderr = '';
27
+ let buffer = '';
27
28
 
28
29
  child.stdout.on('data', (data) => {
29
- stdout += data.toString();
30
+ const chunk = data.toString();
31
+ stdout += chunk;
32
+ buffer += chunk;
33
+
34
+ // Stream output in meaningful chunks (split on newlines)
35
+ const lines = buffer.split('\n');
36
+ buffer = lines.pop(); // keep incomplete line in buffer
37
+
38
+ if (lines.length > 0 && onOutput) {
39
+ const text = lines.join('\n').trim();
40
+ if (text) {
41
+ logger.info(`Claude Code output: ${text.slice(0, 200)}`);
42
+ onOutput(text).catch(() => {});
43
+ }
44
+ }
30
45
  });
31
46
 
32
47
  child.stderr.on('data', (data) => {
@@ -40,6 +55,12 @@ export class ClaudeCodeSpawner {
40
55
 
41
56
  child.on('close', (code) => {
42
57
  clearTimeout(timer);
58
+
59
+ // Flush remaining buffer
60
+ if (buffer.trim() && onOutput) {
61
+ onOutput(buffer.trim()).catch(() => {});
62
+ }
63
+
43
64
  if (code !== 0 && !stdout) {
44
65
  reject(new Error(`Claude Code exited with code ${code}: ${stderr}`));
45
66
  } else {
@@ -41,6 +41,9 @@ export const handlers = {
41
41
  workingDirectory: params.working_directory,
42
42
  prompt: params.prompt,
43
43
  maxTurns: params.max_turns,
44
+ onOutput: context.onUpdate
45
+ ? (text) => context.onUpdate(`📟 \`Claude Code:\`\n${text}`)
46
+ : null,
44
47
  });
45
48
  return { success: true, output: result.output };
46
49
  } catch (err) {