@nestbox-ai/cli 1.0.8 → 1.0.12

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.
@@ -1,8 +1,9 @@
1
1
  name: Generate the Nextbo AI Cli Tools
2
+
2
3
  on:
3
4
  push:
4
5
  branches:
5
- - '*'
6
+ - main
6
7
 
7
8
  permissions:
8
9
  contents: write
@@ -38,4 +39,4 @@ jobs:
38
39
  npm install && npm run build
39
40
  npm publish --access public --registry=https://registry.npmjs.org
40
41
  env:
41
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,2 +1,2 @@
1
- import { Command } from 'commander';
1
+ import { Command } from "commander";
2
2
  export declare function registerAgentCommands(program: Command): void;
@@ -22,6 +22,7 @@ const project_1 = require("../utils/project");
22
22
  const fs_1 = __importDefault(require("fs"));
23
23
  const agent_1 = require("../utils/agent");
24
24
  const axios_1 = __importDefault(require("axios"));
25
+ const agentType_1 = require("../types/agentType");
25
26
  function registerAgentCommands(program) {
26
27
  // Get authentication token and create API configuration
27
28
  const authToken = (0, auth_1.getAuthToken)();
@@ -29,26 +30,26 @@ function registerAgentCommands(program) {
29
30
  basePath: authToken === null || authToken === void 0 ? void 0 : authToken.serverUrl,
30
31
  baseOptions: {
31
32
  headers: {
32
- "Authorization": authToken === null || authToken === void 0 ? void 0 : authToken.token,
33
- }
34
- }
33
+ Authorization: authToken === null || authToken === void 0 ? void 0 : authToken.token,
34
+ },
35
+ },
35
36
  });
36
37
  const agentsApi = new admin_1.MachineAgentApi(configuration);
37
38
  const projectsApi = new admin_1.ProjectsApi(configuration);
38
39
  // Create the main agent command
39
40
  const agentCommand = program
40
- .command('agent')
41
- .description('Manage Nestbox agents');
41
+ .command("agent")
42
+ .description("Manage Nestbox agents");
42
43
  // Add the list subcommand
43
44
  agentCommand
