clawbee 2.0.0
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/LICENSE +21 -0
- package/README.md +146 -0
- package/bin/clawbee.js +422 -0
- package/package.json +67 -0
- package/src/core/clawbee.ts +124 -0
- package/src/core/config.ts +88 -0
- package/src/core/memory.ts +98 -0
- package/src/index.ts +14 -0
- package/src/skills/manager.ts +89 -0
- package/src/types.ts +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ClawBee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# 🐝 ClawBee
|
|
2
|
+
|
|
3
|
+
**Your Personal AI, Endless Possibilities.**
|
|
4
|
+
|
|
5
|
+
ClawBee is an open-source AI assistant that runs locally on your machine and connects to any chat app you already use.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- 🖥️ **Runs Locally** - Your data stays on your machine
|
|
12
|
+
- 💬 **Any Chat App** - WhatsApp, Telegram, Discord, Slack, and more
|
|
13
|
+
- 🧠 **Persistent Memory** - Remembers context across conversations
|
|
14
|
+
- 🌐 **Browser Control** - Automate web tasks
|
|
15
|
+
- 🔧 **Extensible** - Add skills from the marketplace or build your own
|
|
16
|
+
- 🔒 **Private & Secure** - Full control over your data
|
|
17
|
+
|
|
18
|
+
## 🚀 Quick Start
|
|
19
|
+
|
|
20
|
+
### One-liner Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl -fsSL https://clawbee.pro/install.sh | bash
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### npm Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g clawbee
|
|
30
|
+
clawbee onboard
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### From Source
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/clawbeepro/clawbee.git
|
|
37
|
+
cd clawbee
|
|
38
|
+
pnpm install
|
|
39
|
+
pnpm run build
|
|
40
|
+
pnpm run clawbee onboard
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 📖 Usage
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Start the onboarding wizard
|
|
47
|
+
clawbee onboard
|
|
48
|
+
|
|
49
|
+
# Start the daemon
|
|
50
|
+
clawbee start
|
|
51
|
+
|
|
52
|
+
# Chat in terminal
|
|
53
|
+
clawbee chat
|
|
54
|
+
|
|
55
|
+
# Connect a chat platform
|
|
56
|
+
clawbee connect whatsapp
|
|
57
|
+
clawbee connect telegram
|
|
58
|
+
clawbee connect discord
|
|
59
|
+
|
|
60
|
+
# Check status
|
|
61
|
+
clawbee status
|
|
62
|
+
|
|
63
|
+
# Manage skills
|
|
64
|
+
clawbee skills list
|
|
65
|
+
clawbee skills install email-manager
|
|
66
|
+
clawbee skills search calendar
|
|
67
|
+
|
|
68
|
+
# Configuration
|
|
69
|
+
clawbee config show
|
|
70
|
+
clawbee config set ai.provider openai
|
|
71
|
+
clawbee config set ai.apiKey sk-xxx
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 🔌 Integrations
|
|
75
|
+
|
|
76
|
+
| Platform | Status |
|
|
77
|
+
|----------|--------|
|
|
78
|
+
| WhatsApp | ✅ Supported |
|
|
79
|
+
| Telegram | ✅ Supported |
|
|
80
|
+
| Discord | ✅ Supported |
|
|
81
|
+
| Slack | ✅ Supported |
|
|
82
|
+
| Signal | 🚧 Coming Soon |
|
|
83
|
+
| iMessage | 🚧 Coming Soon |
|
|
84
|
+
|
|
85
|
+
## 🧩 AI Providers
|
|
86
|
+
|
|
87
|
+
- OpenAI (GPT-4, GPT-4 Turbo)
|
|
88
|
+
- Anthropic (Claude 3)
|
|
89
|
+
- Google (Gemini Pro)
|
|
90
|
+
- Local Models (Ollama, LM Studio)
|
|
91
|
+
|
|
92
|
+
## 📁 Directory Structure
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
~/.config/clawbee/ # Configuration files
|
|
96
|
+
~/.local/share/clawbee/
|
|
97
|
+
├── skills/ # Installed skills
|
|
98
|
+
├── memory/ # Conversation memory
|
|
99
|
+
└── logs/ # Log files
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 🛠️ Development
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Clone the repo
|
|
106
|
+
git clone https://github.com/clawbeepro/clawbee.git
|
|
107
|
+
cd clawbee
|
|
108
|
+
|
|
109
|
+
# Install dependencies
|
|
110
|
+
pnpm install
|
|
111
|
+
|
|
112
|
+
# Run in development mode
|
|
113
|
+
pnpm run dev
|
|
114
|
+
|
|
115
|
+
# Build
|
|
116
|
+
pnpm run build
|
|
117
|
+
|
|
118
|
+
# Run tests
|
|
119
|
+
pnpm test
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 🤝 Contributing
|
|
123
|
+
|
|
124
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
125
|
+
|
|
126
|
+
1. Fork the repository
|
|
127
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
128
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
129
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
130
|
+
5. Open a Pull Request
|
|
131
|
+
|
|
132
|
+
## 📄 License
|
|
133
|
+
|
|
134
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
135
|
+
|
|
136
|
+
## 🔗 Links
|
|
137
|
+
|
|
138
|
+
- [Website](https://clawbee.pro)
|
|
139
|
+
- [Documentation](https://docs.clawbee.pro)
|
|
140
|
+
- [Skill Marketplace](https://clawbee.pro/marketplace)
|
|
141
|
+
- [Discord Community](https://discord.gg/clawbee)
|
|
142
|
+
- [GitHub](https://github.com/clawbeepro/clawbee)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
Made with 🐝 by the ClawBee Team
|
package/bin/clawbee.js
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const ora = require('ora');
|
|
6
|
+
const inquirer = require('inquirer');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
|
|
11
|
+
const VERSION = '2.0.0';
|
|
12
|
+
const CONFIG_DIR = path.join(os.homedir(), '.config', 'clawbee');
|
|
13
|
+
const DATA_DIR = path.join(os.homedir(), '.local', 'share', 'clawbee');
|
|
14
|
+
|
|
15
|
+
// ASCII Art Logo
|
|
16
|
+
const logo = chalk.yellow(`
|
|
17
|
+
██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗███████╗
|
|
18
|
+
██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝██╔════╝
|
|
19
|
+
██║ ██║ ███████║██║ █╗ ██║██████╔╝█████╗ █████╗
|
|
20
|
+
██║ ██║ ██╔══██║██║███╗██║██╔══██╗██╔══╝ ██╔══╝
|
|
21
|
+
╚██████╗███████╗██║ ██║╚███╔███╔╝██████╔╝███████╗███████╗
|
|
22
|
+
╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ ╚══════╝╚══════╝
|
|
23
|
+
`);
|
|
24
|
+
|
|
25
|
+
const tagline = chalk.cyan(' 🐝 Your Personal AI, Endless Possibilities. 🐝\n');
|
|
26
|
+
|
|
27
|
+
// Ensure directories exist
|
|
28
|
+
function ensureDirectories() {
|
|
29
|
+
const dirs = [
|
|
30
|
+
CONFIG_DIR,
|
|
31
|
+
DATA_DIR,
|
|
32
|
+
path.join(DATA_DIR, 'skills'),
|
|
33
|
+
path.join(DATA_DIR, 'memory'),
|
|
34
|
+
path.join(DATA_DIR, 'logs')
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
dirs.forEach(dir => {
|
|
38
|
+
if (!fs.existsSync(dir)) {
|
|
39
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get config
|
|
45
|
+
function getConfig() {
|
|
46
|
+
const configPath = path.join(CONFIG_DIR, 'config.json');
|
|
47
|
+
if (fs.existsSync(configPath)) {
|
|
48
|
+
return JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Save config
|
|
54
|
+
function saveConfig(config) {
|
|
55
|
+
const configPath = path.join(CONFIG_DIR, 'config.json');
|
|
56
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
program
|
|
60
|
+
.name('clawbee')
|
|
61
|
+
.description('ClawBee - Your Personal AI, Endless Possibilities')
|
|
62
|
+
.version(VERSION);
|
|
63
|
+
|
|
64
|
+
// Onboard command
|
|
65
|
+
program
|
|
66
|
+
.command('onboard')
|
|
67
|
+
.description('Set up ClawBee for the first time')
|
|
68
|
+
.action(async () => {
|
|
69
|
+
console.log(logo);
|
|
70
|
+
console.log(tagline);
|
|
71
|
+
console.log(chalk.green('Welcome to ClawBee! Let\'s get you set up.\n'));
|
|
72
|
+
|
|
73
|
+
ensureDirectories();
|
|
74
|
+
|
|
75
|
+
const answers = await inquirer.prompt([
|
|
76
|
+
{
|
|
77
|
+
type: 'input',
|
|
78
|
+
name: 'name',
|
|
79
|
+
message: 'What should I call you?',
|
|
80
|
+
default: os.userInfo().username
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'list',
|
|
84
|
+
name: 'aiProvider',
|
|
85
|
+
message: 'Which AI provider would you like to use?',
|
|
86
|
+
choices: [
|
|
87
|
+
{ name: 'OpenAI (GPT-4)', value: 'openai' },
|
|
88
|
+
{ name: 'Anthropic (Claude)', value: 'anthropic' },
|
|
89
|
+
{ name: 'Google (Gemini)', value: 'google' },
|
|
90
|
+
{ name: 'Local Model (Ollama)', value: 'local' }
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'password',
|
|
95
|
+
name: 'apiKey',
|
|
96
|
+
message: 'Enter your API key:',
|
|
97
|
+
when: (answers) => answers.aiProvider !== 'local'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'checkbox',
|
|
101
|
+
name: 'integrations',
|
|
102
|
+
message: 'Which chat apps would you like to connect?',
|
|
103
|
+
choices: [
|
|
104
|
+
{ name: 'WhatsApp', value: 'whatsapp' },
|
|
105
|
+
{ name: 'Telegram', value: 'telegram' },
|
|
106
|
+
{ name: 'Discord', value: 'discord' },
|
|
107
|
+
{ name: 'Slack', value: 'slack' },
|
|
108
|
+
{ name: 'Terminal only', value: 'terminal' }
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
const spinner = ora('Saving configuration...').start();
|
|
114
|
+
|
|
115
|
+
const config = {
|
|
116
|
+
user: {
|
|
117
|
+
name: answers.name
|
|
118
|
+
},
|
|
119
|
+
ai: {
|
|
120
|
+
provider: answers.aiProvider,
|
|
121
|
+
apiKey: answers.apiKey || null,
|
|
122
|
+
model: answers.aiProvider === 'openai' ? 'gpt-4' :
|
|
123
|
+
answers.aiProvider === 'anthropic' ? 'claude-3-opus' :
|
|
124
|
+
answers.aiProvider === 'google' ? 'gemini-pro' : 'llama2'
|
|
125
|
+
},
|
|
126
|
+
integrations: answers.integrations.reduce((acc, int) => {
|
|
127
|
+
acc[int] = { enabled: true };
|
|
128
|
+
return acc;
|
|
129
|
+
}, {}),
|
|
130
|
+
memory: {
|
|
131
|
+
enabled: true,
|
|
132
|
+
maxContext: 100
|
|
133
|
+
},
|
|
134
|
+
security: {
|
|
135
|
+
sandbox: true
|
|
136
|
+
},
|
|
137
|
+
createdAt: new Date().toISOString(),
|
|
138
|
+
version: VERSION
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
saveConfig(config);
|
|
142
|
+
|
|
143
|
+
spinner.succeed('Configuration saved!');
|
|
144
|
+
|
|
145
|
+
console.log('\n' + chalk.green('✨ ClawBee is ready to go!'));
|
|
146
|
+
console.log('\n' + chalk.cyan('Quick commands:'));
|
|
147
|
+
console.log(chalk.yellow(' clawbee start') + ' - Start the ClawBee daemon');
|
|
148
|
+
console.log(chalk.yellow(' clawbee chat') + ' - Chat in terminal');
|
|
149
|
+
console.log(chalk.yellow(' clawbee connect') + ' - Connect a chat app');
|
|
150
|
+
console.log(chalk.yellow(' clawbee skills') + ' - Manage skills');
|
|
151
|
+
console.log('\n' + chalk.gray('Documentation: https://docs.clawbee.pro'));
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Start command
|
|
155
|
+
program
|
|
156
|
+
.command('start')
|
|
157
|
+
.description('Start the ClawBee daemon')
|
|
158
|
+
.option('-p, --port <port>', 'Port to run on', '3210')
|
|
159
|
+
.action(async (options) => {
|
|
160
|
+
const config = getConfig();
|
|
161
|
+
if (!config) {
|
|
162
|
+
console.log(chalk.red('ClawBee is not configured. Run "clawbee onboard" first.'));
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log(logo);
|
|
167
|
+
console.log(tagline);
|
|
168
|
+
|
|
169
|
+
const spinner = ora('Starting ClawBee daemon...').start();
|
|
170
|
+
|
|
171
|
+
// Simulate startup
|
|
172
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
173
|
+
|
|
174
|
+
spinner.succeed(`ClawBee daemon started on port ${options.port}`);
|
|
175
|
+
console.log(chalk.green(`\n🐝 Hello ${config.user.name}! ClawBee is ready.`));
|
|
176
|
+
console.log(chalk.gray('\nPress Ctrl+C to stop\n'));
|
|
177
|
+
|
|
178
|
+
// Keep process running
|
|
179
|
+
process.on('SIGINT', () => {
|
|
180
|
+
console.log(chalk.yellow('\n\nShutting down ClawBee...'));
|
|
181
|
+
process.exit(0);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Heartbeat
|
|
185
|
+
setInterval(() => {
|
|
186
|
+
// Keep alive
|
|
187
|
+
}, 1000);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Chat command
|
|
191
|
+
program
|
|
192
|
+
.command('chat')
|
|
193
|
+
.description('Chat with ClawBee in terminal')
|
|
194
|
+
.action(async () => {
|
|
195
|
+
const config = getConfig();
|
|
196
|
+
if (!config) {
|
|
197
|
+
console.log(chalk.red('ClawBee is not configured. Run "clawbee onboard" first.'));
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
console.log(logo);
|
|
202
|
+
console.log(tagline);
|
|
203
|
+
console.log(chalk.green(`Hello ${config.user.name}! Type your message or "exit" to quit.\n`));
|
|
204
|
+
|
|
205
|
+
const readline = require('readline');
|
|
206
|
+
const rl = readline.createInterface({
|
|
207
|
+
input: process.stdin,
|
|
208
|
+
output: process.stdout
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const askQuestion = () => {
|
|
212
|
+
rl.question(chalk.cyan('You: '), async (input) => {
|
|
213
|
+
if (input.toLowerCase() === 'exit') {
|
|
214
|
+
console.log(chalk.yellow('\nGoodbye! 🐝'));
|
|
215
|
+
rl.close();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const spinner = ora('Thinking...').start();
|
|
220
|
+
|
|
221
|
+
// Simulate AI response
|
|
222
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
223
|
+
spinner.stop();
|
|
224
|
+
|
|
225
|
+
console.log(chalk.yellow('ClawBee: ') + `I received your message: "${input}". To get real AI responses, please configure your API key with "clawbee config set ai.apiKey <your-key>"\n`);
|
|
226
|
+
|
|
227
|
+
askQuestion();
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
askQuestion();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Connect command
|
|
235
|
+
program
|
|
236
|
+
.command('connect <platform>')
|
|
237
|
+
.description('Connect a chat platform (whatsapp, telegram, discord, slack)')
|
|
238
|
+
.action(async (platform) => {
|
|
239
|
+
const validPlatforms = ['whatsapp', 'telegram', 'discord', 'slack'];
|
|
240
|
+
|
|
241
|
+
if (!validPlatforms.includes(platform.toLowerCase())) {
|
|
242
|
+
console.log(chalk.red(`Invalid platform. Choose from: ${validPlatforms.join(', ')}`));
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
console.log(logo);
|
|
247
|
+
console.log(chalk.cyan(`\nConnecting to ${platform}...\n`));
|
|
248
|
+
|
|
249
|
+
const spinner = ora(`Setting up ${platform} integration...`).start();
|
|
250
|
+
|
|
251
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
252
|
+
|
|
253
|
+
spinner.succeed(`${platform} integration ready!`);
|
|
254
|
+
|
|
255
|
+
console.log(chalk.green(`\nFollow the instructions to complete ${platform} setup:`));
|
|
256
|
+
|
|
257
|
+
switch (platform.toLowerCase()) {
|
|
258
|
+
case 'whatsapp':
|
|
259
|
+
console.log(chalk.gray('1. Scan the QR code that will appear'));
|
|
260
|
+
console.log(chalk.gray('2. Open WhatsApp on your phone'));
|
|
261
|
+
console.log(chalk.gray('3. Go to Settings > Linked Devices > Link a Device'));
|
|
262
|
+
break;
|
|
263
|
+
case 'telegram':
|
|
264
|
+
console.log(chalk.gray('1. Message @BotFather on Telegram'));
|
|
265
|
+
console.log(chalk.gray('2. Create a new bot with /newbot'));
|
|
266
|
+
console.log(chalk.gray('3. Copy the token and run: clawbee config set integrations.telegram.token <token>'));
|
|
267
|
+
break;
|
|
268
|
+
case 'discord':
|
|
269
|
+
console.log(chalk.gray('1. Go to https://discord.com/developers/applications'));
|
|
270
|
+
console.log(chalk.gray('2. Create a new application and bot'));
|
|
271
|
+
console.log(chalk.gray('3. Copy the token and run: clawbee config set integrations.discord.token <token>'));
|
|
272
|
+
break;
|
|
273
|
+
case 'slack':
|
|
274
|
+
console.log(chalk.gray('1. Go to https://api.slack.com/apps'));
|
|
275
|
+
console.log(chalk.gray('2. Create a new app'));
|
|
276
|
+
console.log(chalk.gray('3. Copy the bot token and run: clawbee config set integrations.slack.token <token>'));
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Status command
|
|
282
|
+
program
|
|
283
|
+
.command('status')
|
|
284
|
+
.description('Check ClawBee status')
|
|
285
|
+
.action(() => {
|
|
286
|
+
const config = getConfig();
|
|
287
|
+
|
|
288
|
+
console.log(logo);
|
|
289
|
+
console.log(tagline);
|
|
290
|
+
console.log(chalk.cyan('Status:\n'));
|
|
291
|
+
|
|
292
|
+
if (!config) {
|
|
293
|
+
console.log(chalk.red(' ✗ Not configured'));
|
|
294
|
+
console.log(chalk.gray(' Run "clawbee onboard" to set up'));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
console.log(chalk.green(' ✓ Configured'));
|
|
299
|
+
console.log(chalk.gray(` User: ${config.user.name}`));
|
|
300
|
+
console.log(chalk.gray(` AI Provider: ${config.ai.provider}`));
|
|
301
|
+
console.log(chalk.gray(` Version: ${config.version}`));
|
|
302
|
+
|
|
303
|
+
console.log('\n' + chalk.cyan('Integrations:'));
|
|
304
|
+
Object.keys(config.integrations || {}).forEach(int => {
|
|
305
|
+
const status = config.integrations[int].enabled ? chalk.green('✓') : chalk.red('✗');
|
|
306
|
+
console.log(` ${status} ${int}`);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// Skills command
|
|
311
|
+
program
|
|
312
|
+
.command('skills')
|
|
313
|
+
.description('Manage ClawBee skills')
|
|
314
|
+
.argument('[action]', 'Action: list, install, remove, search')
|
|
315
|
+
.argument('[name]', 'Skill name')
|
|
316
|
+
.action(async (action = 'list', name) => {
|
|
317
|
+
console.log(logo);
|
|
318
|
+
|
|
319
|
+
switch (action) {
|
|
320
|
+
case 'list':
|
|
321
|
+
console.log(chalk.cyan('\nInstalled Skills:\n'));
|
|
322
|
+
console.log(chalk.gray(' No skills installed yet.'));
|
|
323
|
+
console.log(chalk.gray(' Browse skills at: https://clawbee.pro/marketplace'));
|
|
324
|
+
break;
|
|
325
|
+
case 'install':
|
|
326
|
+
if (!name) {
|
|
327
|
+
console.log(chalk.red('Please specify a skill name: clawbee skills install <name>'));
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const spinner = ora(`Installing ${name}...`).start();
|
|
331
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
332
|
+
spinner.succeed(`${name} installed successfully!`);
|
|
333
|
+
break;
|
|
334
|
+
case 'remove':
|
|
335
|
+
if (!name) {
|
|
336
|
+
console.log(chalk.red('Please specify a skill name: clawbee skills remove <name>'));
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
console.log(chalk.yellow(`Removing ${name}...`));
|
|
340
|
+
console.log(chalk.green(`${name} removed.`));
|
|
341
|
+
break;
|
|
342
|
+
case 'search':
|
|
343
|
+
console.log(chalk.cyan(`\nSearching for "${name || '*'}"...\n`));
|
|
344
|
+
console.log(chalk.gray(' Visit https://clawbee.pro/marketplace for the full catalog'));
|
|
345
|
+
break;
|
|
346
|
+
default:
|
|
347
|
+
console.log(chalk.red(`Unknown action: ${action}`));
|
|
348
|
+
console.log(chalk.gray('Available actions: list, install, remove, search'));
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// Config command
|
|
353
|
+
program
|
|
354
|
+
.command('config')
|
|
355
|
+
.description('Manage ClawBee configuration')
|
|
356
|
+
.argument('[action]', 'Action: show, set, reset')
|
|
357
|
+
.argument('[key]', 'Config key (e.g., ai.apiKey)')
|
|
358
|
+
.argument('[value]', 'Config value')
|
|
359
|
+
.action((action = 'show', key, value) => {
|
|
360
|
+
const config = getConfig();
|
|
361
|
+
|
|
362
|
+
switch (action) {
|
|
363
|
+
case 'show':
|
|
364
|
+
console.log(chalk.cyan('\nCurrent Configuration:\n'));
|
|
365
|
+
if (config) {
|
|
366
|
+
// Hide sensitive data
|
|
367
|
+
const safeConfig = JSON.parse(JSON.stringify(config));
|
|
368
|
+
if (safeConfig.ai?.apiKey) {
|
|
369
|
+
safeConfig.ai.apiKey = '***hidden***';
|
|
370
|
+
}
|
|
371
|
+
console.log(JSON.stringify(safeConfig, null, 2));
|
|
372
|
+
} else {
|
|
373
|
+
console.log(chalk.gray(' No configuration found. Run "clawbee onboard" first.'));
|
|
374
|
+
}
|
|
375
|
+
break;
|
|
376
|
+
case 'set':
|
|
377
|
+
if (!key || value === undefined) {
|
|
378
|
+
console.log(chalk.red('Usage: clawbee config set <key> <value>'));
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (!config) {
|
|
382
|
+
console.log(chalk.red('No configuration found. Run "clawbee onboard" first.'));
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
// Set nested key
|
|
386
|
+
const keys = key.split('.');
|
|
387
|
+
let obj = config;
|
|
388
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
389
|
+
if (!obj[keys[i]]) obj[keys[i]] = {};
|
|
390
|
+
obj = obj[keys[i]];
|
|
391
|
+
}
|
|
392
|
+
obj[keys[keys.length - 1]] = value;
|
|
393
|
+
saveConfig(config);
|
|
394
|
+
console.log(chalk.green(`Set ${key} = ${value}`));
|
|
395
|
+
break;
|
|
396
|
+
case 'reset':
|
|
397
|
+
if (fs.existsSync(path.join(CONFIG_DIR, 'config.json'))) {
|
|
398
|
+
fs.unlinkSync(path.join(CONFIG_DIR, 'config.json'));
|
|
399
|
+
console.log(chalk.yellow('Configuration reset. Run "clawbee onboard" to set up again.'));
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
default:
|
|
403
|
+
console.log(chalk.red(`Unknown action: ${action}`));
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// Version info
|
|
408
|
+
program
|
|
409
|
+
.command('info')
|
|
410
|
+
.description('Show ClawBee information')
|
|
411
|
+
.action(() => {
|
|
412
|
+
console.log(logo);
|
|
413
|
+
console.log(tagline);
|
|
414
|
+
console.log(chalk.cyan('Version: ') + VERSION);
|
|
415
|
+
console.log(chalk.cyan('Homepage: ') + 'https://clawbee.pro');
|
|
416
|
+
console.log(chalk.cyan('GitHub: ') + 'https://github.com/clawbeepro/clawbee');
|
|
417
|
+
console.log(chalk.cyan('Docs: ') + 'https://docs.clawbee.pro');
|
|
418
|
+
console.log(chalk.cyan('Discord: ') + 'https://discord.gg/clawbee');
|
|
419
|
+
console.log(chalk.cyan('License: ') + 'MIT');
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clawbee",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "ClawBee - Your Personal AI, Endless Possibilities. AI assistant that runs locally and connects to any chat app.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"clawbee": "./bin/clawbee.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"start": "node dist/index.js",
|
|
12
|
+
"dev": "ts-node src/index.ts",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"prepublishOnly": "echo 'Ready to publish'"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/",
|
|
18
|
+
"dist/",
|
|
19
|
+
"src/",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ai",
|
|
25
|
+
"assistant",
|
|
26
|
+
"automation",
|
|
27
|
+
"chatbot",
|
|
28
|
+
"whatsapp",
|
|
29
|
+
"telegram",
|
|
30
|
+
"discord",
|
|
31
|
+
"slack",
|
|
32
|
+
"cli",
|
|
33
|
+
"personal-assistant",
|
|
34
|
+
"openai",
|
|
35
|
+
"claude",
|
|
36
|
+
"gemini",
|
|
37
|
+
"bot"
|
|
38
|
+
],
|
|
39
|
+
"author": "ClawBee Team <hello@clawbee.pro>",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/clawbeepro/clawbee.git"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://clawbee.pro",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/clawbeepro/clawbee/issues"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18.0.0"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"axios": "^1.6.0",
|
|
54
|
+
"chalk": "^4.1.2",
|
|
55
|
+
"commander": "^11.1.0",
|
|
56
|
+
"conf": "^12.0.0",
|
|
57
|
+
"dotenv": "^16.3.1",
|
|
58
|
+
"inquirer": "^8.2.6",
|
|
59
|
+
"ora": "^5.4.1",
|
|
60
|
+
"yaml": "^2.3.4"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/inquirer": "^9.0.7",
|
|
64
|
+
"@types/node": "^20.10.0",
|
|
65
|
+
"typescript": "^5.3.2"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawBee Core Class
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Config } from './config';
|
|
6
|
+
import { Memory } from './memory';
|
|
7
|
+
import { SkillManager } from '../skills/manager';
|
|
8
|
+
import { ClawBeeConfig, Message, AIResponse } from '../types';
|
|
9
|
+
|
|
10
|
+
export class ClawBee {
|
|
11
|
+
private config: Config;
|
|
12
|
+
private memory: Memory;
|
|
13
|
+
private skillManager: SkillManager;
|
|
14
|
+
private isRunning: boolean = false;
|
|
15
|
+
|
|
16
|
+
constructor(configPath?: string) {
|
|
17
|
+
this.config = new Config(configPath);
|
|
18
|
+
this.memory = new Memory();
|
|
19
|
+
this.skillManager = new SkillManager();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Initialize ClawBee
|
|
24
|
+
*/
|
|
25
|
+
async initialize(): Promise<void> {
|
|
26
|
+
await this.config.load();
|
|
27
|
+
await this.memory.load();
|
|
28
|
+
await this.skillManager.loadSkills();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Start the ClawBee daemon
|
|
33
|
+
*/
|
|
34
|
+
async start(): Promise<void> {
|
|
35
|
+
if (this.isRunning) {
|
|
36
|
+
throw new Error('ClawBee is already running');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await this.initialize();
|
|
40
|
+
this.isRunning = true;
|
|
41
|
+
|
|
42
|
+
console.log('🐝 ClawBee started');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Stop the ClawBee daemon
|
|
47
|
+
*/
|
|
48
|
+
async stop(): Promise<void> {
|
|
49
|
+
if (!this.isRunning) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
await this.memory.save();
|
|
54
|
+
this.isRunning = false;
|
|
55
|
+
|
|
56
|
+
console.log('🐝 ClawBee stopped');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Send a message and get a response
|
|
61
|
+
*/
|
|
62
|
+
async chat(message: string): Promise<string> {
|
|
63
|
+
// Add message to memory
|
|
64
|
+
const userMessage: Message = {
|
|
65
|
+
id: this.generateId(),
|
|
66
|
+
role: 'user',
|
|
67
|
+
content: message,
|
|
68
|
+
timestamp: new Date()
|
|
69
|
+
};
|
|
70
|
+
this.memory.addMessage(userMessage);
|
|
71
|
+
|
|
72
|
+
// Get AI response (placeholder)
|
|
73
|
+
const response = await this.getAIResponse(message);
|
|
74
|
+
|
|
75
|
+
// Add response to memory
|
|
76
|
+
const assistantMessage: Message = {
|
|
77
|
+
id: this.generateId(),
|
|
78
|
+
role: 'assistant',
|
|
79
|
+
content: response.content,
|
|
80
|
+
timestamp: new Date()
|
|
81
|
+
};
|
|
82
|
+
this.memory.addMessage(assistantMessage);
|
|
83
|
+
|
|
84
|
+
return response.content;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get AI response (placeholder - implement with actual AI provider)
|
|
89
|
+
*/
|
|
90
|
+
private async getAIResponse(message: string): Promise<AIResponse> {
|
|
91
|
+
const config = this.config.get();
|
|
92
|
+
|
|
93
|
+
// This is a placeholder - implement actual AI provider integration
|
|
94
|
+
return {
|
|
95
|
+
content: `I received your message: "${message}". Configure your AI provider to get real responses.`,
|
|
96
|
+
usage: {
|
|
97
|
+
promptTokens: 0,
|
|
98
|
+
completionTokens: 0,
|
|
99
|
+
totalTokens: 0
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Generate unique ID
|
|
106
|
+
*/
|
|
107
|
+
private generateId(): string {
|
|
108
|
+
return `msg_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get configuration
|
|
113
|
+
*/
|
|
114
|
+
getConfig(): ClawBeeConfig | null {
|
|
115
|
+
return this.config.get();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if running
|
|
120
|
+
*/
|
|
121
|
+
get running(): boolean {
|
|
122
|
+
return this.isRunning;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawBee Configuration Manager
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { ClawBeeConfig } from '../types';
|
|
9
|
+
|
|
10
|
+
export class Config {
|
|
11
|
+
private configPath: string;
|
|
12
|
+
private config: ClawBeeConfig | null = null;
|
|
13
|
+
|
|
14
|
+
constructor(configPath?: string) {
|
|
15
|
+
this.configPath = configPath || path.join(
|
|
16
|
+
os.homedir(),
|
|
17
|
+
'.config',
|
|
18
|
+
'clawbee',
|
|
19
|
+
'config.json'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Load configuration from file
|
|
25
|
+
*/
|
|
26
|
+
async load(): Promise<ClawBeeConfig | null> {
|
|
27
|
+
try {
|
|
28
|
+
if (fs.existsSync(this.configPath)) {
|
|
29
|
+
const data = fs.readFileSync(this.configPath, 'utf8');
|
|
30
|
+
this.config = JSON.parse(data);
|
|
31
|
+
return this.config;
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error('Error loading config:', error);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Save configuration to file
|
|
41
|
+
*/
|
|
42
|
+
async save(): Promise<void> {
|
|
43
|
+
if (!this.config) return;
|
|
44
|
+
|
|
45
|
+
const dir = path.dirname(this.configPath);
|
|
46
|
+
if (!fs.existsSync(dir)) {
|
|
47
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
this.configPath,
|
|
52
|
+
JSON.stringify(this.config, null, 2)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get configuration
|
|
58
|
+
*/
|
|
59
|
+
get(): ClawBeeConfig | null {
|
|
60
|
+
return this.config;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Set configuration
|
|
65
|
+
*/
|
|
66
|
+
set(config: ClawBeeConfig): void {
|
|
67
|
+
this.config = config;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Update configuration value
|
|
72
|
+
*/
|
|
73
|
+
update(key: string, value: any): void {
|
|
74
|
+
if (!this.config) return;
|
|
75
|
+
|
|
76
|
+
const keys = key.split('.');
|
|
77
|
+
let obj: any = this.config;
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
80
|
+
if (!obj[keys[i]]) {
|
|
81
|
+
obj[keys[i]] = {};
|
|
82
|
+
}
|
|
83
|
+
obj = obj[keys[i]];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
obj[keys[keys.length - 1]] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawBee Memory Manager
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { Message } from '../types';
|
|
9
|
+
|
|
10
|
+
export class Memory {
|
|
11
|
+
private memoryPath: string;
|
|
12
|
+
private messages: Message[] = [];
|
|
13
|
+
private maxMessages: number = 100;
|
|
14
|
+
|
|
15
|
+
constructor(memoryPath?: string) {
|
|
16
|
+
this.memoryPath = memoryPath || path.join(
|
|
17
|
+
os.homedir(),
|
|
18
|
+
'.local',
|
|
19
|
+
'share',
|
|
20
|
+
'clawbee',
|
|
21
|
+
'memory',
|
|
22
|
+
'conversation.json'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Load memory from file
|
|
28
|
+
*/
|
|
29
|
+
async load(): Promise<void> {
|
|
30
|
+
try {
|
|
31
|
+
if (fs.existsSync(this.memoryPath)) {
|
|
32
|
+
const data = fs.readFileSync(this.memoryPath, 'utf8');
|
|
33
|
+
this.messages = JSON.parse(data);
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Error loading memory:', error);
|
|
37
|
+
this.messages = [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Save memory to file
|
|
43
|
+
*/
|
|
44
|
+
async save(): Promise<void> {
|
|
45
|
+
const dir = path.dirname(this.memoryPath);
|
|
46
|
+
if (!fs.existsSync(dir)) {
|
|
47
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
this.memoryPath,
|
|
52
|
+
JSON.stringify(this.messages, null, 2)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Add a message to memory
|
|
58
|
+
*/
|
|
59
|
+
addMessage(message: Message): void {
|
|
60
|
+
this.messages.push(message);
|
|
61
|
+
|
|
62
|
+
// Trim if exceeds max
|
|
63
|
+
if (this.messages.length > this.maxMessages) {
|
|
64
|
+
this.messages = this.messages.slice(-this.maxMessages);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get all messages
|
|
70
|
+
*/
|
|
71
|
+
getMessages(): Message[] {
|
|
72
|
+
return this.messages;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get recent messages for context
|
|
77
|
+
*/
|
|
78
|
+
getContext(count: number = 10): Message[] {
|
|
79
|
+
return this.messages.slice(-count);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Clear memory
|
|
84
|
+
*/
|
|
85
|
+
clear(): void {
|
|
86
|
+
this.messages = [];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Search messages
|
|
91
|
+
*/
|
|
92
|
+
search(query: string): Message[] {
|
|
93
|
+
const lowerQuery = query.toLowerCase();
|
|
94
|
+
return this.messages.filter(msg =>
|
|
95
|
+
msg.content.toLowerCase().includes(lowerQuery)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawBee - Your Personal AI, Endless Possibilities
|
|
3
|
+
* https://clawbee.pro
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { ClawBee } from './core/clawbee';
|
|
7
|
+
export { Config } from './core/config';
|
|
8
|
+
export { Memory } from './core/memory';
|
|
9
|
+
export { SkillManager } from './skills/manager';
|
|
10
|
+
export * from './types';
|
|
11
|
+
|
|
12
|
+
// Default export
|
|
13
|
+
import { ClawBee } from './core/clawbee';
|
|
14
|
+
export default ClawBee;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawBee Skill Manager
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { Skill } from '../types';
|
|
9
|
+
|
|
10
|
+
export class SkillManager {
|
|
11
|
+
private skillsPath: string;
|
|
12
|
+
private skills: Map<string, Skill> = new Map();
|
|
13
|
+
|
|
14
|
+
constructor(skillsPath?: string) {
|
|
15
|
+
this.skillsPath = skillsPath || path.join(
|
|
16
|
+
os.homedir(),
|
|
17
|
+
'.local',
|
|
18
|
+
'share',
|
|
19
|
+
'clawbee',
|
|
20
|
+
'skills'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Load all installed skills
|
|
26
|
+
*/
|
|
27
|
+
async loadSkills(): Promise<void> {
|
|
28
|
+
if (!fs.existsSync(this.skillsPath)) {
|
|
29
|
+
fs.mkdirSync(this.skillsPath, { recursive: true });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dirs = fs.readdirSync(this.skillsPath, { withFileTypes: true })
|
|
34
|
+
.filter(dirent => dirent.isDirectory())
|
|
35
|
+
.map(dirent => dirent.name);
|
|
36
|
+
|
|
37
|
+
for (const dir of dirs) {
|
|
38
|
+
try {
|
|
39
|
+
const manifestPath = path.join(this.skillsPath, dir, 'manifest.json');
|
|
40
|
+
if (fs.existsSync(manifestPath)) {
|
|
41
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
42
|
+
this.skills.set(manifest.name, manifest);
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error(`Error loading skill ${dir}:`, error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get all installed skills
|
|
52
|
+
*/
|
|
53
|
+
getSkills(): Skill[] {
|
|
54
|
+
return Array.from(this.skills.values());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get a specific skill
|
|
59
|
+
*/
|
|
60
|
+
getSkill(name: string): Skill | undefined {
|
|
61
|
+
return this.skills.get(name);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Install a skill
|
|
66
|
+
*/
|
|
67
|
+
async install(name: string, source: string): Promise<void> {
|
|
68
|
+
// Placeholder - implement actual skill installation
|
|
69
|
+
console.log(`Installing skill ${name} from ${source}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Uninstall a skill
|
|
74
|
+
*/
|
|
75
|
+
async uninstall(name: string): Promise<void> {
|
|
76
|
+
const skillPath = path.join(this.skillsPath, name);
|
|
77
|
+
if (fs.existsSync(skillPath)) {
|
|
78
|
+
fs.rmSync(skillPath, { recursive: true });
|
|
79
|
+
this.skills.delete(name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Check if a skill is installed
|
|
85
|
+
*/
|
|
86
|
+
isInstalled(name: string): boolean {
|
|
87
|
+
return this.skills.has(name);
|
|
88
|
+
}
|
|
89
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawBee Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface ClawBeeConfig {
|
|
6
|
+
user: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
ai: {
|
|
10
|
+
provider: 'openai' | 'anthropic' | 'google' | 'local';
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
model: string;
|
|
13
|
+
temperature?: number;
|
|
14
|
+
maxTokens?: number;
|
|
15
|
+
};
|
|
16
|
+
integrations: Record<string, IntegrationConfig>;
|
|
17
|
+
memory: {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
maxContext: number;
|
|
20
|
+
};
|
|
21
|
+
security: {
|
|
22
|
+
sandbox: boolean;
|
|
23
|
+
allowedCommands?: string[];
|
|
24
|
+
blockedCommands?: string[];
|
|
25
|
+
};
|
|
26
|
+
version: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IntegrationConfig {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
token?: string;
|
|
33
|
+
webhook?: string;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Message {
|
|
38
|
+
id: string;
|
|
39
|
+
role: 'user' | 'assistant' | 'system';
|
|
40
|
+
content: string;
|
|
41
|
+
timestamp: Date;
|
|
42
|
+
metadata?: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface Skill {
|
|
46
|
+
name: string;
|
|
47
|
+
version: string;
|
|
48
|
+
description: string;
|
|
49
|
+
author: string;
|
|
50
|
+
commands: SkillCommand[];
|
|
51
|
+
triggers?: SkillTrigger[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SkillCommand {
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
handler: (args: any) => Promise<any>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SkillTrigger {
|
|
61
|
+
type: 'keyword' | 'regex' | 'schedule';
|
|
62
|
+
pattern: string;
|
|
63
|
+
handler: (context: any) => Promise<any>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface AIResponse {
|
|
67
|
+
content: string;
|
|
68
|
+
usage?: {
|
|
69
|
+
promptTokens: number;
|
|
70
|
+
completionTokens: number;
|
|
71
|
+
totalTokens: number;
|
|
72
|
+
};
|
|
73
|
+
}
|