@agents-at-scale/ark 0.1.34 → 0.1.35-rc.1
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/dist/arkServices.d.ts +50 -0
- package/dist/arkServices.js +153 -0
- package/dist/charts/charts.d.ts +5 -0
- package/dist/charts/charts.js +6 -0
- package/dist/charts/dependencies.d.ts +6 -0
- package/dist/charts/dependencies.js +50 -0
- package/dist/charts/types.d.ts +40 -0
- package/dist/charts/types.js +1 -0
- package/dist/commands/agents/index.d.ts +2 -0
- package/dist/commands/agents/index.js +56 -0
- package/dist/commands/agents/selector.d.ts +8 -0
- package/dist/commands/agents/selector.js +53 -0
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.js +53 -0
- package/dist/commands/chat/index.d.ts +2 -0
- package/dist/commands/chat/index.js +45 -0
- package/dist/commands/chat.d.ts +2 -0
- package/dist/commands/chat.js +45 -0
- package/dist/commands/cluster/get.d.ts +2 -0
- package/dist/commands/cluster/get.js +39 -0
- package/dist/commands/cluster/index.js +2 -4
- package/dist/commands/completion/index.d.ts +2 -0
- package/dist/commands/completion/index.js +268 -0
- package/dist/commands/completion.js +159 -2
- package/dist/commands/config/index.d.ts +2 -0
- package/dist/commands/config/index.js +42 -0
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.js +38 -321
- package/dist/commands/dashboard/index.d.ts +3 -0
- package/dist/commands/dashboard/index.js +39 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.js +39 -0
- package/dist/commands/dev/index.d.ts +2 -0
- package/dist/commands/dev/index.js +9 -0
- package/dist/commands/dev/tool/check.d.ts +2 -0
- package/dist/commands/dev/tool/check.js +142 -0
- package/dist/commands/dev/tool/clean.d.ts +2 -0
- package/dist/commands/dev/tool/clean.js +153 -0
- package/dist/commands/dev/tool/generate.d.ts +2 -0
- package/dist/commands/dev/tool/generate.js +28 -0
- package/dist/commands/dev/tool/index.d.ts +2 -0
- package/dist/commands/dev/tool/index.js +14 -0
- package/dist/commands/dev/tool/init.d.ts +2 -0
- package/dist/commands/dev/tool/init.js +320 -0
- package/dist/commands/dev/tool/shared.d.ts +5 -0
- package/dist/commands/dev/tool/shared.js +256 -0
- package/dist/commands/dev/tool/status.d.ts +2 -0
- package/dist/commands/dev/tool/status.js +136 -0
- package/dist/commands/dev/tool.d.ts +2 -0
- package/dist/commands/dev/tool.js +559 -0
- package/dist/commands/generate/config.js +5 -24
- package/dist/commands/generate/generators/mcpserver.d.ts +2 -1
- package/dist/commands/generate/generators/mcpserver.js +26 -5
- package/dist/commands/install/index.d.ts +6 -0
- package/dist/commands/install/index.js +165 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.js +147 -0
- package/dist/commands/models/create.d.ts +1 -0
- package/dist/commands/models/create.js +213 -0
- package/dist/commands/models/index.d.ts +2 -0
- package/dist/commands/models/index.js +65 -0
- package/dist/commands/models/selector.d.ts +8 -0
- package/dist/commands/models/selector.js +53 -0
- package/dist/commands/routes/index.d.ts +2 -0
- package/dist/commands/routes/index.js +101 -0
- package/dist/commands/routes.d.ts +2 -0
- package/dist/commands/routes.js +101 -0
- package/dist/commands/status/index.d.ts +3 -0
- package/dist/commands/status/index.js +33 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +33 -0
- package/dist/commands/targets/index.d.ts +2 -0
- package/dist/commands/targets/index.js +65 -0
- package/dist/commands/targets.d.ts +2 -0
- package/dist/commands/targets.js +65 -0
- package/dist/commands/teams/index.d.ts +2 -0
- package/dist/commands/teams/index.js +54 -0
- package/dist/commands/teams/selector.d.ts +8 -0
- package/dist/commands/teams/selector.js +55 -0
- package/dist/commands/tools/index.d.ts +2 -0
- package/dist/commands/tools/index.js +54 -0
- package/dist/commands/tools/selector.d.ts +8 -0
- package/dist/commands/tools/selector.js +53 -0
- package/dist/commands/uninstall/index.d.ts +2 -0
- package/dist/commands/uninstall/index.js +84 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.js +83 -0
- package/dist/components/ChatUI.d.ts +16 -0
- package/dist/components/ChatUI.js +801 -0
- package/dist/components/StatusView.d.ts +10 -0
- package/dist/components/StatusView.js +39 -0
- package/dist/components/statusChecker.d.ts +10 -13
- package/dist/components/statusChecker.js +128 -65
- package/dist/config.js +3 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -36
- package/dist/lib/arkApiClient.d.ts +53 -0
- package/dist/lib/arkApiClient.js +102 -0
- package/dist/lib/arkApiProxy.d.ts +9 -0
- package/dist/lib/arkApiProxy.js +22 -0
- package/dist/lib/arkServiceProxy.d.ts +14 -0
- package/dist/lib/arkServiceProxy.js +93 -0
- package/dist/lib/arkStatus.d.ts +5 -0
- package/dist/lib/arkStatus.js +20 -0
- package/dist/lib/chatClient.d.ts +33 -0
- package/dist/lib/chatClient.js +101 -0
- package/dist/lib/cluster.d.ts +2 -1
- package/dist/lib/cluster.js +27 -3
- package/dist/lib/commandUtils.d.ts +4 -0
- package/dist/lib/commandUtils.js +18 -0
- package/dist/lib/commandUtils.test.d.ts +1 -0
- package/dist/lib/commandUtils.test.js +44 -0
- package/dist/lib/config.d.ts +24 -80
- package/dist/lib/config.js +68 -205
- package/dist/lib/config.test.d.ts +1 -0
- package/dist/lib/config.test.js +93 -0
- package/dist/lib/dev/tools/analyzer.d.ts +30 -0
- package/dist/lib/dev/tools/analyzer.js +190 -0
- package/dist/lib/dev/tools/discover_tools.py +392 -0
- package/dist/lib/dev/tools/mcp-types.d.ts +28 -0
- package/dist/lib/dev/tools/mcp-types.js +86 -0
- package/dist/lib/dev/tools/types.d.ts +50 -0
- package/dist/lib/dev/tools/types.js +1 -0
- package/dist/lib/output.d.ts +36 -0
- package/dist/lib/output.js +89 -0
- package/dist/lib/types.d.ts +8 -3
- package/dist/types/types.d.ts +40 -0
- package/dist/types/types.js +1 -0
- package/dist/ui/MainMenu.js +158 -90
- package/dist/ui/statusFormatter.d.ts +4 -1
- package/dist/ui/statusFormatter.js +91 -19
- package/package.json +16 -4
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import output from '../../lib/output.js';
|
|
5
|
+
import { isCommandAvailable } from '../../lib/commandUtils.js';
|
|
6
|
+
async function listRoutes() {
|
|
7
|
+
// Check if kubectl is installed
|
|
8
|
+
const kubectlInstalled = await isCommandAvailable('kubectl');
|
|
9
|
+
if (!kubectlInstalled) {
|
|
10
|
+
output.error('kubectl is not installed. please install kubectl first:');
|
|
11
|
+
output.info('https://kubernetes.io/docs/tasks/tools/');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const namespace = 'ark-system';
|
|
15
|
+
const port = 8080;
|
|
16
|
+
const portSuffix = `:${port}`;
|
|
17
|
+
try {
|
|
18
|
+
// Check if localhost-gateway is installed
|
|
19
|
+
const { stdout: gatewayCheck } = await execa('kubectl', ['get', 'gateway', 'localhost-gateway', '-n', namespace], { reject: false });
|
|
20
|
+
if (!gatewayCheck) {
|
|
21
|
+
output.error("localhost-gateway not installed in namespace 'ark-system'");
|
|
22
|
+
output.info("run 'ark install' first");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
// Get HTTPRoutes
|
|
26
|
+
const { stdout: routeOutput } = await execa('kubectl', [
|
|
27
|
+
'get',
|
|
28
|
+
'httproutes',
|
|
29
|
+
'-A',
|
|
30
|
+
'-o',
|
|
31
|
+
'custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,HOSTNAMES:.spec.hostnames',
|
|
32
|
+
'--no-headers',
|
|
33
|
+
], { reject: false });
|
|
34
|
+
if (!routeOutput || routeOutput.trim() === '') {
|
|
35
|
+
console.log(chalk.white('available localhost gateway routes: 0'));
|
|
36
|
+
output.info('no httproutes found. install services to see routes here.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Parse routes
|
|
40
|
+
const lines = routeOutput.trim().split('\n');
|
|
41
|
+
const routes = [];
|
|
42
|
+
lines.forEach((line) => {
|
|
43
|
+
const parts = line.split(/\s+/);
|
|
44
|
+
if (parts.length >= 3) {
|
|
45
|
+
const name = parts[1];
|
|
46
|
+
// Remove brackets and split hostnames
|
|
47
|
+
const hostnamesStr = parts.slice(2).join(' ').replace(/\[|\]/g, '');
|
|
48
|
+
const hostnames = hostnamesStr
|
|
49
|
+
.split(',')
|
|
50
|
+
.map((h) => h.trim())
|
|
51
|
+
.filter((h) => h && h !== '<none>');
|
|
52
|
+
if (hostnames.length > 0) {
|
|
53
|
+
routes.push({ name, hostnames });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// Count total routes (each hostname counts as a route)
|
|
58
|
+
const routeCount = routes.reduce((count, r) => count + r.hostnames.length, 0);
|
|
59
|
+
console.log(chalk.white(`available localhost gateway routes: ${routeCount}`));
|
|
60
|
+
// Check port-forward status
|
|
61
|
+
const { stdout: psOutput } = await execa('pgrep', ['-f', `kubectl.*port-forward.*${port}:80`], { reject: false });
|
|
62
|
+
const portForwardActive = !!psOutput;
|
|
63
|
+
if (portForwardActive) {
|
|
64
|
+
output.info(`port-forward active on localhost${portSuffix}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
output.error(`port-forward not running on localhost${portSuffix} - routes are not exposed`);
|
|
68
|
+
console.log(chalk.blue('run:'), `kubectl port-forward -n ${namespace} service/localhost-gateway-nginx ${port}:80 > /dev/null 2>&1 &`);
|
|
69
|
+
}
|
|
70
|
+
console.log();
|
|
71
|
+
// Display routes
|
|
72
|
+
if (routes.length > 0) {
|
|
73
|
+
const maxLength = Math.max(...routes.map((r) => r.name.length));
|
|
74
|
+
routes.forEach((route) => {
|
|
75
|
+
route.hostnames.forEach((hostname) => {
|
|
76
|
+
const url = `http://${hostname}${portSuffix}/`;
|
|
77
|
+
const padding = ' '.repeat(maxLength - route.name.length);
|
|
78
|
+
if (portForwardActive) {
|
|
79
|
+
console.log(` ${route.name}${padding}: ${chalk.blue(url)}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log(` ${route.name}${padding}: ${chalk.blue(url)} ${chalk.red('(unavailable)')}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
output.error('failed to fetch routes:', error instanceof Error ? error.message : 'Unknown error');
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function createRoutesCommand() {
|
|
94
|
+
const command = new Command('routes');
|
|
95
|
+
command
|
|
96
|
+
.description('show available gateway routes and their urls')
|
|
97
|
+
.action(async () => {
|
|
98
|
+
await listRoutes();
|
|
99
|
+
});
|
|
100
|
+
return command;
|
|
101
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import output from '../lib/output.js';
|
|
5
|
+
import { isCommandAvailable } from '../lib/commandUtils.js';
|
|
6
|
+
async function listRoutes() {
|
|
7
|
+
// Check if kubectl is installed
|
|
8
|
+
const kubectlInstalled = await isCommandAvailable('kubectl');
|
|
9
|
+
if (!kubectlInstalled) {
|
|
10
|
+
output.error('kubectl is not installed. please install kubectl first:');
|
|
11
|
+
output.info('https://kubernetes.io/docs/tasks/tools/');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const namespace = 'ark-system';
|
|
15
|
+
const port = 8080;
|
|
16
|
+
const portSuffix = `:${port}`;
|
|
17
|
+
try {
|
|
18
|
+
// Check if localhost-gateway is installed
|
|
19
|
+
const { stdout: gatewayCheck } = await execa('kubectl', ['get', 'gateway', 'localhost-gateway', '-n', namespace], { reject: false });
|
|
20
|
+
if (!gatewayCheck) {
|
|
21
|
+
output.error("localhost-gateway not installed in namespace 'ark-system'");
|
|
22
|
+
output.info("run 'ark install' first");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
// Get HTTPRoutes
|
|
26
|
+
const { stdout: routeOutput } = await execa('kubectl', [
|
|
27
|
+
'get',
|
|
28
|
+
'httproutes',
|
|
29
|
+
'-A',
|
|
30
|
+
'-o',
|
|
31
|
+
'custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,HOSTNAMES:.spec.hostnames',
|
|
32
|
+
'--no-headers',
|
|
33
|
+
], { reject: false });
|
|
34
|
+
if (!routeOutput || routeOutput.trim() === '') {
|
|
35
|
+
console.log(chalk.white('available localhost gateway routes: 0'));
|
|
36
|
+
output.info('no httproutes found. install services to see routes here.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Parse routes
|
|
40
|
+
const lines = routeOutput.trim().split('\n');
|
|
41
|
+
const routes = [];
|
|
42
|
+
lines.forEach((line) => {
|
|
43
|
+
const parts = line.split(/\s+/);
|
|
44
|
+
if (parts.length >= 3) {
|
|
45
|
+
const name = parts[1];
|
|
46
|
+
// Remove brackets and split hostnames
|
|
47
|
+
const hostnamesStr = parts.slice(2).join(' ').replace(/\[|\]/g, '');
|
|
48
|
+
const hostnames = hostnamesStr
|
|
49
|
+
.split(',')
|
|
50
|
+
.map((h) => h.trim())
|
|
51
|
+
.filter((h) => h && h !== '<none>');
|
|
52
|
+
if (hostnames.length > 0) {
|
|
53
|
+
routes.push({ name, hostnames });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// Count total routes (each hostname counts as a route)
|
|
58
|
+
const routeCount = routes.reduce((count, r) => count + r.hostnames.length, 0);
|
|
59
|
+
console.log(chalk.white(`available localhost gateway routes: ${routeCount}`));
|
|
60
|
+
// Check port-forward status
|
|
61
|
+
const { stdout: psOutput } = await execa('pgrep', ['-f', `kubectl.*port-forward.*${port}:80`], { reject: false });
|
|
62
|
+
const portForwardActive = !!psOutput;
|
|
63
|
+
if (portForwardActive) {
|
|
64
|
+
output.info(`port-forward active on localhost${portSuffix}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
output.error(`port-forward not running on localhost${portSuffix} - routes are not exposed`);
|
|
68
|
+
console.log(chalk.blue('run:'), `kubectl port-forward -n ${namespace} service/localhost-gateway-nginx ${port}:80 > /dev/null 2>&1 &`);
|
|
69
|
+
}
|
|
70
|
+
console.log();
|
|
71
|
+
// Display routes
|
|
72
|
+
if (routes.length > 0) {
|
|
73
|
+
const maxLength = Math.max(...routes.map((r) => r.name.length));
|
|
74
|
+
routes.forEach((route) => {
|
|
75
|
+
route.hostnames.forEach((hostname) => {
|
|
76
|
+
const url = `http://${hostname}${portSuffix}/`;
|
|
77
|
+
const padding = ' '.repeat(maxLength - route.name.length);
|
|
78
|
+
if (portForwardActive) {
|
|
79
|
+
console.log(` ${route.name}${padding}: ${chalk.blue(url)}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log(` ${route.name}${padding}: ${chalk.blue(url)} ${chalk.red('(unavailable)')}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
output.error('failed to fetch routes:', error instanceof Error ? error.message : 'Unknown error');
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function createRoutesCommand() {
|
|
94
|
+
const command = new Command('routes');
|
|
95
|
+
command
|
|
96
|
+
.description('show available gateway routes and their urls')
|
|
97
|
+
.action(async () => {
|
|
98
|
+
await listRoutes();
|
|
99
|
+
});
|
|
100
|
+
return command;
|
|
101
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { StatusChecker } from '../../components/statusChecker.js';
|
|
5
|
+
import { ConfigManager } from '../../config.js';
|
|
6
|
+
import { ArkClient } from '../../lib/arkClient.js';
|
|
7
|
+
import { StatusFormatter } from '../../ui/statusFormatter.js';
|
|
8
|
+
export async function checkStatus() {
|
|
9
|
+
const spinner = ora('Checking system status').start();
|
|
10
|
+
try {
|
|
11
|
+
const configManager = new ConfigManager();
|
|
12
|
+
spinner.text = 'Checking system dependencies';
|
|
13
|
+
const apiBaseUrl = await configManager.getApiBaseUrl();
|
|
14
|
+
const arkClient = new ArkClient(apiBaseUrl);
|
|
15
|
+
const statusChecker = new StatusChecker(arkClient);
|
|
16
|
+
spinner.text = 'Testing cluster access';
|
|
17
|
+
spinner.text = 'Checking ARK services';
|
|
18
|
+
const statusData = await statusChecker.checkAll();
|
|
19
|
+
spinner.stop();
|
|
20
|
+
StatusFormatter.printStatus(statusData);
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
spinner.fail('Failed to check status');
|
|
25
|
+
console.error(chalk.red('Error:'), error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function createStatusCommand() {
|
|
30
|
+
const statusCommand = new Command('status');
|
|
31
|
+
statusCommand.description('Check ARK system status').action(checkStatus);
|
|
32
|
+
return statusCommand;
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { StatusChecker } from '../components/statusChecker.js';
|
|
5
|
+
import { ConfigManager } from '../config.js';
|
|
6
|
+
import { ArkClient } from '../lib/arkClient.js';
|
|
7
|
+
import { StatusFormatter } from '../ui/statusFormatter.js';
|
|
8
|
+
export async function checkStatus() {
|
|
9
|
+
const spinner = ora('Checking system status').start();
|
|
10
|
+
try {
|
|
11
|
+
const configManager = new ConfigManager();
|
|
12
|
+
spinner.text = 'Checking system dependencies';
|
|
13
|
+
const apiBaseUrl = await configManager.getApiBaseUrl();
|
|
14
|
+
const arkClient = new ArkClient(apiBaseUrl);
|
|
15
|
+
const statusChecker = new StatusChecker(arkClient);
|
|
16
|
+
spinner.text = 'Testing cluster access';
|
|
17
|
+
spinner.text = 'Checking ARK services';
|
|
18
|
+
const statusData = await statusChecker.checkAll();
|
|
19
|
+
spinner.stop();
|
|
20
|
+
StatusFormatter.printStatus(statusData);
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
spinner.fail('Failed to check status');
|
|
25
|
+
console.error(chalk.red('Error:'), error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function createStatusCommand() {
|
|
30
|
+
const statusCommand = new Command('status');
|
|
31
|
+
statusCommand.description('Check ARK system status').action(checkStatus);
|
|
32
|
+
return statusCommand;
|
|
33
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import output from '../../lib/output.js';
|
|
3
|
+
import { ArkApiProxy } from '../../lib/arkApiProxy.js';
|
|
4
|
+
async function listTargets(options) {
|
|
5
|
+
let proxy;
|
|
6
|
+
try {
|
|
7
|
+
proxy = new ArkApiProxy();
|
|
8
|
+
const arkApiClient = await proxy.start();
|
|
9
|
+
const allTargets = await arkApiClient.getQueryTargets();
|
|
10
|
+
// Filter by type if specified
|
|
11
|
+
let filteredTargets = allTargets;
|
|
12
|
+
if (options.type) {
|
|
13
|
+
filteredTargets = allTargets.filter((t) => t.type === options.type);
|
|
14
|
+
}
|
|
15
|
+
// Sort targets by type and name
|
|
16
|
+
filteredTargets.sort((a, b) => {
|
|
17
|
+
if (a.type !== b.type) {
|
|
18
|
+
return a.type.localeCompare(b.type);
|
|
19
|
+
}
|
|
20
|
+
return a.name.localeCompare(b.name);
|
|
21
|
+
});
|
|
22
|
+
if (options.output === 'json') {
|
|
23
|
+
console.log(JSON.stringify(filteredTargets, null, 2));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (filteredTargets.length === 0) {
|
|
27
|
+
output.warning('no targets available');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Simple list output with type/name format
|
|
31
|
+
for (const target of filteredTargets) {
|
|
32
|
+
console.log(target.id);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
output.error('fetching targets:', error instanceof Error ? error.message : error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
if (proxy) {
|
|
42
|
+
proxy.stop();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function createTargetsCommand() {
|
|
47
|
+
const targets = new Command('targets');
|
|
48
|
+
targets
|
|
49
|
+
.description('list available query targets (agents, teams, models, tools)')
|
|
50
|
+
.option('-o, --output <format>', 'output format (json or text)', 'text')
|
|
51
|
+
.option('-t, --type <type>', 'filter by type (agent, team, model, tool)')
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
await listTargets(options);
|
|
54
|
+
});
|
|
55
|
+
targets
|
|
56
|
+
.command('list')
|
|
57
|
+
.alias('ls')
|
|
58
|
+
.description('list all available query targets')
|
|
59
|
+
.option('-o, --output <format>', 'output format (json or text)', 'text')
|
|
60
|
+
.option('-t, --type <type>', 'filter by type (agent, team, model, tool)')
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
await listTargets(options);
|
|
63
|
+
});
|
|
64
|
+
return targets;
|
|
65
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import output from '../lib/output.js';
|
|
3
|
+
import { ArkApiProxy } from '../lib/arkApiProxy.js';
|
|
4
|
+
async function listTargets(options) {
|
|
5
|
+
let proxy;
|
|
6
|
+
try {
|
|
7
|
+
proxy = new ArkApiProxy();
|
|
8
|
+
const arkApiClient = await proxy.start();
|
|
9
|
+
const allTargets = await arkApiClient.getQueryTargets();
|
|
10
|
+
// Filter by type if specified
|
|
11
|
+
let filteredTargets = allTargets;
|
|
12
|
+
if (options.type) {
|
|
13
|
+
filteredTargets = allTargets.filter((t) => t.type === options.type);
|
|
14
|
+
}
|
|
15
|
+
// Sort targets by type and name
|
|
16
|
+
filteredTargets.sort((a, b) => {
|
|
17
|
+
if (a.type !== b.type) {
|
|
18
|
+
return a.type.localeCompare(b.type);
|
|
19
|
+
}
|
|
20
|
+
return a.name.localeCompare(b.name);
|
|
21
|
+
});
|
|
22
|
+
if (options.output === 'json') {
|
|
23
|
+
console.log(JSON.stringify(filteredTargets, null, 2));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (filteredTargets.length === 0) {
|
|
27
|
+
output.warning('no targets available');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Simple list output with type/name format
|
|
31
|
+
for (const target of filteredTargets) {
|
|
32
|
+
console.log(target.id);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
output.error('fetching targets:', error instanceof Error ? error.message : error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
if (proxy) {
|
|
42
|
+
proxy.stop();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function createTargetsCommand() {
|
|
47
|
+
const targets = new Command('targets');
|
|
48
|
+
targets
|
|
49
|
+
.description('list available query targets (agents, teams, models, tools)')
|
|
50
|
+
.option('-o, --output <format>', 'output format (json or text)', 'text')
|
|
51
|
+
.option('-t, --type <type>', 'filter by type (agent, team, model, tool)')
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
await listTargets(options);
|
|
54
|
+
});
|
|
55
|
+
targets
|
|
56
|
+
.command('list')
|
|
57
|
+
.alias('ls')
|
|
58
|
+
.description('list all available query targets')
|
|
59
|
+
.option('-o, --output <format>', 'output format (json or text)', 'text')
|
|
60
|
+
.option('-t, --type <type>', 'filter by type (agent, team, model, tool)')
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
await listTargets(options);
|
|
63
|
+
});
|
|
64
|
+
return targets;
|
|
65
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import output from '../../lib/output.js';
|
|
4
|
+
async function listTeams(options) {
|
|
5
|
+
try {
|
|
6
|
+
// Use kubectl to get teams
|
|
7
|
+
const result = await execa('kubectl', ['get', 'teams', '-o', 'json'], {
|
|
8
|
+
stdio: 'pipe',
|
|
9
|
+
});
|
|
10
|
+
const data = JSON.parse(result.stdout);
|
|
11
|
+
const teams = data.items || [];
|
|
12
|
+
if (options.output === 'json') {
|
|
13
|
+
// Output the raw items for JSON format
|
|
14
|
+
console.log(JSON.stringify(teams, null, 2));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
if (teams.length === 0) {
|
|
18
|
+
output.info('No teams found');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
teams.forEach((team) => {
|
|
22
|
+
console.log(team.metadata.name);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof Error && error.message.includes('the server doesn\'t have a resource type')) {
|
|
28
|
+
output.error('Team CRDs not installed. Is the ARK controller running?');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
output.error(`Failed to list teams: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
32
|
+
}
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function createTeamsCommand() {
|
|
37
|
+
const teamsCommand = new Command('teams');
|
|
38
|
+
teamsCommand
|
|
39
|
+
.description('List available teams')
|
|
40
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
41
|
+
.action(async (options) => {
|
|
42
|
+
await listTeams(options);
|
|
43
|
+
});
|
|
44
|
+
const listCommand = new Command('list');
|
|
45
|
+
listCommand
|
|
46
|
+
.alias('ls')
|
|
47
|
+
.description('List available teams')
|
|
48
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
49
|
+
.action(async (options) => {
|
|
50
|
+
await listTeams(options);
|
|
51
|
+
});
|
|
52
|
+
teamsCommand.addCommand(listCommand);
|
|
53
|
+
return teamsCommand;
|
|
54
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Team, ArkApiClient } from '../../lib/arkApiClient.js';
|
|
2
|
+
interface TeamSelectorProps {
|
|
3
|
+
arkApiClient: ArkApiClient;
|
|
4
|
+
onSelect: (team: Team) => void;
|
|
5
|
+
onExit: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function TeamSelector({ arkApiClient, onSelect, onExit, }: TeamSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
4
|
+
export function TeamSelector({ arkApiClient, onSelect, onExit, }) {
|
|
5
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
6
|
+
const [teams, setTeams] = useState([]);
|
|
7
|
+
const [loading, setLoading] = useState(true);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
arkApiClient
|
|
11
|
+
.getTeams()
|
|
12
|
+
.then((fetchedTeams) => {
|
|
13
|
+
setTeams(fetchedTeams);
|
|
14
|
+
setLoading(false);
|
|
15
|
+
})
|
|
16
|
+
.catch((err) => {
|
|
17
|
+
setError(err.message || 'Failed to fetch teams');
|
|
18
|
+
setLoading(false);
|
|
19
|
+
});
|
|
20
|
+
}, [arkApiClient]);
|
|
21
|
+
useInput((input, key) => {
|
|
22
|
+
if (key.escape) {
|
|
23
|
+
onExit();
|
|
24
|
+
}
|
|
25
|
+
else if (key.upArrow || input === 'k') {
|
|
26
|
+
setSelectedIndex((prev) => (prev === 0 ? teams.length - 1 : prev - 1));
|
|
27
|
+
}
|
|
28
|
+
else if (key.downArrow || input === 'j') {
|
|
29
|
+
setSelectedIndex((prev) => (prev === teams.length - 1 ? 0 : prev + 1));
|
|
30
|
+
}
|
|
31
|
+
else if (key.return) {
|
|
32
|
+
onSelect(teams[selectedIndex]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Handle number keys for quick selection
|
|
36
|
+
const num = parseInt(input, 10);
|
|
37
|
+
if (!isNaN(num) && num >= 1 && num <= teams.length) {
|
|
38
|
+
onSelect(teams[num - 1]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (loading) {
|
|
43
|
+
return (_jsx(Box, { children: _jsx(Text, { children: "Loading teams..." }) }));
|
|
44
|
+
}
|
|
45
|
+
if (error) {
|
|
46
|
+
return (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) }));
|
|
47
|
+
}
|
|
48
|
+
if (teams.length === 0) {
|
|
49
|
+
return (_jsx(Box, { children: _jsx(Text, { children: "No teams available" }) }));
|
|
50
|
+
}
|
|
51
|
+
const selectedTeam = teams[selectedIndex];
|
|
52
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Select Team" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { dimColor: true, children: "Choose a team to start a conversation with" }) }), _jsx(Box, { flexDirection: "column", children: teams.map((team, index) => (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: index === selectedIndex ? 'green' : undefined, children: [index === selectedIndex ? '❯ ' : ' ', index + 1, ". ", team.name, team.strategy ? ` (${team.strategy})` : ''] }) }, team.name))) }), selectedTeam &&
|
|
53
|
+
(selectedTeam.description || selectedTeam.members_count) && (_jsx(Box, { marginTop: 1, paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "wrap", children: selectedTeam.description ||
|
|
54
|
+
`Members: ${selectedTeam.members_count}` }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Enter to confirm \u00B7 Number to select \u00B7 Esc to exit" }) })] }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import output from '../../lib/output.js';
|
|
4
|
+
async function listTools(options) {
|
|
5
|
+
try {
|
|
6
|
+
// Use kubectl to get tools (MCPServers)
|
|
7
|
+
const result = await execa('kubectl', ['get', 'mcpservers', '-o', 'json'], {
|
|
8
|
+
stdio: 'pipe',
|
|
9
|
+
});
|
|
10
|
+
const data = JSON.parse(result.stdout);
|
|
11
|
+
const tools = data.items || [];
|
|
12
|
+
if (options.output === 'json') {
|
|
13
|
+
// Output the raw items for JSON format
|
|
14
|
+
console.log(JSON.stringify(tools, null, 2));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
if (tools.length === 0) {
|
|
18
|
+
output.info('No tools found');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
tools.forEach((tool) => {
|
|
22
|
+
console.log(tool.metadata.name);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof Error && error.message.includes('the server doesn\'t have a resource type')) {
|
|
28
|
+
output.error('MCPServer CRDs not installed. Is the ARK controller running?');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
output.error(`Failed to list tools: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
32
|
+
}
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function createToolsCommand() {
|
|
37
|
+
const toolsCommand = new Command('tools');
|
|
38
|
+
toolsCommand
|
|
39
|
+
.description('List available tools')
|
|
40
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
41
|
+
.action(async (options) => {
|
|
42
|
+
await listTools(options);
|
|
43
|
+
});
|
|
44
|
+
const listCommand = new Command('list');
|
|
45
|
+
listCommand
|
|
46
|
+
.alias('ls')
|
|
47
|
+
.description('List available tools')
|
|
48
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
49
|
+
.action(async (options) => {
|
|
50
|
+
await listTools(options);
|
|
51
|
+
});
|
|
52
|
+
toolsCommand.addCommand(listCommand);
|
|
53
|
+
return toolsCommand;
|
|
54
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tool, ArkApiClient } from '../../lib/arkApiClient.js';
|
|
2
|
+
interface ToolSelectorProps {
|
|
3
|
+
arkApiClient: ArkApiClient;
|
|
4
|
+
onSelect: (tool: Tool) => void;
|
|
5
|
+
onExit: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ToolSelector({ arkApiClient, onSelect, onExit, }: ToolSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|