44
- .command('list')
45
- .description('List all AI agents associated with the authenticated user')
46
- .option('--project <projectName>', 'Project name (defaults to the current project)')
45
+ .command("list")
46
+ .description("List all AI agents associated with the authenticated user")
47
+ .option("--project <projectName>", "Project name (defaults to the current project)")
47
48
  .action((options) => __awaiter(this, void 0, void 0, function* () {
48
49
  var _a, _b;
49
50
  try {
50
51
  if (!authToken) {
51
- console.error(chalk_1.default.red('No authentication token found. Please login first.'));
52
+ console.error(chalk_1.default.red("No authentication token found. Please login first."));
52
53
  return;
53
54
  }
54
55
  try {
@@ -57,8 +58,8 @@ function registerAgentCommands(program) {
57
58
  const spinner = (0, ora_1.default)(`Listing agents in project ${projectData.name}...`).start();
58
59
  try {
59
60
  // Now get the agents for the specific project
60
- const agentsResponse = yield agentsApi.machineAgentControllerGetMachineAgentByProjectId(projectData.id, 0, 10, "");
61
- spinner.succeed('Successfully retrieved agents');
61
+ const agentsResponse = yield agentsApi.machineAgentControllerGetMachineAgentByProjectId(projectData.id, 0, 10, agentType_1.AgentType.REGULAR);
62
+ spinner.succeed("Successfully retrieved agents");
62
63
  // Display the results
63
64
  const agents = ((_a = agentsResponse.data) === null || _a === void 0 ? void 0 : _a.machineAgents) || [];
64
65
  if (!agents || agents.length === 0) {
@@ -69,37 +70,29 @@ function registerAgentCommands(program) {
69
70
  // Create a formatted table focusing on id, name, and URL
70
71
  const table = new cli_table3_1.default({
71
72
  head: [
72
- chalk_1.default.white.bold('ID'),
73
- chalk_1.default.white.bold('Name'),
74
- chalk_1.default.white.bold('Goal'),
75
- chalk_1.default.white.bold('URL'),
76
- chalk_1.default.white.bold('Created At')
73
+ chalk_1.default.white.bold("ID"),
74
+ chalk_1.default.white.bold("Name"),
75
+ chalk_1.default.white.bold("URL"),
77
76
  ],
78
77
  style: {
79
78
  head: [], // Disable the default styling
80
- border: []
81
- }
79
+ border: [],
80
+ },
82
81
  });
83
82
  // Add agents to the table with the requested info
84
83
  agents.forEach((agent) => {
85
84
  // Format the agent URL
86
- let url = 'N/A';
85
+ let url = "N/A";
87
86
  if (agent.instanceIP) {
88
87
  // Construct an agent-specific URL if possible
89
- url = `${agent.instanceIP}`;
88
+ url = `${agent.instanceIP}/v1/agents/${agent.modelBaseId}/query`;
90
89
  }
91
90
  // Format date for readability
92
- let createdAt = agent.createdAt || 'N/A';
93
- if (createdAt !== 'N/A') {
91
+ let createdAt = agent.createdAt || "N/A";
92
+ if (createdAt !== "N/A") {
94
93
  createdAt = new Date(createdAt).toLocaleString();
95
94
  }
96
- table.push([
97
- agent.id || 'N/A',
98
- agent.agentName || 'N/A',
99
- agent.goal || 'N/A',
100
- url,
101
- createdAt
102
- ]);
95
+ table.push([agent.id || "N/A", agent.agentName || "N/A", url]);
103
96
  });
104
97
  // Display the table
105
98
  console.log(table.toString());
@@ -107,34 +100,34 @@ function registerAgentCommands(program) {
107
100
  console.log(`\nTotal agents: ${agents.length}`);
108
101
  }
109
102
  catch (error) {
110
- spinner.fail('Failed to retrieve agents');
103
+ spinner.fail("Failed to retrieve agents");
111
104
  if (error.response) {
112
- console.error(chalk_1.default.red('API Error:'), ((_b = error.response.data) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error');
105
+ console.error(chalk_1.default.red("API Error:"), ((_b = error.response.data) === null || _b === void 0 ? void 0 : _b.message) || "Unknown error");
113
106
  }
114
107
  else {
115
- console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
108
+ console.error(chalk_1.default.red("Error:"), error.message || "Unknown error");
116
109
  }
117
110
  }
118
111
  }
119
112
  catch (error) {
120
- console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
113
+ console.error(chalk_1.default.red("Error:"), error instanceof Error ? error.message : "Unknown error");
121
114
  }
122
115
  }
123
116
  catch (error) {
124
- console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
117
+ console.error(chalk_1.default.red("Error:"), error instanceof Error ? error.message : "Unknown error");
125
118
  }
126
119
  }));
127
- // Remove agent
120
+ // Remove agent
128
121
  agentCommand
129
- .command('remove')
130
- .description('Remove an AI agent')
131
- .requiredOption('--agent <agentId>', 'Agent ID to remove')
132
- .option('--project <projectName>', 'Project name (defaults to the current project)')
122
+ .command("remove")
123
+ .description("Remove an AI agent")
124
+ .requiredOption("--agent <agentId>", "Agent ID to remove")
125
+ .option("--project <projectName>", "Project name (defaults to the current project)")
133
126
  .action((options) => __awaiter(this, void 0, void 0, function* () {
134
127
  var _a, _b;
135
128
  try {
136
129
  if (!authToken) {
137
- console.error(chalk_1.default.red('No authentication token found. Please login first.'));
130
+ console.error(chalk_1.default.red("No authentication token found. Please login first."));
138
131
  return;
139
132
  }
140
133
  const { agent } = options;
@@ -143,8 +136,7 @@ function registerAgentCommands(program) {
143
136
  const spinner = (0, ora_1.default)(`Finding agent ${agent} in project ${projectData.name}...`).start();
144
137
  try {
145
138
  // First, get the list of agents to find the correct modelbaseId
146
- const agentsResponse = yield agentsApi.machineAgentControllerGetMachineAgentByProjectId(projectData.id, 0, 100, // Increased to make sure we get all agents
147
- "");
139
+ const agentsResponse = yield agentsApi.machineAgentControllerGetMachineAgentByProjectId(projectData.id, 0, 100, agentType_1.AgentType.REGULAR);
148
140
  // Get the agents array
149
141
  const agents = ((_a = agentsResponse.data) === null || _a === void 0 ? void 0 : _a.machineAgents) || [];
150
142
  // Find the specific agent by ID
@@ -161,45 +153,47 @@ function registerAgentCommands(program) {
161
153
  }
162
154
  spinner.text = `Removing agent ${agent} from project ${projectData.name}...`;
163
155
  // Now remove the agent with the dynamically retrieved modelbaseId
164
- const payload = [{
156
+ const payload = [
157
+ {
165
158
  id: parseInt(agent, 10),
166
- modelbaseId: modelbaseId
167
- }];
159
+ modelbaseId: modelbaseId,
160
+ },
161
+ ];
168
162
  const removeResponse = yield agentsApi.machineAgentControllerDeleteMachineAgents(projectData.id, agent, payload);
169
- spinner.succeed('Successfully removed agent');
163
+ spinner.succeed("Successfully removed agent");
170
164
  // Display the results
171
165
  console.log(chalk_1.default.green(`Agent ${agent} removed successfully from project ${projectData.name}`));
172
166
  }
173
167
  catch (error) {
174
- spinner.fail('Failed to remove agent');
168
+ spinner.fail("Failed to remove agent");
175
169
  if (error.response) {
176
- console.error(chalk_1.default.red('API Error:'), ((_b = error.response.data) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error');
170
+ console.error(chalk_1.default.red("API Error:"), ((_b = error.response.data) === null || _b === void 0 ? void 0 : _b.message) || "Unknown error");
177
171
  }
178
172
  else {
179
- console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
173
+ console.error(chalk_1.default.red("Error:"), error.message || "Unknown error");
180
174
  }
181
175
  }
182
176
  }
183
177
  catch (error) {
184
- console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
178
+ console.error(chalk_1.default.red("Error:"), error instanceof Error ? error.message : "Unknown error");
185
179
  }
186
180
  }));
187
181
  agentCommand
188
- .command('deploy')
189
- .description('Deploy an AI agent to the Nestbox platform')
190
- .requiredOption('--agent <agentId>', 'Agent ID to deploy')
191
- .requiredOption('--instance <instanceId>', 'Instance ID')
192
- .requiredOption('--zip <zipFileOrDirPath>', 'Path to the zip file or directory to upload')
193
- .option('--project <projectName>', 'Project name (defaults to the current project)')
194
- .option('--entry <entryFunction>', 'Entry function name', 'main')
182
+ .command("deploy")
183
+ .description("Deploy an AI agent to the Nestbox platform")
184
+ .requiredOption("--agent <agentId>", "Agent ID to deploy")
185
+ .requiredOption("--instance <instanceId>", "Instance ID")
186
+ .option("--zip <zipFileOrDirPath>", "Path to the zip file or directory to upload")
187
+ .option("--project <projectName>", "Project name (defaults to the current project)")
188
+ .option("--entry <entryFunction>", "Entry function name", "main")
195
189
  .action((options) => __awaiter(this, void 0, void 0, function* () {
196
190
  var _a, _b, _c, _d, _e, _f;
197
191
  try {
198
192
  if (!authToken) {
199
- console.error(chalk_1.default.red('No authentication token found. Please login first.'));
193
+ console.error(chalk_1.default.red("No authentication token found. Please login first."));
200
194
  return;
201
195
  }
202
- const { agent: agentId, instance: instanceId, zip: customZipPath, entry } = options;
196
+ const { agent: agentId, instance: instanceId, zip: customZipPath, entry, } = options;
203
197
  // Find project root (CLI tools directory)
204
198
  const projectRoot = yield (0, agent_1.findProjectRoot)();
205
199
  console.log(chalk_1.default.blue(`Project root detected at: ${projectRoot}`));
@@ -222,7 +216,7 @@ function registerAgentCommands(program) {
222
216
  const stats = fs_1.default.statSync(sourcePath);
223
217
  if (stats.isFile()) {
224
218
  // Case 1: It's a file - verify it's a zip and use directly
225
- if (!sourcePath.toLowerCase().endsWith('.zip')) {
219
+ if (!sourcePath.toLowerCase().endsWith(".zip")) {
226
220
  spinner.fail(`File is not a zip archive: ${sourcePath}`);
227
221
  return;
228
222
  }
@@ -243,7 +237,7 @@ function registerAgentCommands(program) {
243
237
  yield (0, agent_1.runPredeployScripts)(predeployScripts, sourcePath);
244
238
  }
245
239
  else {
246
- spinner.info('No predeploy scripts found in CLI tools nestbox.config.json');
240
+ spinner.info("No predeploy scripts found in CLI tools nestbox.config.json");
247
241
  }
248
242
  }
249
243
  else {
@@ -261,23 +255,23 @@ function registerAgentCommands(program) {
261
255
  }
262
256
  spinner.text = `Deploying agent ${agentId} to instance ${instanceId}...`;
263
257
  // Clean the base URL to avoid path duplication
264
- const baseUrl = ((_e = authToken === null || authToken === void 0 ? void 0 : authToken.serverUrl) === null || _e === void 0 ? void 0 : _e.endsWith('/'))
258
+ const baseUrl = ((_e = authToken === null || authToken === void 0 ? void 0 : authToken.serverUrl) === null || _e === void 0 ? void 0 : _e.endsWith("/"))
265
259
  ? authToken.serverUrl.slice(0, -1)
266
260
  : authToken === null || authToken === void 0 ? void 0 : authToken.serverUrl;
267
- const FormData = require('form-data');
261
+ const FormData = require("form-data");
268
262
  const form = new FormData();
269
263
  // Add file as a readable stream
270
- form.append('file', fs_1.default.createReadStream(zipFilePath));
264
+ form.append("file", fs_1.default.createReadStream(zipFilePath));
271
265
  // Add all the required fields
272
- form.append('machineAgentId', agentId.toString());
273
- form.append('instanceId', instanceId.toString());
274
- form.append('entryFunctionName', entry);
275
- form.append('isSourceCodeUpdate', 'true');
276
- form.append('projectId', projectData.id);
266
+ form.append("machineAgentId", agentId.toString());
267
+ form.append("instanceId", instanceId.toString());
268
+ form.append("entryFunctionName", entry);
269
+ form.append("isSourceCodeUpdate", "true");
270
+ form.append("projectId", projectData.id);
277
271
  // Create a custom axios instance with form-data headers
278
272
  const axiosInstance = axios_1.default.create({
279
273
  baseURL: baseUrl,
280
- headers: Object.assign(Object.assign({}, form.getHeaders()), { "Authorization": authToken === null || authToken === void 0 ? void 0 : authToken.token })
274
+ headers: Object.assign(Object.assign({}, form.getHeaders()), { Authorization: authToken === null || authToken === void 0 ? void 0 : authToken.token }),
281
275
  });
282
276
  // Construct the endpoint URL
283
277
  const endpoint = `/projects/${projectData.id}/agents/${agentId}`;
@@ -288,20 +282,20 @@ function registerAgentCommands(program) {
288
282
  fs_1.default.unlinkSync(zipFilePath);
289
283
  }
290
284
  spinner.succeed(`Successfully deployed agent ${agentId} to instance ${instanceId}`);
291
- console.log(chalk_1.default.green('Agent deployed successfully'));
285
+ console.log(chalk_1.default.green("Agent deployed successfully"));
292
286
  }
293
287
  catch (error) {
294
- spinner.fail('Failed to deploy agent');
288
+ spinner.fail("Failed to deploy agent");
295
289
  if (error.response) {
296
- console.error(chalk_1.default.red(`API Error (${error.response.status}): ${((_f = error.response.data) === null || _f === void 0 ? void 0 : _f.message) || 'Unknown error'}`));
290
+ console.error(chalk_1.default.red(`API Error (${error.response.status}): ${((_f = error.response.data) === null || _f === void 0 ? void 0 : _f.message) || "Unknown error"}`));
297
291
  }
298
292
  else {
299
- console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
293
+ console.error(chalk_1.default.red("Error:"), error.message || "Unknown error");
300
294
  }
301
295
  }
302
296
  }
303
297
  catch (error) {
304
- console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
298
+ console.error(chalk_1.default.red("Error:"), error instanceof Error ? error.message : "Unknown error");
305
299
  }
306
300
  }));
307
301
  }
@@ -1 +1 @@
1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type, which is used to categorize different types of agents.
3
+ */
4
+ export declare enum AgentType {
5
+ REGULAR = "REGULAR",
6
+ CHATBOT = "CHATBOT"
7
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentType = void 0;
4
+ /**
5
+ * This file defines the AgentType type, which is used to categorize different types of agents.
6
+ */
7
+ var AgentType;
8
+ (function (AgentType) {
9
+ AgentType["REGULAR"] = "REGULAR";
10
+ AgentType["CHATBOT"] = "CHATBOT";
11
+ })(AgentType || (exports.AgentType = AgentType = {}));
12
+ //# sourceMappingURL=agentType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentType.js","sourceRoot":"","sources":["../../src/types/agentType.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;AACrB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestbox-ai/cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.12",
4
4
  "description": "The cli tools that helps developers to build agents",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,15 +1,20 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
- import Table from 'cli-table3';
5
- import { getAuthToken } from '../utils/auth';
6
- import { Configuration, MachineAgentApi, ProjectsApi } from '@nestbox-ai/admin';
7
- import { resolveProject } from '../utils/project';
8
- import fs from 'fs';
9
- import { createZipFromDirectory, findProjectRoot, isTypeScriptProject, loadNestboxConfig, runPredeployScripts } from '../utils/agent';
10
- import axios from 'axios';
11
-
12
-
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import ora from "ora";
4
+ import Table from "cli-table3";
5
+ import { getAuthToken } from "../utils/auth";
6
+ import { Configuration, MachineAgentApi, ProjectsApi } from "@nestbox-ai/admin";
7
+ import { resolveProject } from "../utils/project";
8
+ import fs from "fs";
9
+ import {
10
+ createZipFromDirectory,
11
+ findProjectRoot,
12
+ isTypeScriptProject,
13
+ loadNestboxConfig,
14
+ runPredeployScripts,
15
+ } from "../utils/agent";
16
+ import axios from "axios";
17
+ import { AgentType } from "../types/agentType";
13
18
 
14
19
  export function registerAgentCommands(program: Command): void {
15
20
  // Get authentication token and create API configuration
@@ -18,9 +23,9 @@ export function registerAgentCommands(program: Command): void {
18
23
  basePath: authToken?.serverUrl,
19
24
  baseOptions: {
20
25
  headers: {
21
- "Authorization": authToken?.token,
22
- }
23
- }
26
+ Authorization: authToken?.token,
27
+ },
28
+ },
24
29
  });
25
30
 
26
31
  const agentsApi = new MachineAgentApi(configuration);
@@ -28,328 +33,402 @@ export function registerAgentCommands(program: Command): void {
28
33
 
29
34
  // Create the main agent command
30
35
  const agentCommand = program
31
- .command('agent')
32
- .description('Manage Nestbox agents');
36
+ .command("agent")
37
+ .description("Manage Nestbox agents");
33
38
 
34
39
  // Add the list subcommand
35
- agentCommand
36
- .command('list')
37
- .description('List all AI agents associated with the authenticated user')
38
- .option('--project <projectName>', 'Project name (defaults to the current project)')
39
- .action(async (options) => {
40
- try {
41
- if (!authToken) {
42
- console.error(chalk.red('No authentication token found. Please login first.'));
43
- return;
44
- }
45
-
46
- try {
47
- // Use the resolveProject helper to get project information
48
- const projectData = await resolveProject(projectsApi, options);
49
-
50
- const spinner = ora(`Listing agents in project ${projectData.name}...`).start();
51
-
40
+ agentCommand
41
+ .command("list")
42
+ .description("List all AI agents associated with the authenticated user")
43
+ .option(
44
+ "--project <projectName>",
45
+ "Project name (defaults to the current project)"
46
+ )
47
+ .action(async (options) => {
52
48
  try {
53
- // Now get the agents for the specific project
54
- const agentsResponse: any = await agentsApi.machineAgentControllerGetMachineAgentByProjectId(projectData.id, 0, 10, "");
55
-
56
- spinner.succeed('Successfully retrieved agents');
49
+ if (!authToken) {
50
+ console.error(
51
+ chalk.red("No authentication token found. Please login first.")
52
+ );
53
+ return;
54
+ }
55
+
56
+ try {
57
+ // Use the resolveProject helper to get project information
58
+ const projectData = await resolveProject(projectsApi, options);
59
+
60
+ const spinner = ora(
61
+ `Listing agents in project ${projectData.name}...`
62
+ ).start();
63
+
64
+ try {
65
+ // Now get the agents for the specific project
66
+ const agentsResponse: any =
67
+ await agentsApi.machineAgentControllerGetMachineAgentByProjectId(
68
+ projectData.id,
69
+ 0,
70
+ 10,
71
+ AgentType.REGULAR
72
+ );
73
+
74
+ spinner.succeed("Successfully retrieved agents");
57
75
 
58
- // Display the results
59
- const agents = agentsResponse.data?.machineAgents || [];
76
+ // Display the results
77
+ const agents = agentsResponse.data?.machineAgents || [];
78
+
79
+ if (!agents || agents.length === 0) {
80
+ console.log(
81
+ chalk.yellow(`No agents found in project ${projectData.name}`)
82
+ );
83
+ return;
84
+ }
85
+
86
+ console.log(
87
+ chalk.blue(`\nAgents in project ${projectData.name}:\n`)
88
+ );
89
+
90
+ // Create a formatted table focusing on id, name, and URL
91
+ const table = new Table({
92
+ head: [
93
+ chalk.white.bold("ID"),
94
+ chalk.white.bold("Name"),
95
+ chalk.white.bold("URL"),
96
+ ],
97
+ style: {
98
+ head: [], // Disable the default styling
99
+ border: [],
100
+ },
101
+ });
102
+
103
+ // Add agents to the table with the requested info
104
+ agents.forEach((agent: any) => {
105
+ // Format the agent URL
106
+ let url = "N/A";
107
+ if (agent.instanceIP) {
108
+ // Construct an agent-specific URL if possible
109
+ url = `${agent.instanceIP}/v1/agents/${agent.modelBaseId}/query`;
110
+ }
111
+
112
+ // Format date for readability
113
+ let createdAt = agent.createdAt || "N/A";
114
+ if (createdAt !== "N/A") {
115
+ createdAt = new Date(createdAt).toLocaleString();
116
+ }
117
+
118
+ table.push([agent.id || "N/A", agent.agentName || "N/A", url]);
119
+ });
120
+
121
+ // Display the table
122
+ console.log(table.toString());
123
+
124
+ // Display totals
125
+ console.log(`\nTotal agents: ${agents.length}`);
126
+ } catch (error: any) {
127
+ spinner.fail("Failed to retrieve agents");
128
+ if (error.response) {
129
+ console.error(
130
+ chalk.red("API Error:"),
131
+ error.response.data?.message || "Unknown error"
132
+ );
133
+ } else {
134
+ console.error(
135
+ chalk.red("Error:"),
136
+ error.message || "Unknown error"
137
+ );
138
+ }
139
+ }
140
+ } catch (error: any) {
141
+ console.error(
142
+ chalk.red("Error:"),
143
+ error instanceof Error ? error.message : "Unknown error"
144
+ );
145
+ }
146
+ } catch (error) {
147
+ console.error(
148
+ chalk.red("Error:"),
149
+ error instanceof Error ? error.message : "Unknown error"
150
+ );
151
+ }
152
+ });
60
153
 
61
- if (!agents || agents.length === 0) {
62
- console.log(chalk.yellow(`No agents found in project ${projectData.name}`));
154
+ // Remove agent
155
+ agentCommand
156
+ .command("remove")
157
+ .description("Remove an AI agent")
158
+ .requiredOption("--agent <agentId>", "Agent ID to remove")
159
+ .option(
160
+ "--project <projectName>",
161
+ "Project name (defaults to the current project)"
162
+ )
163
+ .action(async (options) => {
164
+ try {
165
+ if (!authToken) {
166
+ console.error(
167
+ chalk.red("No authentication token found. Please login first.")
168
+ );
63
169
  return;
64
170
  }
65
171
 
66
- console.log(chalk.blue(`\nAgents in project ${projectData.name}:\n`));
67
-
68
- // Create a formatted table focusing on id, name, and URL
69
- const table = new Table({
70
- head: [
71
- chalk.white.bold('ID'),
72
- chalk.white.bold('Name'),
73
- chalk.white.bold('Goal'),
74
- chalk.white.bold('URL'),
75
- chalk.white.bold('Created At')
76
- ],
77
- style: {
78
- head: [], // Disable the default styling
79
- border: []
172
+ const { agent } = options;
173
+
174
+ // Use the resolveProject helper to get project information
175
+ const projectData = await resolveProject(projectsApi, options);
176
+
177
+ const spinner = ora(
178
+ `Finding agent ${agent} in project ${projectData.name}...`
179
+ ).start();
180
+
181
+ try {
182
+ // First, get the list of agents to find the correct modelbaseId
183
+ const agentsResponse: any =
184
+ await agentsApi.machineAgentControllerGetMachineAgentByProjectId(
185
+ projectData.id,
186
+ 0,
187
+ 100,
188
+ AgentType.REGULAR
189
+ );
190
+
191
+ // Get the agents array
192
+ const agents = agentsResponse.data?.machineAgents || [];
193
+
194
+ // Find the specific agent by ID
195
+ const targetAgent = agents.find(
196
+ (a: any) => a.id.toString() === agent.toString()
197
+ );
198
+
199
+ if (!targetAgent) {
200
+ spinner.fail(
201
+ `Agent with ID ${agent} not found in project ${projectData.name}`
202
+ );
203
+ return;
80
204
  }
81
- });
82
-
83
- // Add agents to the table with the requested info
84
- agents.forEach((agent: any) => {
85
- // Format the agent URL
86
- let url = 'N/A';
87
- if (agent.instanceIP) {
88
- // Construct an agent-specific URL if possible
89
- url = `${agent.instanceIP}`;
205
+
206
+ // Extract the modelbaseId from the found agent
207
+ const modelbaseId = targetAgent.modelBaseId;
208
+
209
+ if (!modelbaseId) {
210
+ spinner.fail(
211
+ `Could not find modelbaseId for agent ${agent}. Please try again.`
212
+ );
213
+ return;
90
214
  }
91
-
92
- // Format date for readability
93
- let createdAt = agent.createdAt || 'N/A';
94
- if (createdAt !== 'N/A') {
95
- createdAt = new Date(createdAt).toLocaleString();
215
+
216
+ spinner.text = `Removing agent ${agent} from project ${projectData.name}...`;
217
+
218
+ // Now remove the agent with the dynamically retrieved modelbaseId
219
+ const payload: any = [
220
+ {
221
+ id: parseInt(agent, 10),
222
+ modelbaseId: modelbaseId,
223
+ },
224
+ ];
225
+
226
+ const removeResponse =
227
+ await agentsApi.machineAgentControllerDeleteMachineAgents(
228
+ projectData.id,
229
+ agent,
230
+ payload
231
+ );
232
+
233
+ spinner.succeed("Successfully removed agent");
234
+
235
+ // Display the results
236
+ console.log(
237
+ chalk.green(
238
+ `Agent ${agent} removed successfully from project ${projectData.name}`
239
+ )
240
+ );
241
+ } catch (error: any) {
242
+ spinner.fail("Failed to remove agent");
243
+ if (error.response) {
244
+ console.error(
245
+ chalk.red("API Error:"),
246
+ error.response.data?.message || "Unknown error"
247
+ );
248
+ } else {
249
+ console.error(
250
+ chalk.red("Error:"),
251
+ error.message || "Unknown error"
252
+ );
96
253
  }
97
-
98
- table.push([
99
- agent.id || 'N/A',
100
- agent.agentName || 'N/A',
101
- agent.goal || 'N/A',
102
- url,
103
- createdAt
104
- ]);
105
- });
106
-
107
- // Display the table
108
- console.log(table.toString());
109
-
110
- // Display totals
111
- console.log(`\nTotal agents: ${agents.length}`);
112
-
113
- } catch (error: any) {
114
- spinner.fail('Failed to retrieve agents');
115
- if (error.response) {
116
- console.error(chalk.red('API Error:'), error.response.data?.message || 'Unknown error');
117
- } else {
118
- console.error(chalk.red('Error:'), error.message || 'Unknown error');
119
254
  }
255
+ } catch (error) {
256
+ console.error(
257
+ chalk.red("Error:"),
258
+ error instanceof Error ? error.message : "Unknown error"
259
+ );
120
260
  }
121
- } catch (error: any) {
122
- console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
123
- }
124
- } catch (error) {
125
- console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
126
- }
127
- });
128
-
129
-
130
- // Remove agent
131
- agentCommand
132
- .command('remove')
133
- .description('Remove an AI agent')
134
- .requiredOption('--agent <agentId>', 'Agent ID to remove')
135
- .option('--project <projectName>', 'Project name (defaults to the current project)')
136
- .action(async (options) => {
137
- try {
138
- if (!authToken) {
139
- console.error(chalk.red('No authentication token found. Please login first.'));
140
- return;
141
- }
142
-
143
- const { agent } = options;
144
-
145
- // Use the resolveProject helper to get project information
146
- const projectData = await resolveProject(projectsApi, options);
147
-
148
- const spinner = ora(`Finding agent ${agent} in project ${projectData.name}...`).start();
149
-
150
- try {
151
- // First, get the list of agents to find the correct modelbaseId
152
- const agentsResponse: any = await agentsApi.machineAgentControllerGetMachineAgentByProjectId(
153
- projectData.id,
154
- 0,
155
- 100, // Increased to make sure we get all agents
156
- ""
157
- );
158
-
159
- // Get the agents array
160
- const agents = agentsResponse.data?.machineAgents || [];
161
-
162
- // Find the specific agent by ID
163
- const targetAgent = agents.find((a: any) => a.id.toString() === agent.toString());
164
-
165
- if (!targetAgent) {
166
- spinner.fail(`Agent with ID ${agent} not found in project ${projectData.name}`);
167
- return;
168
- }
261
+ });
169
262
 
170
- // Extract the modelbaseId from the found agent
171
- const modelbaseId = targetAgent.modelBaseId;
172
-
173
- if (!modelbaseId) {
174
- spinner.fail(`Could not find modelbaseId for agent ${agent}. Please try again.`);
175
- return;
176
- }
177
-
178
- spinner.text = `Removing agent ${agent} from project ${projectData.name}...`;
179
-
180
- // Now remove the agent with the dynamically retrieved modelbaseId
181
- const payload: any = [{
182
- id: parseInt(agent, 10),
183
- modelbaseId: modelbaseId
184
- }];
185
-
186
- const removeResponse = await agentsApi.machineAgentControllerDeleteMachineAgents(
187
- projectData.id,
188
- agent,
189
- payload
190
- );
191
-
192
- spinner.succeed('Successfully removed agent');
193
-
194
- // Display the results
195
- console.log(chalk.green(`Agent ${agent} removed successfully from project ${projectData.name}`));
196
-
197
- } catch (error: any) {
198
- spinner.fail('Failed to remove agent');
199
- if (error.response) {
200
- console.error(chalk.red('API Error:'), error.response.data?.message || 'Unknown error');
201
- } else {
202
- console.error(chalk.red('Error:'), error.message || 'Unknown error');
203
- }
204
- }
205
- } catch (error) {
206
- console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
207
- }
208
- });
209
-
210
- agentCommand
211
- .command('deploy')
212
- .description('Deploy an AI agent to the Nestbox platform')
213
- .requiredOption('--agent <agentId>', 'Agent ID to deploy')
214
- .requiredOption('--instance <instanceId>', 'Instance ID')
215
- .requiredOption('--zip <zipFileOrDirPath>', 'Path to the zip file or directory to upload')
216
- .option('--project <projectName>', 'Project name (defaults to the current project)')
217
- .option('--entry <entryFunction>', 'Entry function name', 'main')
218
- .action(async (options) => {
219
- try {
220
- if (!authToken) {
221
- console.error(chalk.red('No authentication token found. Please login first.'));
222
- return;
223
- }
224
-
225
- const { agent: agentId, instance: instanceId, zip: customZipPath, entry } = options;
226
-
227
- // Find project root (CLI tools directory)
228
- const projectRoot = await findProjectRoot();
229
- console.log(chalk.blue(`Project root detected at: ${projectRoot}`));
230
-
231
- // Use the resolveProject helper to get project information
232
- const projectData = await resolveProject(projectsApi, options);
233
-
234
- // Load nestbox.config.json from CLI tools directory
235
- const config = loadNestboxConfig(projectRoot);
236
-
237
- // Start the deployment process
238
- const spinner = ora(`Preparing to deploy agent ${agentId} to instance ${instanceId}...`).start();
239
-
240
- try {
241
- // Determine the source path (custom path or project root)
242
- const sourcePath = customZipPath || projectRoot;
243
-
244
- let zipFilePath;
245
-
246
- // Check if the specified path exists
247
- if (!fs.existsSync(sourcePath)) {
248
- spinner.fail(`Path not found: ${sourcePath}`);
249
- return;
250
- }
251
-
252
- // Check if the path is a zip file or directory
253
- const stats = fs.statSync(sourcePath);
254
-
255
- if (stats.isFile()) {
256
- // Case 1: It's a file - verify it's a zip and use directly
257
- if (!sourcePath.toLowerCase().endsWith('.zip')) {
258
- spinner.fail(`File is not a zip archive: ${sourcePath}`);
263
+ agentCommand
264
+ .command("deploy")
265
+ .description("Deploy an AI agent to the Nestbox platform")
266
+ .requiredOption("--agent <agentId>", "Agent ID to deploy")
267
+ .requiredOption("--instance <instanceId>", "Instance ID")
268
+ .option(
269
+ "--zip <zipFileOrDirPath>",
270
+ "Path to the zip file or directory to upload"
271
+ )
272
+ .option(
273
+ "--project <projectName>",
274
+ "Project name (defaults to the current project)"
275
+ )
276
+ .option("--entry <entryFunction>", "Entry function name", "main")
277
+ .action(async (options) => {
278
+ try {
279
+ if (!authToken) {
280
+ console.error(
281
+ chalk.red("No authentication token found. Please login first.")
282
+ );
259
283
  return;
260
284
  }
261
-
262
- // Use the zip file directly
263
- spinner.text = `Using provided zip file: ${sourcePath}`;
264
- zipFilePath = sourcePath;
265
-
266
- } else if (stats.isDirectory()) {
267
- // Case 2: It's a directory - check for predeploy scripts in CLI config
268
-
269
- // Determine if it's a TypeScript project
270
- const isTypeScript = isTypeScriptProject(sourcePath);
271
-
272
- if (isTypeScript) {
273
- spinner.text = `TypeScript project detected. Checking for predeploy scripts...`;
274
-
275
- // Run predeploy scripts if defined in CLI tools config
276
- if (config?.agent?.predeploy || config?.agents?.predeploy) {
277
- const predeployScripts = config?.agent?.predeploy || config?.agents?.predeploy;
278
- spinner.text = `Running predeploy scripts on target directory...`;
279
- await runPredeployScripts(predeployScripts, sourcePath);
285
+
286
+ const {
287
+ agent: agentId,
288
+ instance: instanceId,
289
+ zip: customZipPath,
290
+ entry,
291
+ } = options;
292
+
293
+ // Find project root (CLI tools directory)
294
+ const projectRoot = await findProjectRoot();
295
+ console.log(chalk.blue(`Project root detected at: ${projectRoot}`));
296
+
297
+ // Use the resolveProject helper to get project information
298
+ const projectData = await resolveProject(projectsApi, options);
299
+
300
+ // Load nestbox.config.json from CLI tools directory
301
+ const config = loadNestboxConfig(projectRoot);
302
+
303
+ // Start the deployment process
304
+ const spinner = ora(
305
+ `Preparing to deploy agent ${agentId} to instance ${instanceId}...`
306
+ ).start();
307
+
308
+ try {
309
+ // Determine the source path (custom path or project root)
310
+ const sourcePath = customZipPath || projectRoot;
311
+
312
+ let zipFilePath;
313
+
314
+ // Check if the specified path exists
315
+ if (!fs.existsSync(sourcePath)) {
316
+ spinner.fail(`Path not found: ${sourcePath}`);
317
+ return;
318
+ }
319
+
320
+ // Check if the path is a zip file or directory
321
+ const stats = fs.statSync(sourcePath);
322
+
323
+ if (stats.isFile()) {
324
+ // Case 1: It's a file - verify it's a zip and use directly
325
+ if (!sourcePath.toLowerCase().endsWith(".zip")) {
326
+ spinner.fail(`File is not a zip archive: ${sourcePath}`);
327
+ return;
328
+ }
329
+
330
+ // Use the zip file directly
331
+ spinner.text = `Using provided zip file: ${sourcePath}`;
332
+ zipFilePath = sourcePath;
333
+ } else if (stats.isDirectory()) {
334
+ // Case 2: It's a directory - check for predeploy scripts in CLI config
335
+
336
+ // Determine if it's a TypeScript project
337
+ const isTypeScript = isTypeScriptProject(sourcePath);
338
+
339
+ if (isTypeScript) {
340
+ spinner.text = `TypeScript project detected. Checking for predeploy scripts...`;
341
+
342
+ // Run predeploy scripts if defined in CLI tools config
343
+ if (config?.agent?.predeploy || config?.agents?.predeploy) {
344
+ const predeployScripts =
345
+ config?.agent?.predeploy || config?.agents?.predeploy;
346
+ spinner.text = `Running predeploy scripts on target directory...`;
347
+ await runPredeployScripts(predeployScripts, sourcePath);
348
+ } else {
349
+ spinner.info(
350
+ "No predeploy scripts found in CLI tools nestbox.config.json"
351
+ );
352
+ }
353
+ } else {
354
+ // JavaScript directory - just zip it
355
+ spinner.text = `JavaScript project detected. Skipping predeploy scripts.`;
356
+ }
357
+
358
+ // Create zip archive with node_modules excluded
359
+ spinner.text = `Creating zip archive from directory ${sourcePath}...`;
360
+ zipFilePath = createZipFromDirectory(sourcePath);
361
+ spinner.text = `Directory zipped successfully to ${zipFilePath}`;
280
362
  } else {
281
- spinner.info('No predeploy scripts found in CLI tools nestbox.config.json');
363
+ spinner.fail(`Unsupported file type: ${sourcePath}`);
364
+ return;
282
365
  }
283
- } else {
284
- // JavaScript directory - just zip it
285
- spinner.text = `JavaScript project detected. Skipping predeploy scripts.`;
286
- }
287
-
288
- // Create zip archive with node_modules excluded
289
- spinner.text = `Creating zip archive from directory ${sourcePath}...`;
290
- zipFilePath = createZipFromDirectory(sourcePath);
291
- spinner.text = `Directory zipped successfully to ${zipFilePath}`;
292
- } else {
293
- spinner.fail(`Unsupported file type: ${sourcePath}`);
294
- return;
295
- }
296
-
297
- spinner.text = `Deploying agent ${agentId} to instance ${instanceId}...`;
298
-
299
- // Clean the base URL to avoid path duplication
300
- const baseUrl = authToken?.serverUrl?.endsWith('/')
301
- ? authToken.serverUrl.slice(0, -1)
302
- : authToken?.serverUrl;
303
-
304
- const FormData = require('form-data');
305
- const form = new FormData();
306
-
307
- // Add file as a readable stream
308
- form.append('file', fs.createReadStream(zipFilePath));
309
-
310
- // Add all the required fields
311
- form.append('machineAgentId', agentId.toString());
312
- form.append('instanceId', instanceId.toString());
313
- form.append('entryFunctionName', entry);
314
- form.append('isSourceCodeUpdate', 'true');
315
- form.append('projectId', projectData.id);
316
-
317
- // Create a custom axios instance with form-data headers
318
- const axiosInstance = axios.create({
319
- baseURL: baseUrl,
320
- headers: {
321
- ...form.getHeaders(),
322
- "Authorization": authToken?.token
323
- }
324
- });
325
-
326
- // Construct the endpoint URL
327
- const endpoint = `/projects/${projectData.id}/agents/${agentId}`;
328
-
329
- // Make direct axios request
330
- await axiosInstance.patch(endpoint, form);
331
-
332
- // Clean up temporary zip file if we created one
333
- if (zipFilePath !== sourcePath && fs.existsSync(zipFilePath)) {
334
- fs.unlinkSync(zipFilePath);
335
- }
336
-
337
- spinner.succeed(`Successfully deployed agent ${agentId} to instance ${instanceId}`);
338
- console.log(chalk.green('Agent deployed successfully'));
339
-
340
- } catch (error: any) {
341
- spinner.fail('Failed to deploy agent');
342
-
343
- if (error.response) {
344
- console.error(chalk.red(`API Error (${error.response.status}): ${error.response.data?.message || 'Unknown error'}`));
345
- } else {
346
- console.error(chalk.red('Error:'), error.message || 'Unknown error');
347
- }
348
- }
349
- } catch (error) {
350
- console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
351
- }
352
- })
353
366
 
367
+ spinner.text = `Deploying agent ${agentId} to instance ${instanceId}...`;
368
+
369
+ // Clean the base URL to avoid path duplication
370
+ const baseUrl = authToken?.serverUrl?.endsWith("/")
371
+ ? authToken.serverUrl.slice(0, -1)
372
+ : authToken?.serverUrl;
373
+
374
+ const FormData = require("form-data");
375
+ const form = new FormData();
376
+
377
+ // Add file as a readable stream
378
+ form.append("file", fs.createReadStream(zipFilePath));
379
+
380
+ // Add all the required fields
381
+ form.append("machineAgentId", agentId.toString());
382
+ form.append("instanceId", instanceId.toString());
383
+ form.append("entryFunctionName", entry);
384
+ form.append("isSourceCodeUpdate", "true");
385
+ form.append("projectId", projectData.id);
386
+
387
+ // Create a custom axios instance with form-data headers
388
+ const axiosInstance = axios.create({
389
+ baseURL: baseUrl,
390
+ headers: {
391
+ ...form.getHeaders(),
392
+ Authorization: authToken?.token,
393
+ },
394
+ });
354
395
 
396
+ // Construct the endpoint URL
397
+ const endpoint = `/projects/${projectData.id}/agents/${agentId}`;
398
+
399
+ // Make direct axios request
400
+ await axiosInstance.patch(endpoint, form);
401
+
402
+ // Clean up temporary zip file if we created one
403
+ if (zipFilePath !== sourcePath && fs.existsSync(zipFilePath)) {
404
+ fs.unlinkSync(zipFilePath);
405
+ }
406
+
407
+ spinner.succeed(
408
+ `Successfully deployed agent ${agentId} to instance ${instanceId}`
409
+ );
410
+ console.log(chalk.green("Agent deployed successfully"));
411
+ } catch (error: any) {
412
+ spinner.fail("Failed to deploy agent");
413
+
414
+ if (error.response) {
415
+ console.error(
416
+ chalk.red(
417
+ `API Error (${error.response.status}): ${error.response.data?.message || "Unknown error"}`
418
+ )
419
+ );
420
+ } else {
421
+ console.error(
422
+ chalk.red("Error:"),
423
+ error.message || "Unknown error"
424
+ );
425
+ }
426
+ }
427
+ } catch (error) {
428
+ console.error(
429
+ chalk.red("Error:"),
430
+ error instanceof Error ? error.message : "Unknown error"
431
+ );
432
+ }
433
+ });
355
434
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file defines the AgentType type, which is used to categorize different types of agents.
3
+ */
4
+ export enum AgentType {
5
+ REGULAR = 'REGULAR',
6
+ CHATBOT = 'CHATBOT',
7
+ }