@nestbox-ai/cli 1.0.23 → 1.0.25

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.
Files changed (61) hide show
  1. package/dist/commands/agent/apiUtils.d.ts +10 -0
  2. package/dist/commands/agent/apiUtils.js +20 -0
  3. package/dist/commands/agent/apiUtils.js.map +1 -0
  4. package/dist/commands/agent/create.d.ts +29 -0
  5. package/dist/commands/agent/create.js +88 -0
  6. package/dist/commands/agent/create.js.map +1 -0
  7. package/dist/commands/agent/createFromYaml.d.ts +2 -0
  8. package/dist/commands/agent/createFromYaml.js +172 -0
  9. package/dist/commands/agent/createFromYaml.js.map +1 -0
  10. package/dist/commands/agent/deploy.d.ts +2 -0
  11. package/dist/commands/agent/deploy.js +243 -0
  12. package/dist/commands/agent/deploy.js.map +1 -0
  13. package/dist/commands/agent/generate.d.ts +2 -0
  14. package/dist/commands/agent/generate.js +141 -0
  15. package/dist/commands/agent/generate.js.map +1 -0
  16. package/dist/commands/agent/index.d.ts +7 -0
  17. package/dist/commands/agent/index.js +21 -0
  18. package/dist/commands/agent/index.js.map +1 -0
  19. package/dist/commands/agent/list.d.ts +2 -0
  20. package/dist/commands/agent/list.js +94 -0
  21. package/dist/commands/agent/list.js.map +1 -0
  22. package/dist/commands/agent/remove.d.ts +2 -0
  23. package/dist/commands/agent/remove.js +85 -0
  24. package/dist/commands/agent/remove.js.map +1 -0
  25. package/dist/commands/agent.d.ts +4 -0
  26. package/dist/commands/agent.js +16 -731
  27. package/dist/commands/agent.js.map +1 -1
  28. package/dist/commands/compute/apiUtils.d.ts +11 -0
  29. package/dist/commands/compute/apiUtils.js +22 -0
  30. package/dist/commands/compute/apiUtils.js.map +1 -0
  31. package/dist/commands/compute/create.d.ts +2 -0
  32. package/dist/commands/compute/create.js +183 -0
  33. package/dist/commands/compute/create.js.map +1 -0
  34. package/dist/commands/compute/delete.d.ts +2 -0
  35. package/dist/commands/compute/delete.js +145 -0
  36. package/dist/commands/compute/delete.js.map +1 -0
  37. package/dist/commands/compute/index.d.ts +4 -0
  38. package/dist/commands/compute/index.js +14 -0
  39. package/dist/commands/compute/index.js.map +1 -0
  40. package/dist/commands/compute/list.d.ts +2 -0
  41. package/dist/commands/compute/list.js +128 -0
  42. package/dist/commands/compute/list.js.map +1 -0
  43. package/dist/commands/compute.d.ts +3 -0
  44. package/dist/commands/compute.js +10 -400
  45. package/dist/commands/compute.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/commands/agent/apiUtils.ts +24 -0
  48. package/src/commands/agent/create.ts +105 -0
  49. package/src/commands/agent/createFromYaml.ts +192 -0
  50. package/src/commands/agent/deploy.ts +272 -0
  51. package/src/commands/agent/generate.ts +151 -0
  52. package/src/commands/agent/index.ts +12 -0
  53. package/src/commands/agent/list.ts +104 -0
  54. package/src/commands/agent/remove.ts +103 -0
  55. package/src/commands/agent.ts +15 -909
  56. package/src/commands/compute/apiUtils.ts +28 -0
  57. package/src/commands/compute/create.ts +195 -0
  58. package/src/commands/compute/delete.ts +147 -0
  59. package/src/commands/compute/index.ts +7 -0
  60. package/src/commands/compute/list.ts +125 -0
  61. package/src/commands/compute.ts +16 -449
