-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodebolt.js
More file actions
executable file
·169 lines (138 loc) · 4.83 KB
/
codebolt.js
File metadata and controls
executable file
·169 lines (138 loc) · 4.83 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/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 { publishAgent } = require('./actions/publishAgent');
const { publishTool } = require('./actions/publishTool');
const { pullAgent } = require('./actions/pullAgent');
const { pullTool } = require('./actions/pullTool');
const { listTools } = require('./actions/listTools');
const { runTool, inspectTool } = require('./actions/toolCommands');
const { spawn } = require('child_process');
const { cloneAgent } = require('./actions/cloneAgent');
const { init } = require('./actions/init');
const { createprovider } = require('./actions/createprovider');
const { publishProvider } = require('./actions/publishProvider');
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('listtools')
.description('List all the MCP tools published by me')
.action(listTools);
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('pulltool [workingDir]')
.description('Pull the latest MCP tool configuration from server')
.action(pullTool);
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('publishtool [folderPath]')
.description('Publish a MCP tool to the registry')
.action(publishTool);
program
.command('runtool <command> <file>')
.description('Run a specified tool with a required file')
.action(runTool);
program
.command('inspecttool <file>')
.description('Inspect a server file')
.action((file) => {
try {
console.log(file)
const child = spawn('npx', ['@modelcontextprotocol/inspector', 'node', file], {
stdio: 'inherit',
});
console.log(child)
console.log('Inspector process started for file:', file);
child.on('error', (error) => {
console.error('Error starting inspector process:', error.message);
process.exit(1);
});
child.on('exit', (code) => {
if (code !== 0) {
console.error(`Inspector process exited with code ${code}`);
process.exit(code);
} else {
console.log('Inspector process completed successfully.');
}
});
} catch (error) {
console.error('Unexpected error:', error.message);
process.exit(1);
}
});
program
.command('cloneagent <unique_id> [targetDir]')
.description('Clone an agent using its unique_id to the specified directory (defaults to current directory)')
.action((unique_id, targetDir) => {
cloneAgent(unique_id, targetDir);
});
program
.command('init')
.description('Initialize the Codebolt CLI')
.action(init);
program
.command('createprovider')
.description('Create a new Codebolt Provider')
.option('-n, --name <name>', 'name of the provider')
.option('--quick', 'create provider quickly with default settings')
.action((options) => {
createprovider(options);
});
program
.command('publishprovider [folderPath]')
.description('Publish a Codebolt Provider to the registry')
.action((options) => {
publishProvider(options);
});
program.parse(process.argv);