kernelbot 1.0.24 → 1.0.26

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/.env.example CHANGED
@@ -1,5 +1,13 @@
1
+ # AI provider API keys (only the one matching your brain.provider is required)
1
2
  ANTHROPIC_API_KEY=sk-ant-...
3
+ OPENAI_API_KEY=sk-...
4
+ GOOGLE_API_KEY=AIza...
5
+ GROQ_API_KEY=gsk_...
6
+
7
+ # Required
2
8
  TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
9
+
10
+ # Optional
3
11
  GITHUB_TOKEN=ghp_...
4
12
  JIRA_BASE_URL=https://yourcompany.atlassian.net
5
13
  JIRA_EMAIL=you@company.com
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # KernelBot
2
2
 
3
- [kernelbot.io](https://kernelbot.io) | [npm](https://www.npmjs.com/package/kernelbot) | [GitHub](https://github.com/KernelCode/KERNEL)
3
+ [kernelbot.io](https://kernelbot.io) | [npm](https://www.npmjs.com/package/kernelbot) | [GitHub](https://github.com/KernelCode/kernelbot)
4
4
 
5
- AI engineering agent — a Telegram bot backed by Claude with full OS control via tool use.
5
+ AI engineering agent — a Telegram bot backed by Claude, GPT, Gemini, or Groq with full OS control via tool use.
6
6
 
7
7
  Send a message in Telegram, and KernelBot will read files, write code, run commands, browse the web, manage infrastructure, and respond with the results. It's your personal engineering assistant with direct access to your machine.
8
8
 
9
9
  ## Features
10
10
 
11
+ - **Multi-model support** — choose your AI brain: Anthropic (Claude), OpenAI (GPT), Google (Gemini), or Groq (Llama/Mixtral). Switch models anytime from the CLI menu
11
12
  - **Autonomous agent loop** — send one message and KernelBot chains tool calls until the task is done, no hand-holding needed
12
13
  - **Full shell access** — run any command, install packages, build projects, run tests
13
14
  - **File management** — read, write, and create files with automatic directory creation
@@ -30,14 +31,14 @@ Send a message in Telegram, and KernelBot will read files, write code, run comma
30
31
  ## How It Works
31
32
 
32
33
  ```text
33
- You (Telegram) → KernelBot → Claude (Anthropic API)
34
+ You (Telegram) → KernelBot → AI Brain (Claude / GPT / Gemini / Groq)
34
35
 
35
36
  Tools (shell, files, git, docker, browser, etc.)
36
37
 
37
38
  Claude Code CLI (coding tasks)
38
39
  ```
39
40
 
40
- KernelBot runs a **tool-use loop**: Claude decides which tools to call, KernelBot executes them on your OS, feeds results back, and Claude continues until the task is done. One message can trigger dozens of tool calls autonomously.
41
+ KernelBot runs a **tool-use loop**: the AI decides which tools to call, KernelBot executes them on your OS, feeds results back, and the AI continues until the task is done. One message can trigger dozens of tool calls autonomously.
41
42
 
42
43
  For complex coding tasks, KernelBot can spawn **Claude Code CLI** as a sub-agent — giving it a dedicated coding environment with its own tool loop for writing, editing, and debugging code.
43
44
 
@@ -45,85 +46,85 @@ For complex coding tasks, KernelBot can spawn **Claude Code CLI** as a sub-agent
45
46
 
46
47
  ### File System & Shell
47
48
 
48
- | Tool | Description |
49
- | --- | --- |
50
- | `execute_command` | Run any shell command (git, npm, python, etc.) |
51
- | `read_file` | Read file contents with optional line limits |
52
- | `write_file` | Write/create files, auto-creates parent directories |
53
- | `list_directory` | List directory contents, optionally recursive |
49
+ | Tool | Description |
50
+ | ----------------- | --------------------------------------------------- |
51
+ | `execute_command` | Run any shell command (git, npm, python, etc.) |
52
+ | `read_file` | Read file contents with optional line limits |
53
+ | `write_file` | Write/create files, auto-creates parent directories |
54
+ | `list_directory` | List directory contents, optionally recursive |
54
55
 
55
56
  ### Git & GitHub
56
57
 
57
- | Tool | Description |
58
- | --- | --- |
59
- | `git_clone` | Clone a repo (`org/repo` shorthand or full URL) |
60
- | `git_checkout` | Checkout or create branches |
61
- | `git_commit` | Stage all changes and commit |
62
- | `git_push` | Push current branch to remote |
63
- | `git_diff` | Show uncommitted changes |
64
- | `github_create_pr` | Create a pull request |
65
- | `github_get_pr_diff` | Get the diff of a PR |
66
- | `github_post_review` | Post a review on a PR |
67
- | `github_create_repo` | Create a new GitHub repository |
68
- | `github_list_prs` | List pull requests for a repo |
58
+ | Tool | Description |
59
+ | -------------------- | ----------------------------------------------- |
60
+ | `git_clone` | Clone a repo (`org/repo` shorthand or full URL) |
61
+ | `git_checkout` | Checkout or create branches |
62
+ | `git_commit` | Stage all changes and commit |
63
+ | `git_push` | Push current branch to remote |
64
+ | `git_diff` | Show uncommitted changes |
65
+ | `github_create_pr` | Create a pull request |
66
+ | `github_get_pr_diff` | Get the diff of a PR |
67
+ | `github_post_review` | Post a review on a PR |
68
+ | `github_create_repo` | Create a new GitHub repository |
69
+ | `github_list_prs` | List pull requests for a repo |
69
70
 
70
71
  ### Web Browsing
71
72
 
72
- | Tool | Description |
73
- | --- | --- |
74
- | `browse_website` | Navigate to a URL and extract page content (title, headings, text, links) |
75
- | `screenshot_website` | Take a screenshot of a website, supports full-page and element capture |
76
- | `extract_content` | Extract specific content using CSS selectors |
77
- | `interact_with_page` | Click, type, scroll, and run JS on a webpage |
78
- | `send_image` | Send an image/screenshot directly to the Telegram chat |
73
+ | Tool | Description |
74
+ | -------------------- | ------------------------------------------------------------------------- |
75
+ | `browse_website` | Navigate to a URL and extract page content (title, headings, text, links) |
76
+ | `screenshot_website` | Take a screenshot of a website, supports full-page and element capture |
77
+ | `extract_content` | Extract specific content using CSS selectors |
78
+ | `interact_with_page` | Click, type, scroll, and run JS on a webpage |
79
+ | `send_image` | Send an image/screenshot directly to the Telegram chat |
79
80
 
80
81
  ### JIRA
81
82
 
82
- | Tool | Description |
83
- | --- | --- |
84
- | `jira_get_ticket` | Get details of a specific JIRA ticket |
85
- | `jira_search_tickets` | Search tickets using JQL queries |
86
- | `jira_list_my_tickets` | List tickets assigned to the current user |
87
- | `jira_get_project_tickets` | Get tickets from a specific JIRA project |
83
+ | Tool | Description |
84
+ | -------------------------- | ----------------------------------------- |
85
+ | `jira_get_ticket` | Get details of a specific JIRA ticket |
86
+ | `jira_search_tickets` | Search tickets using JQL queries |
87
+ | `jira_list_my_tickets` | List tickets assigned to the current user |
88
+ | `jira_get_project_tickets` | Get tickets from a specific JIRA project |
88
89
 
89
90
  ### Docker
90
91
 
91
- | Tool | Description |
92
- | --- | --- |
93
- | `docker_ps` | List containers |
94
- | `docker_logs` | Get container logs |
95
- | `docker_exec` | Execute a command inside a running container |
96
- | `docker_compose` | Run docker compose commands |
92
+ | Tool | Description |
93
+ | ---------------- | -------------------------------------------- |
94
+ | `docker_ps` | List containers |
95
+ | `docker_logs` | Get container logs |
96
+ | `docker_exec` | Execute a command inside a running container |
97
+ | `docker_compose` | Run docker compose commands |
97
98
 
98
99
  ### Process & System
99
100
 
100
- | Tool | Description |
101
- | --- | --- |
102
- | `process_list` | List running processes, optionally filter by name |
103
- | `kill_process` | Kill a process by PID or name |
101
+ | Tool | Description |
102
+ | ----------------- | ------------------------------------------------------ |
103
+ | `process_list` | List running processes, optionally filter by name |
104
+ | `kill_process` | Kill a process by PID or name |
104
105
  | `service_control` | Manage systemd services (start, stop, restart, status) |
105
106
 
106
107
  ### Monitoring
107
108
 
108
- | Tool | Description |
109
- | --- | --- |
110
- | `disk_usage` | Show disk space usage |
111
- | `memory_usage` | Show RAM usage |
112
- | `cpu_usage` | Show CPU load |
113
- | `system_logs` | Read system or application logs |
109
+ | Tool | Description |
110
+ | -------------- | ------------------------------- |
111
+ | `disk_usage` | Show disk space usage |
112
+ | `memory_usage` | Show RAM usage |
113
+ | `cpu_usage` | Show CPU load |
114
+ | `system_logs` | Read system or application logs |
114
115
 
115
116
  ### Networking
116
117
 
117
- | Tool | Description |
118
- | --- | --- |
119
- | `check_port` | Check if a port is open and listening |
120
- | `curl_url` | Make HTTP requests and return the response |
121
- | `nginx_reload` | Test nginx config and reload if valid |
118
+ | Tool | Description |
119
+ | -------------- | ------------------------------------------ |
120
+ | `check_port` | Check if a port is open and listening |
121
+ | `curl_url` | Make HTTP requests and return the response |
122
+ | `nginx_reload` | Test nginx config and reload if valid |
122
123
 
123
124
  ### Coding
124
125
 
125
- | Tool | Description |
126
- | --- | --- |
126
+ | Tool | Description |
127
+ | ------------------- | ----------------------------------------------------------------------------------------- |
127
128
  | `spawn_claude_code` | Spawn Claude Code CLI for coding tasks — writing, fixing, reviewing, and scaffolding code |
128
129
 
129
130
  ## Disclaimer
@@ -144,10 +145,13 @@ kernelbot
144
145
 
145
146
  That's it. On first run, KernelBot will:
146
147
 
147
- 1. Detect missing credentials and prompt for them
148
- 2. Save them to `~/.kernelbot/.env`
149
- 3. Verify API connections
150
- 4. Launch the Telegram bot
148
+ 1. Prompt you to select an AI provider and model
149
+ 2. Ask for your API key and Telegram bot token
150
+ 3. Save credentials to `~/.kernelbot/.env`
151
+ 4. Verify API connections
152
+ 5. Launch the Telegram bot
153
+
154
+ You can change your AI provider/model anytime from the CLI menu (option 5).
151
155
 
152
156
  ## Configuration
153
157
 
@@ -158,7 +162,12 @@ KernelBot auto-detects config from the current directory or `~/.kernelbot/`. Eve
158
162
  Set these in `.env` or as system environment variables:
159
163
 
160
164
  ```text
161
- ANTHROPIC_API_KEY=sk-ant-...
165
+ # AI provider key (only the one matching your provider is required)
166
+ ANTHROPIC_API_KEY=sk-ant-... # for Anthropic (Claude)
167
+ OPENAI_API_KEY=sk-... # for OpenAI (GPT)
168
+ GOOGLE_API_KEY=AIza... # for Google (Gemini)
169
+ GROQ_API_KEY=gsk_... # for Groq (Llama/Mixtral)
170
+
162
171
  TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
163
172
  GITHUB_TOKEN=ghp_... # optional, for GitHub tools
164
173
  JIRA_BASE_URL=https://yourcompany.atlassian.net # optional, for JIRA tools
@@ -174,7 +183,8 @@ Drop a `config.yaml` in your working directory or `~/.kernelbot/` to customize b
174
183
  bot:
175
184
  name: KernelBot
176
185
 
177
- anthropic:
186
+ brain:
187
+ provider: anthropic # anthropic | openai | google | groq
178
188
  model: claude-sonnet-4-20250514
179
189
  max_tokens: 8192
180
190
  temperature: 0.3
@@ -209,11 +219,12 @@ conversation:
209
219
 
210
220
  ## Telegram Commands
211
221
 
212
- | Command | Description |
213
- | --- | --- |
214
- | `/clean` | Clear conversation and start fresh |
215
- | `/history` | Show message count in memory |
216
- | `/help` | Show help message |
222
+ | Command | Description |
223
+ | ---------- | ---------------------------------------------- |
224
+ | `/brain` | Show current AI model and switch provider/model |
225
+ | `/clean` | Clear conversation and start fresh |
226
+ | `/history` | Show message count in memory |
227
+ | `/help` | Show help message |
217
228
 
218
229
  ## Security
219
230
 
@@ -256,12 +267,18 @@ KernelBot/
256
267
  ├── bin/
257
268
  │ └── kernel.js # Entry point + CLI menu
258
269
  ├── src/
259
- │ ├── agent.js # Claude tool-use loop
270
+ │ ├── agent.js # AI tool-use loop (provider-agnostic)
260
271
  │ ├── bot.js # Telegram bot (polling, auth, message handling)
261
272
  │ ├── coder.js # Claude Code CLI spawner + smart output
262
273
  │ ├── conversation.js # Per-chat conversation history
263
274
  │ ├── prompts/
264
275
  │ │ └── system.js # System prompt
276
+ │ ├── providers/
277
+ │ │ ├── models.js # Provider & model catalog
278
+ │ │ ├── base.js # Abstract provider interface
279
+ │ │ ├── anthropic.js # Anthropic (Claude) provider
280
+ │ │ ├── openai-compat.js # OpenAI / Gemini / Groq provider
281
+ │ │ └── index.js # Provider factory
265
282
  │ ├── security/
266
283
  │ │ ├── auth.js # User allowlist
267
284
  │ │ ├── audit.js # Tool call audit logging
@@ -290,7 +307,11 @@ KernelBot/
290
307
  ## Requirements
291
308
 
292
309
  - Node.js 18+
293
- - [Anthropic API key](https://console.anthropic.com/)
310
+ - AI provider API key (one of):
311
+ - [Anthropic API key](https://console.anthropic.com/) (Claude)
312
+ - [OpenAI API key](https://platform.openai.com/api-keys) (GPT)
313
+ - [Google AI API key](https://aistudio.google.com/apikey) (Gemini)
314
+ - [Groq API key](https://console.groq.com/keys) (Llama/Mixtral)
294
315
  - [Telegram Bot Token](https://t.me/BotFather)
295
316
  - Chromium/Chrome (for browser tools — installed automatically by Puppeteer)
296
317
  - [GitHub Token](https://github.com/settings/tokens) (optional, for GitHub tools)
package/bin/kernel.js CHANGED
@@ -9,7 +9,7 @@ import { readFileSync, existsSync } from 'fs';
9
9
  import { join } from 'path';
10
10
  import { homedir } from 'os';
11
11
  import chalk from 'chalk';
12
- import { loadConfig, loadConfigInteractive } from '../src/utils/config.js';
12
+ import { loadConfig, loadConfigInteractive, changeBrainModel } from '../src/utils/config.js';
13
13
  import { createLogger, getLogger } from '../src/utils/logger.js';
14
14
  import {
15
15
  showLogo,
@@ -21,16 +21,23 @@ import { createAuditLogger } from '../src/security/audit.js';
21
21
  import { ConversationManager } from '../src/conversation.js';
22
22
  import { Agent } from '../src/agent.js';
23
23
  import { startBot } from '../src/bot.js';
24
- import Anthropic from '@anthropic-ai/sdk';
24
+ import { createProvider, PROVIDERS } from '../src/providers/index.js';
25
25
 
26
- function showMenu() {
26
+ function showMenu(config) {
27
+ const providerDef = PROVIDERS[config.brain.provider];
28
+ const providerName = providerDef ? providerDef.name : config.brain.provider;
29
+ const modelId = config.brain.model;
30
+
31
+ console.log('');
32
+ console.log(chalk.dim(` Current brain: ${providerName} / ${modelId}`));
27
33
  console.log('');
28
34
  console.log(chalk.bold(' What would you like to do?\n'));
29
35
  console.log(` ${chalk.cyan('1.')} Start bot`);
30
36
  console.log(` ${chalk.cyan('2.')} Check connections`);
31
37
  console.log(` ${chalk.cyan('3.')} View logs`);
32
38
  console.log(` ${chalk.cyan('4.')} View audit logs`);
33
- console.log(` ${chalk.cyan('5.')} Exit`);
39
+ console.log(` ${chalk.cyan('5.')} Change brain model`);
40
+ console.log(` ${chalk.cyan('6.')} Exit`);
34
41
  console.log('');
35
42
  }
36
43
 
@@ -70,21 +77,21 @@ function viewLog(filename) {
70
77
  }
71
78
 
72
79
  async function runCheck(config) {
73
- await showStartupCheck('ANTHROPIC_API_KEY', async () => {
74
- if (!config.anthropic.api_key) throw new Error('Not set');
80
+ const providerDef = PROVIDERS[config.brain.provider];
81
+ const providerLabel = providerDef ? providerDef.name : config.brain.provider;
82
+ const envKeyLabel = providerDef ? providerDef.envKey : 'API_KEY';
83
+
84
+ await showStartupCheck(envKeyLabel, async () => {
85
+ if (!config.brain.api_key) throw new Error('Not set');
75
86
  });
76
87
 
77
88
  await showStartupCheck('TELEGRAM_BOT_TOKEN', async () => {
78
89
  if (!config.telegram.bot_token) throw new Error('Not set');
79
90
  });
80
91
 
81
- await showStartupCheck('Anthropic API connection', async () => {
82
- const client = new Anthropic({ apiKey: config.anthropic.api_key });
83
- await client.messages.create({
84
- model: config.anthropic.model,
85
- max_tokens: 16,
86
- messages: [{ role: 'user', content: 'ping' }],
87
- });
92
+ await showStartupCheck(`${providerLabel} API connection`, async () => {
93
+ const provider = createProvider(config);
94
+ await provider.ping();
88
95
  });
89
96
 
90
97
  await showStartupCheck('Telegram Bot API', async () => {
@@ -102,16 +109,15 @@ async function startBotFlow(config) {
102
109
  createAuditLogger();
103
110
  const logger = getLogger();
104
111
 
112
+ const providerDef = PROVIDERS[config.brain.provider];
113
+ const providerLabel = providerDef ? providerDef.name : config.brain.provider;
114
+
105
115
  const checks = [];
106
116
 
107
117
  checks.push(
108
- await showStartupCheck('Anthropic API', async () => {
109
- const client = new Anthropic({ apiKey: config.anthropic.api_key });
110
- await client.messages.create({
111
- model: config.anthropic.model,
112
- max_tokens: 16,
113
- messages: [{ role: 'user', content: 'ping' }],
114
- });
118
+ await showStartupCheck(`${providerLabel} API`, async () => {
119
+ const provider = createProvider(config);
120
+ await provider.ping();
115
121
  }),
116
122
  );
117
123
 
@@ -148,7 +154,7 @@ async function main() {
148
154
 
149
155
  let running = true;
150
156
  while (running) {
151
- showMenu();
157
+ showMenu(config);
152
158
  const choice = await ask(rl, chalk.cyan(' > '));
153
159
 
154
160
  switch (choice.trim()) {
@@ -168,6 +174,9 @@ async function main() {
168
174
  viewLog('kernel-audit.log');
169
175
  break;
170
176
  case '5':
177
+ await changeBrainModel(config, rl);
178
+ break;
179
+ case '6':
171
180
  running = false;
172
181
  break;
173
182
  default:
@@ -5,7 +5,8 @@ bot:
5
5
  name: KernelBot
6
6
  description: AI engineering agent with full OS control
7
7
 
8
- anthropic:
8
+ brain:
9
+ provider: anthropic # anthropic | openai | google | groq
9
10
  model: claude-sonnet-4-20250514
10
11
  max_tokens: 8192
11
12
  temperature: 0.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kernelbot",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "KernelBot — AI engineering agent with full OS control",
5
5
  "type": "module",
6
6
  "author": "Abdullah Al-Taheri <abdullah@altaheri.me>",
@@ -15,6 +15,9 @@
15
15
  "agent",
16
16
  "telegram",
17
17
  "anthropic",
18
+ "openai",
19
+ "gemini",
20
+ "groq",
18
21
  "tools"
19
22
  ],
20
23
  "repository": {
@@ -37,6 +40,7 @@
37
40
  "gradient-string": "^3.0.0",
38
41
  "js-yaml": "^4.1.0",
39
42
  "node-telegram-bot-api": "^0.66.0",
43
+ "openai": "^4.82.0",
40
44
  "ora": "^8.1.1",
41
45
  "puppeteer": "^24.37.3",
42
46
  "simple-git": "^3.31.1",