@@ -0,0 +1,104 @@
1
+ import { Command } from "commander";
2
+ import { withTokenRefresh } from "../../utils/error";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import Table from "cli-table3";
6
+ import { resolveProject } from "../../utils/project";
7
+ import { AgentType } from "../../types/agentType";
8
+ import { createApis } from "./apiUtils";
9
+
10
+ export function registerListCommand(agentCommand: Command): void {
11
+ agentCommand
12
+ .command("list")
13
+ .description("List all AI agents associated with the authenticated user")
14
+ .option(
15
+ "--project <projectName>",
16
+ "Project name (defaults to the current project)"
17
+ )
18
+ .action(async (options) => {
19
+ try {
20
+ let apis = createApis();
21
+
22
+ // Execute with token refresh support
23
+ await withTokenRefresh(
24
+ async () => {
25
+ // Resolve project
26
+ const projectData = await resolveProject(apis.projectsApi, options);
27
+
28
+ const spinner = ora(
29
+ `Listing agents in project ${projectData.name}...`
30
+ ).start();
31
+
32
+ try {
33
+ // Get the agents for the specific project
34
+ const agentsResponse: any =
35
+ await apis.agentsApi.machineAgentControllerGetMachineAgentByProjectId(
36
+ projectData.id,
37
+ 0,
38
+ 10,
39
+ AgentType.REGULAR
40
+ );
41
+
42
+ spinner.succeed("Successfully retrieved agents");
43
+
44
+ // Display the results
45
+ const agents = agentsResponse.data?.machineAgents || [];
46
+
47
+ if (!agents || agents.length === 0) {
48
+ console.log(
49
+ chalk.yellow(`No agents found in project ${projectData.name}`)
50
+ );
51
+ return;
52
+ }
53
+
54
+ console.log(
55
+ chalk.blue(`\nAgents in project ${projectData.name}:\n`)
56
+ );
57
+
58
+ // Create a formatted table
59
+ const table = new Table({
60
+ head: [
61
+ chalk.white.bold("ID"),
62
+ chalk.white.bold("Name"),
63
+ chalk.white.bold("URL"),
64
+ ],
65
+ style: {
66
+ head: [],
67
+ border: [],
68
+ },
69
+ });
70
+
71
+ // Add agents to the table
72
+ agents.forEach((agent: any) => {
73
+ let url = "N/A";
74
+ if (agent.instanceIP) {
75
+ url = `${agent.instanceIP}/v1/agents/${agent.modelBaseId}/query`;
76
+ }
77
+
78
+ table.push([agent.id || "N/A", agent.agentName || "N/A", url]);
79
+ });
80
+
81
+ console.log(table.toString());
82
+ console.log(`\nTotal agents: ${agents.length}`);
83
+
84
+ } catch (error: any) {
85
+ spinner.fail("Failed to retrieve agents");
86
+ throw error;
87
+ }
88
+ },
89
+ () => {
90
+ // Recreate APIs after token refresh
91
+ apis = createApis();
92
+ }
93
+ );
94
+ } catch (error: any) {
95
+ if (error.message && error.message.includes('Authentication')) {
96
+ console.error(chalk.red(error.message));
97
+ } else if (error.response?.data?.message) {
98
+ console.error(chalk.red("API Error:"), error.response.data.message);
99
+ } else {
100
+ console.error(chalk.red("Error:"), error.message || "Unknown error");
101
+ }
102
+ }
103
+ });
104
+ }
@@ -0,0 +1,103 @@
1
+ import { Command } from "commander";
2
+ import { withTokenRefresh } from "../../utils/error";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import { resolveProject } from "../../utils/project";
6
+ import { AgentType } from "../../types/agentType";
7
+ import { createApis } from "./apiUtils";
8
+
9
+ export function registerRemoveCommand(agentCommand: Command): void {
10
+ agentCommand
11
+ .command("remove")
12
+ .description("Remove an AI agent")
13
+ .requiredOption("--agent <agentId>", "Agent ID to remove")
14
+ .option(
15
+ "--project <projectName>",
16
+ "Project name (defaults to the current project)"
17
+ )
18
+ .action(async (options) => {
19
+ try {
20
+ let apis = createApis();
21
+ const { agent } = options;
22
+
23
+ await withTokenRefresh(
24
+ async () => {
25
+ // Resolve project
26
+ const projectData = await resolveProject(apis.projectsApi, options);
27
+
28
+ const spinner = ora(
29
+ `Finding agent ${agent} in project ${projectData.name}...`
30
+ ).start();
31
+
32
+ try {
33
+ // Get the list of agents to find the correct modelbaseId
34
+ const agentsResponse: any =
35
+ await apis.agentsApi.machineAgentControllerGetMachineAgentByProjectId(
36
+ projectData.id,
37
+ 0,
38
+ 100,
39
+ AgentType.REGULAR
40
+ );
41
+
42
+ const agents = agentsResponse.data?.machineAgents || [];
43
+ const targetAgent = agents.find(
44
+ (a: any) => a.id.toString() === agent.toString()
45
+ );
46
+
47
+ if (!targetAgent) {
48
+ spinner.fail(
49
+ `Agent with ID ${agent} not found in project ${projectData.name}`
50
+ );
51
+ return;
52
+ }
53
+
54
+ const modelbaseId = targetAgent.modelBaseId;
55
+ if (!modelbaseId) {
56
+ spinner.fail(
57
+ `Could not find modelbaseId for agent ${agent}. Please try again.`
58
+ );
59
+ return;
60
+ }
61
+
62
+ spinner.text = `Removing agent ${agent} from project ${projectData.name}...`;
63
+
64
+ // Remove the agent
65
+ const payload: any = [
66
+ {
67
+ id: parseInt(agent, 10),
68
+ modelbaseId: modelbaseId,
69
+ },
70
+ ];
71
+
72
+ await apis.agentsApi.machineAgentControllerDeleteMachineAgents(
73
+ projectData.id,
74
+ agent,
75
+ payload
76
+ );
77
+
78
+ spinner.succeed("Successfully removed agent");
79
+ console.log(
80
+ chalk.green(
81
+ `Agent ${agent} removed successfully from project ${projectData.name}`
82
+ )
83
+ );
84
+ } catch (error: any) {
85
+ spinner.fail("Failed to remove agent");
86
+ throw error;
87
+ }
88
+ },
89
+ () => {
90
+ apis = createApis();
91
+ }
92
+ );
93
+ } catch (error: any) {
94
+ if (error.message && error.message.includes('Authentication')) {
95
+ console.error(chalk.red(error.message));
96
+ } else if (error.response?.data?.message) {
97
+ console.error(chalk.red("API Error:"), error.response.data.message);
98
+ } else {
99
+ console.error(chalk.red("Error:"), error.message || "Unknown error");
100
+ }
101
+ }
102
+ });
103
+ }