-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodebolt.js
executable file
·128 lines (107 loc) · 3.43 KB
/
codebolt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env node
const { program } = require('commander');
const { getVersion } = require('./actions/version');
// const { uploadFolder } = require('./actions/uploadfolder');
const inquirer = require('inquirer');
const {signIn,logout} = require('./actions/login')
// const { login } = require('./actions/login');
const { list } = require('./actions/list');
const {startAgent} = require('./actions/startAgent')
const { createagent } = require('./actions/createagent');
const {createtool} = require("./actions/createtool")
const { spawn } = require('child_process');
const { publishAgent } = require('./actions/publishAgent');
const { pullAgent } = require('./actions/pullAgent');
program.version('1.0.1');
program
.command('version')
.description('Check the application version')
.action(getVersion);
program
.command('login')
.description('Log in to the application')
.action(signIn);
program
.command('logout')
.description('Log out of the application') // Added for logout
.action(logout); // Added for logout
program
.command('createagent')
.description('Create a new Codebolt Agent')
.option('-n, --name <name>', 'name of the project')
.option('--quick', 'create agent quickly with default settings')
.action((options) => {
createagent(options);
});
program
.command('publishagent [folderPath]')
.description('Upload a folder')
.action(publishAgent)
program
.command('listagents')
.description('List all the agents created and uploaded by me')
.action(list);
program
.command('startagent [workingDir]')
.description('Start an agent in the specified working directory')
.action(startAgent);
program
.command('pullagent [workingDir]')
.description('Pull the latest agent configuration from server')
.action(pullAgent);
program
.command('createtool')
.description('Create a new Codebolt Tool')
.option('-n, --name <name>', 'name of the Tool')
.option('-i, --id <unique-id>', 'unique identifier for the tool (no spaces)')
.option('-d, --description <description>', 'description of the tool')
.option('-p, --parameters <json>', 'tool parameters in JSON format (e.g., \'{"param1": "value1"}\')')
.action((options) => {
createtool(options);
});
program
.command('runtool <command> <file>')
.description('Run a specified tool with a required file')
.action((command, file) => {
console.log("Running tool");
try {
const args = ['@wong2/mcp-cli', command, file];
const child = spawn('npx', args, {
stdio: 'inherit',
});
child.on('error', (error) => {
console.error('Error running tool:', error.message);
process.exit(1);
});
child.on('exit', (code) => {
if (code !== 0) {
console.error(`Tool process exited with code ${code}`);
process.exit(code);
}
});
} catch (error) {
console.error('Error running tool:', error.message);
process.exit(1);
}
});
program
.command('inspecttool <file>')
.description('Inspect a server file')
.action((file) => {
try {
const child = spawn('npx', ['@modelcontextprotocol/inspector', 'node', file], {
stdio: 'inherit',
});
child.on('error', () => {
process.exit(1);
});
child.on('exit', (code) => {
if (code !== 0) {
process.exit(code);
}
});
} catch {
process.exit(1);
}
});
program.parse(process.argv);