@agents-at-scale/ark 0.1.35 → 0.1.36-rc1
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 +42 -0
- package/dist/arkServices.js +138 -0
- package/dist/arkServices.spec.d.ts +1 -0
- package/dist/arkServices.spec.js +24 -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 +3 -0
- package/dist/commands/agents/index.js +65 -0
- package/dist/commands/agents/index.spec.d.ts +1 -0
- package/dist/commands/agents/index.spec.js +67 -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 +3 -0
- package/dist/commands/chat/index.js +29 -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/get.spec.d.ts +1 -0
- package/dist/commands/cluster/get.spec.js +92 -0
- package/dist/commands/cluster/index.d.ts +2 -1
- package/dist/commands/cluster/index.js +3 -5
- package/dist/commands/cluster/index.spec.d.ts +1 -0
- package/dist/commands/cluster/index.spec.js +24 -0
- package/dist/commands/completion/index.d.ts +3 -0
- package/dist/commands/completion/index.js +230 -0
- package/dist/commands/completion/index.spec.d.ts +1 -0
- package/dist/commands/completion/index.spec.js +34 -0
- package/dist/commands/completion.js +159 -2
- package/dist/commands/config/index.d.ts +3 -0
- package/dist/commands/config/index.js +42 -0
- package/dist/commands/config/index.spec.d.ts +1 -0
- package/dist/commands/config/index.spec.js +78 -0
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.js +38 -321
- package/dist/commands/dashboard/index.d.ts +4 -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 +3 -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 +258 -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-generate.spec.d.ts +1 -0
- package/dist/commands/dev/tool-generate.spec.js +163 -0
- package/dist/commands/dev/tool.d.ts +2 -0
- package/dist/commands/dev/tool.js +559 -0
- package/dist/commands/dev/tool.spec.d.ts +1 -0
- package/dist/commands/dev/tool.spec.js +48 -0
- package/dist/commands/docs/index.d.ts +4 -0
- package/dist/commands/docs/index.js +18 -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/generate/generators/project.js +22 -41
- package/dist/commands/generate/index.d.ts +2 -1
- package/dist/commands/generate/index.js +1 -1
- package/dist/commands/install/index.d.ts +8 -0
- package/dist/commands/install/index.js +295 -0
- package/dist/commands/install/index.spec.d.ts +1 -0
- package/dist/commands/install/index.spec.js +143 -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/create.spec.d.ts +1 -0
- package/dist/commands/models/create.spec.js +125 -0
- package/dist/commands/models/index.d.ts +3 -0
- package/dist/commands/models/index.js +75 -0
- package/dist/commands/models/index.spec.d.ts +1 -0
- package/dist/commands/models/index.spec.js +96 -0
- package/dist/commands/models/selector.d.ts +8 -0
- package/dist/commands/models/selector.js +53 -0
- package/dist/commands/query/index.d.ts +3 -0
- package/dist/commands/query/index.js +24 -0
- package/dist/commands/query/index.spec.d.ts +1 -0
- package/dist/commands/query/index.spec.js +53 -0
- package/dist/commands/routes/index.d.ts +3 -0
- package/dist/commands/routes/index.js +93 -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 +281 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +33 -0
- package/dist/commands/targets/index.d.ts +3 -0
- package/dist/commands/targets/index.js +72 -0
- package/dist/commands/targets/index.spec.d.ts +1 -0
- package/dist/commands/targets/index.spec.js +154 -0
- package/dist/commands/targets.d.ts +2 -0
- package/dist/commands/targets.js +65 -0
- package/dist/commands/teams/index.d.ts +3 -0
- package/dist/commands/teams/index.js +64 -0
- package/dist/commands/teams/index.spec.d.ts +1 -0
- package/dist/commands/teams/index.spec.js +70 -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 +3 -0
- package/dist/commands/tools/index.js +49 -0
- package/dist/commands/tools/index.spec.d.ts +1 -0
- package/dist/commands/tools/index.spec.js +70 -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 +3 -0
- package/dist/commands/uninstall/index.js +101 -0
- package/dist/commands/uninstall/index.spec.d.ts +1 -0
- package/dist/commands/uninstall/index.spec.js +125 -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 +14 -24
- package/dist/components/statusChecker.js +295 -129
- package/dist/config.d.ts +3 -22
- package/dist/config.js +10 -161
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -42
- 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 +95 -0
- package/dist/lib/arkStatus.d.ts +10 -0
- package/dist/lib/arkStatus.js +79 -0
- package/dist/lib/arkStatus.spec.d.ts +1 -0
- package/dist/lib/arkStatus.spec.js +49 -0
- package/dist/lib/chatClient.d.ts +33 -0
- package/dist/lib/chatClient.js +93 -0
- package/dist/lib/cluster.d.ts +2 -1
- package/dist/lib/cluster.js +37 -16
- package/dist/lib/cluster.spec.d.ts +1 -0
- package/dist/lib/cluster.spec.js +338 -0
- 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/commands.d.ts +16 -0
- package/dist/lib/commands.js +29 -0
- package/dist/lib/commands.spec.d.ts +1 -0
- package/dist/lib/commands.spec.js +146 -0
- package/dist/lib/config.d.ts +26 -80
- package/dist/lib/config.js +70 -205
- package/dist/lib/config.spec.d.ts +1 -0
- package/dist/lib/config.spec.js +99 -0
- package/dist/lib/config.test.d.ts +1 -0
- package/dist/lib/config.test.js +93 -0
- package/dist/lib/consts.d.ts +0 -1
- package/dist/lib/consts.js +0 -2
- package/dist/lib/consts.spec.d.ts +1 -0
- package/dist/lib/consts.spec.js +15 -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/errors.js +1 -1
- package/dist/lib/errors.spec.d.ts +1 -0
- package/dist/lib/errors.spec.js +221 -0
- package/dist/lib/exec.d.ts +0 -4
- package/dist/lib/exec.js +0 -11
- package/dist/lib/executeQuery.d.ts +20 -0
- package/dist/lib/executeQuery.js +135 -0
- package/dist/lib/executeQuery.spec.d.ts +1 -0
- package/dist/lib/executeQuery.spec.js +170 -0
- package/dist/lib/nextSteps.d.ts +4 -0
- package/dist/lib/nextSteps.js +20 -0
- package/dist/lib/nextSteps.spec.d.ts +1 -0
- package/dist/lib/nextSteps.spec.js +59 -0
- package/dist/lib/output.d.ts +36 -0
- package/dist/lib/output.js +89 -0
- package/dist/lib/output.spec.d.ts +1 -0
- package/dist/lib/output.spec.js +123 -0
- package/dist/lib/portUtils.d.ts +8 -0
- package/dist/lib/portUtils.js +39 -0
- package/dist/lib/queryRunner.d.ts +22 -0
- package/dist/lib/queryRunner.js +142 -0
- package/dist/lib/startup.d.ts +9 -0
- package/dist/lib/startup.js +87 -0
- package/dist/lib/startup.spec.d.ts +1 -0
- package/dist/lib/startup.spec.js +152 -0
- package/dist/lib/types.d.ts +87 -3
- package/dist/lib/versions.d.ts +23 -0
- package/dist/lib/versions.js +51 -0
- package/dist/types/types.d.ts +40 -0
- package/dist/types/types.js +1 -0
- package/dist/ui/AgentSelector.d.ts +8 -0
- package/dist/ui/AgentSelector.js +53 -0
- package/dist/ui/MainMenu.d.ts +5 -1
- package/dist/ui/MainMenu.js +226 -91
- package/dist/ui/ModelSelector.d.ts +8 -0
- package/dist/ui/ModelSelector.js +53 -0
- package/dist/ui/TeamSelector.d.ts +8 -0
- package/dist/ui/TeamSelector.js +55 -0
- package/dist/ui/ToolSelector.d.ts +8 -0
- package/dist/ui/ToolSelector.js +53 -0
- package/dist/ui/statusFormatter.d.ts +22 -7
- package/dist/ui/statusFormatter.js +39 -39
- package/dist/ui/statusFormatter.spec.d.ts +1 -0
- package/dist/ui/statusFormatter.spec.js +58 -0
- package/package.json +16 -5
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import { isCommandAvailable } from '../lib/commandUtils.js';
|
|
6
|
+
import { getClusterInfo } from '../lib/cluster.js';
|
|
7
|
+
import output from '../lib/output.js';
|
|
8
|
+
import { getInstallableServices, arkDependencies } from '../arkServices.js';
|
|
9
|
+
import { createModel } from './models/create.js';
|
|
10
|
+
export async function installArk() {
|
|
11
|
+
// Check if helm is installed
|
|
12
|
+
const helmInstalled = await isCommandAvailable('helm');
|
|
13
|
+
if (!helmInstalled) {
|
|
14
|
+
output.error('helm is not installed. please install helm first:');
|
|
15
|
+
output.info('https://helm.sh/docs/intro/install/');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
// Check if kubectl is installed (needed for some dependencies)
|
|
19
|
+
const kubectlInstalled = await isCommandAvailable('kubectl');
|
|
20
|
+
if (!kubectlInstalled) {
|
|
21
|
+
output.error('kubectl is not installed. please install kubectl first:');
|
|
22
|
+
output.info('https://kubernetes.io/docs/tasks/tools/');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
// Check cluster connectivity
|
|
26
|
+
const clusterInfo = await getClusterInfo();
|
|
27
|
+
if (clusterInfo.error) {
|
|
28
|
+
output.error('no kubernetes cluster detected');
|
|
29
|
+
output.info('please ensure you have a running cluster and kubectl is configured.');
|
|
30
|
+
output.info('');
|
|
31
|
+
output.info('for local development, we recommend minikube:');
|
|
32
|
+
output.info('• install: https://minikube.sigs.k8s.io/docs/start');
|
|
33
|
+
output.info('• start cluster: minikube start');
|
|
34
|
+
output.info('');
|
|
35
|
+
output.info('alternatively, you can use kind or docker desktop.');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
// Show cluster info
|
|
39
|
+
output.success(`connected to cluster: ${chalk.bold(clusterInfo.context)}`);
|
|
40
|
+
output.info(`type: ${clusterInfo.type}`);
|
|
41
|
+
output.info(`namespace: ${clusterInfo.namespace}`);
|
|
42
|
+
if (clusterInfo.ip) {
|
|
43
|
+
output.info(`ip: ${clusterInfo.ip}`);
|
|
44
|
+
}
|
|
45
|
+
console.log(); // Add blank line after cluster info
|
|
46
|
+
// Ask about installing dependencies
|
|
47
|
+
const { shouldInstallDeps } = await inquirer.prompt([
|
|
48
|
+
{
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
name: 'shouldInstallDeps',
|
|
51
|
+
message: 'install required dependencies (cert-manager, gateway api)?',
|
|
52
|
+
default: true,
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
if (shouldInstallDeps) {
|
|
56
|
+
for (const dep of Object.values(arkDependencies)) {
|
|
57
|
+
output.info(`installing ${dep.description || dep.name}...`);
|
|
58
|
+
try {
|
|
59
|
+
await execa(dep.command, dep.args, {
|
|
60
|
+
stdio: 'inherit',
|
|
61
|
+
});
|
|
62
|
+
output.success(`${dep.name} completed`);
|
|
63
|
+
console.log(); // Add blank line after dependency
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
console.log(); // Add blank line after error
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Get installable services and iterate through them
|
|
72
|
+
const services = getInstallableServices();
|
|
73
|
+
for (const service of Object.values(services)) {
|
|
74
|
+
// Ask for confirmation
|
|
75
|
+
const { shouldInstall } = await inquirer.prompt([
|
|
76
|
+
{
|
|
77
|
+
type: 'confirm',
|
|
78
|
+
name: 'shouldInstall',
|
|
79
|
+
message: `install ${chalk.bold(service.name)}? ${service.description ? chalk.gray(`(${service.description.toLowerCase()})`) : ''}`,
|
|
80
|
+
default: true,
|
|
81
|
+
},
|
|
82
|
+
]);
|
|
83
|
+
if (!shouldInstall) {
|
|
84
|
+
output.warning(`skipping ${service.name}`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
// Build helm arguments
|
|
89
|
+
const helmArgs = [
|
|
90
|
+
'upgrade',
|
|
91
|
+
'--install',
|
|
92
|
+
service.helmReleaseName,
|
|
93
|
+
service.chartPath,
|
|
94
|
+
'--namespace',
|
|
95
|
+
service.namespace,
|
|
96
|
+
];
|
|
97
|
+
// Add any additional args from the service definition
|
|
98
|
+
if (service.installArgs) {
|
|
99
|
+
helmArgs.push(...service.installArgs);
|
|
100
|
+
}
|
|
101
|
+
// Run helm upgrade --install with streaming output
|
|
102
|
+
await execa('helm', helmArgs, {
|
|
103
|
+
stdio: 'inherit',
|
|
104
|
+
});
|
|
105
|
+
console.log(); // Add blank line after command output
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Continue with remaining services on error
|
|
109
|
+
console.log(); // Add blank line after error output
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Check for default model after installing services
|
|
113
|
+
output.info('checking for default model...');
|
|
114
|
+
let modelExists = false;
|
|
115
|
+
try {
|
|
116
|
+
await execa('kubectl', ['get', 'model', 'default'], { stdio: 'pipe' });
|
|
117
|
+
modelExists = true;
|
|
118
|
+
output.success('default model already configured');
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
output.warning('no default model found');
|
|
122
|
+
}
|
|
123
|
+
if (!modelExists) {
|
|
124
|
+
const { shouldCreateModel } = await inquirer.prompt([
|
|
125
|
+
{
|
|
126
|
+
type: 'confirm',
|
|
127
|
+
name: 'shouldCreateModel',
|
|
128
|
+
message: 'would you like to create a default model?',
|
|
129
|
+
default: true,
|
|
130
|
+
},
|
|
131
|
+
]);
|
|
132
|
+
if (shouldCreateModel) {
|
|
133
|
+
await createModel('default');
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
output.warning('skipping model creation');
|
|
137
|
+
output.info('you can create a model later using ark models create or the dashboard');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function createInstallCommand() {
|
|
142
|
+
const command = new Command('install');
|
|
143
|
+
command.description('Install ARK components using Helm').action(async () => {
|
|
144
|
+
await installArk();
|
|
145
|
+
});
|
|
146
|
+
return command;
|
|
147
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createModel(modelName?: string): Promise<boolean>;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import output from '../../lib/output.js';
|
|
4
|
+
export async function createModel(modelName) {
|
|
5
|
+
// Step 1: Get model name if not provided
|
|
6
|
+
if (!modelName) {
|
|
7
|
+
const nameAnswer = await inquirer.prompt([
|
|
8
|
+
{
|
|
9
|
+
type: 'input',
|
|
10
|
+
name: 'modelName',
|
|
11
|
+
message: 'model name:',
|
|
12
|
+
default: 'default',
|
|
13
|
+
validate: (input) => {
|
|
14
|
+
if (!input)
|
|
15
|
+
return 'model name is required';
|
|
16
|
+
// Kubernetes name validation
|
|
17
|
+
if (!/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/.test(input)) {
|
|
18
|
+
return 'model name must be a valid Kubernetes resource name';
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
]);
|
|
24
|
+
modelName = nameAnswer.modelName;
|
|
25
|
+
}
|
|
26
|
+
// Check if model already exists
|
|
27
|
+
try {
|
|
28
|
+
await execa('kubectl', ['get', 'model', modelName], { stdio: 'pipe' });
|
|
29
|
+
output.warning(`model ${modelName} already exists`);
|
|
30
|
+
const { overwrite } = await inquirer.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: 'confirm',
|
|
33
|
+
name: 'overwrite',
|
|
34
|
+
message: `overwrite existing model ${modelName}?`,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
38
|
+
if (!overwrite) {
|
|
39
|
+
output.info('model creation cancelled');
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Model doesn't exist, continue
|
|
45
|
+
}
|
|
46
|
+
// Step 2: Choose model type
|
|
47
|
+
const { modelType } = await inquirer.prompt([
|
|
48
|
+
{
|
|
49
|
+
type: 'list',
|
|
50
|
+
name: 'modelType',
|
|
51
|
+
message: 'select model provider:',
|
|
52
|
+
choices: [
|
|
53
|
+
{ name: 'Azure OpenAI', value: 'azure' },
|
|
54
|
+
{ name: 'OpenAI', value: 'openai' },
|
|
55
|
+
],
|
|
56
|
+
default: 'azure',
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
// Step 3: Get common parameters
|
|
60
|
+
const commonAnswers = await inquirer.prompt([
|
|
61
|
+
{
|
|
62
|
+
type: 'input',
|
|
63
|
+
name: 'modelVersion',
|
|
64
|
+
message: 'model version:',
|
|
65
|
+
default: 'gpt-4o-mini',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'input',
|
|
69
|
+
name: 'baseUrl',
|
|
70
|
+
message: 'base URL:',
|
|
71
|
+
validate: (input) => {
|
|
72
|
+
if (!input)
|
|
73
|
+
return 'base URL is required';
|
|
74
|
+
try {
|
|
75
|
+
new URL(input);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return 'please enter a valid URL';
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
]);
|
|
84
|
+
// Remove trailing slash from base URL
|
|
85
|
+
const baseUrl = commonAnswers.baseUrl.replace(/\/$/, '');
|
|
86
|
+
// Step 4: Get provider-specific parameters
|
|
87
|
+
let apiVersion = '';
|
|
88
|
+
if (modelType === 'azure') {
|
|
89
|
+
const azureAnswers = await inquirer.prompt([
|
|
90
|
+
{
|
|
91
|
+
type: 'input',
|
|
92
|
+
name: 'apiVersion',
|
|
93
|
+
message: 'Azure API version:',
|
|
94
|
+
default: '2024-12-01-preview',
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
apiVersion = azureAnswers.apiVersion;
|
|
98
|
+
}
|
|
99
|
+
// Step 5: Get API key (password input)
|
|
100
|
+
const { apiKey } = await inquirer.prompt([
|
|
101
|
+
{
|
|
102
|
+
type: 'password',
|
|
103
|
+
name: 'apiKey',
|
|
104
|
+
message: 'API key:',
|
|
105
|
+
mask: '*',
|
|
106
|
+
validate: (input) => {
|
|
107
|
+
if (!input)
|
|
108
|
+
return 'API key is required';
|
|
109
|
+
return true;
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
// Step 6: Create the Kubernetes secret
|
|
114
|
+
const secretName = `${modelName}-model-api-key`;
|
|
115
|
+
output.info(`creating secret ${secretName}...`);
|
|
116
|
+
try {
|
|
117
|
+
// Delete existing secret if it exists (update scenario)
|
|
118
|
+
await execa('kubectl', ['delete', 'secret', secretName], {
|
|
119
|
+
stdio: 'pipe',
|
|
120
|
+
}).catch(() => {
|
|
121
|
+
// Ignore error if secret doesn't exist
|
|
122
|
+
});
|
|
123
|
+
// Create the secret
|
|
124
|
+
await execa('kubectl', [
|
|
125
|
+
'create',
|
|
126
|
+
'secret',
|
|
127
|
+
'generic',
|
|
128
|
+
secretName,
|
|
129
|
+
`--from-literal=api-key=${apiKey}`,
|
|
130
|
+
], { stdio: 'pipe' });
|
|
131
|
+
output.success(`secret ${secretName} created`);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
output.error('failed to create secret');
|
|
135
|
+
console.error(error);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
// Step 7: Create the Model resource
|
|
139
|
+
output.info(`creating model ${modelName}...`);
|
|
140
|
+
const modelManifest = {
|
|
141
|
+
apiVersion: 'ark.mckinsey.com/v1alpha1',
|
|
142
|
+
kind: 'Model',
|
|
143
|
+
metadata: {
|
|
144
|
+
name: modelName,
|
|
145
|
+
},
|
|
146
|
+
spec: {
|
|
147
|
+
type: modelType,
|
|
148
|
+
model: {
|
|
149
|
+
value: commonAnswers.modelVersion,
|
|
150
|
+
},
|
|
151
|
+
config: {},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
// Add provider-specific config
|
|
155
|
+
if (modelType === 'azure') {
|
|
156
|
+
modelManifest.spec.config.azure = {
|
|
157
|
+
apiKey: {
|
|
158
|
+
valueFrom: {
|
|
159
|
+
secretKeyRef: {
|
|
160
|
+
name: secretName,
|
|
161
|
+
key: 'api-key',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
baseUrl: {
|
|
166
|
+
value: baseUrl,
|
|
167
|
+
},
|
|
168
|
+
apiVersion: {
|
|
169
|
+
value: apiVersion,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
modelManifest.spec.config.openai = {
|
|
175
|
+
apiKey: {
|
|
176
|
+
valueFrom: {
|
|
177
|
+
secretKeyRef: {
|
|
178
|
+
name: secretName,
|
|
179
|
+
key: 'api-key',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
baseUrl: {
|
|
184
|
+
value: baseUrl,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
// Apply the model manifest using kubectl
|
|
190
|
+
const manifestJson = JSON.stringify(modelManifest);
|
|
191
|
+
await execa('kubectl', ['apply', '-f', '-'], {
|
|
192
|
+
input: manifestJson,
|
|
193
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
194
|
+
});
|
|
195
|
+
output.success(`model ${modelName} created successfully`);
|
|
196
|
+
console.log();
|
|
197
|
+
output.info('you can now use this model with ARK agents and queries');
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
output.error('failed to create model');
|
|
202
|
+
console.error(error);
|
|
203
|
+
// Try to clean up the secret if model creation failed
|
|
204
|
+
try {
|
|
205
|
+
await execa('kubectl', ['delete', 'secret', secretName], { stdio: 'pipe' });
|
|
206
|
+
output.info(`cleaned up secret ${secretName}`);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Ignore cleanup errors
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
const mockExeca = jest.fn();
|
|
3
|
+
jest.unstable_mockModule('execa', () => ({
|
|
4
|
+
execa: mockExeca,
|
|
5
|
+
}));
|
|
6
|
+
const mockInquirer = {
|
|
7
|
+
prompt: jest.fn(),
|
|
8
|
+
};
|
|
9
|
+
jest.unstable_mockModule('inquirer', () => ({
|
|
10
|
+
default: mockInquirer,
|
|
11
|
+
}));
|
|
12
|
+
const mockOutput = {
|
|
13
|
+
info: jest.fn(),
|
|
14
|
+
warning: jest.fn(),
|
|
15
|
+
error: jest.fn(),
|
|
16
|
+
success: jest.fn(),
|
|
17
|
+
};
|
|
18
|
+
jest.unstable_mockModule('../../lib/output.js', () => ({
|
|
19
|
+
default: mockOutput,
|
|
20
|
+
}));
|
|
21
|
+
jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
22
|
+
jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
23
|
+
const { createModel } = await import('./create.js');
|
|
24
|
+
describe('createModel', () => {
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
jest.clearAllMocks();
|
|
27
|
+
});
|
|
28
|
+
it('creates new model with provided name', async () => {
|
|
29
|
+
// Model doesn't exist
|
|
30
|
+
mockExeca.mockRejectedValueOnce(new Error('not found'));
|
|
31
|
+
// Prompts for model details
|
|
32
|
+
mockInquirer.prompt
|
|
33
|
+
.mockResolvedValueOnce({ modelType: 'openai' })
|
|
34
|
+
.mockResolvedValueOnce({
|
|
35
|
+
modelVersion: 'gpt-4',
|
|
36
|
+
baseUrl: 'https://api.openai.com/',
|
|
37
|
+
})
|
|
38
|
+
.mockResolvedValueOnce({ apiKey: 'secret-key' });
|
|
39
|
+
// Secret operations succeed
|
|
40
|
+
mockExeca.mockResolvedValueOnce({}); // delete secret (may not exist)
|
|
41
|
+
mockExeca.mockResolvedValueOnce({}); // create secret
|
|
42
|
+
mockExeca.mockResolvedValueOnce({}); // apply model
|
|
43
|
+
const result = await createModel('test-model');
|
|
44
|
+
expect(result).toBe(true);
|
|
45
|
+
expect(mockExeca).toHaveBeenCalledWith('kubectl', ['get', 'model', 'test-model'], { stdio: 'pipe' });
|
|
46
|
+
expect(mockOutput.success).toHaveBeenCalledWith('model test-model created successfully');
|
|
47
|
+
});
|
|
48
|
+
it('prompts for name when not provided', async () => {
|
|
49
|
+
mockInquirer.prompt
|
|
50
|
+
.mockResolvedValueOnce({ modelName: 'prompted-model' })
|
|
51
|
+
.mockResolvedValueOnce({ modelType: 'azure' })
|
|
52
|
+
.mockResolvedValueOnce({
|
|
53
|
+
modelVersion: 'gpt-4',
|
|
54
|
+
baseUrl: 'https://azure.com',
|
|
55
|
+
})
|
|
56
|
+
.mockResolvedValueOnce({ apiVersion: '2024-12-01' })
|
|
57
|
+
.mockResolvedValueOnce({ apiKey: 'secret' });
|
|
58
|
+
mockExeca.mockRejectedValueOnce(new Error('not found')); // model doesn't exist
|
|
59
|
+
mockExeca.mockResolvedValue({}); // all kubectl ops succeed
|
|
60
|
+
const result = await createModel();
|
|
61
|
+
expect(result).toBe(true);
|
|
62
|
+
expect(mockInquirer.prompt).toHaveBeenCalledWith([
|
|
63
|
+
expect.objectContaining({
|
|
64
|
+
name: 'modelName',
|
|
65
|
+
message: 'model name:',
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
it('handles overwrite confirmation when model exists', async () => {
|
|
70
|
+
// Model exists
|
|
71
|
+
mockExeca.mockResolvedValueOnce({});
|
|
72
|
+
mockInquirer.prompt
|
|
73
|
+
.mockResolvedValueOnce({ overwrite: true })
|
|
74
|
+
.mockResolvedValueOnce({ modelType: 'openai' })
|
|
75
|
+
.mockResolvedValueOnce({
|
|
76
|
+
modelVersion: 'gpt-4',
|
|
77
|
+
baseUrl: 'https://api.openai.com',
|
|
78
|
+
})
|
|
79
|
+
.mockResolvedValueOnce({ apiKey: 'secret' });
|
|
80
|
+
mockExeca.mockResolvedValue({}); // remaining kubectl ops
|
|
81
|
+
const result = await createModel('existing-model');
|
|
82
|
+
expect(result).toBe(true);
|
|
83
|
+
expect(mockOutput.warning).toHaveBeenCalledWith('model existing-model already exists');
|
|
84
|
+
});
|
|
85
|
+
it('cancels when user declines overwrite', async () => {
|
|
86
|
+
mockExeca.mockResolvedValueOnce({}); // model exists
|
|
87
|
+
mockInquirer.prompt.mockResolvedValueOnce({ overwrite: false });
|
|
88
|
+
const result = await createModel('existing-model');
|
|
89
|
+
expect(result).toBe(false);
|
|
90
|
+
expect(mockOutput.info).toHaveBeenCalledWith('model creation cancelled');
|
|
91
|
+
});
|
|
92
|
+
it('handles secret creation failure', async () => {
|
|
93
|
+
mockExeca.mockRejectedValueOnce(new Error('not found')); // model doesn't exist
|
|
94
|
+
mockInquirer.prompt
|
|
95
|
+
.mockResolvedValueOnce({ modelType: 'openai' })
|
|
96
|
+
.mockResolvedValueOnce({
|
|
97
|
+
modelVersion: 'gpt-4',
|
|
98
|
+
baseUrl: 'https://api.openai.com',
|
|
99
|
+
})
|
|
100
|
+
.mockResolvedValueOnce({ apiKey: 'secret' });
|
|
101
|
+
mockExeca.mockRejectedValueOnce(new Error('delete failed')); // delete secret may fail
|
|
102
|
+
mockExeca.mockRejectedValueOnce(new Error('secret creation failed')); // create secret fails
|
|
103
|
+
const result = await createModel('test-model');
|
|
104
|
+
expect(result).toBe(false);
|
|
105
|
+
expect(mockOutput.error).toHaveBeenCalledWith('failed to create secret');
|
|
106
|
+
});
|
|
107
|
+
it('cleans up secret if model creation fails', async () => {
|
|
108
|
+
mockExeca.mockRejectedValueOnce(new Error('not found')); // model doesn't exist
|
|
109
|
+
mockInquirer.prompt
|
|
110
|
+
.mockResolvedValueOnce({ modelType: 'openai' })
|
|
111
|
+
.mockResolvedValueOnce({
|
|
112
|
+
modelVersion: 'gpt-4',
|
|
113
|
+
baseUrl: 'https://api.openai.com',
|
|
114
|
+
})
|
|
115
|
+
.mockResolvedValueOnce({ apiKey: 'secret' });
|
|
116
|
+
mockExeca.mockResolvedValueOnce({}); // delete secret
|
|
117
|
+
mockExeca.mockResolvedValueOnce({}); // create secret
|
|
118
|
+
mockExeca.mockRejectedValueOnce(new Error('apply failed')); // apply model fails
|
|
119
|
+
mockExeca.mockResolvedValueOnce({}); // cleanup secret
|
|
120
|
+
const result = await createModel('test-model');
|
|
121
|
+
expect(result).toBe(false);
|
|
122
|
+
expect(mockOutput.error).toHaveBeenCalledWith('failed to create model');
|
|
123
|
+
expect(mockExeca).toHaveBeenCalledWith('kubectl', ['delete', 'secret', 'test-model-model-api-key'], { stdio: 'pipe' });
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import output from '../../lib/output.js';
|
|
4
|
+
import { createModel } from './create.js';
|
|
5
|
+
import { executeQuery } from '../../lib/executeQuery.js';
|
|
6
|
+
async function listModels(options) {
|
|
7
|
+
try {
|
|
8
|
+
// Use kubectl to get models
|
|
9
|
+
const result = await execa('kubectl', ['get', 'models', '-o', 'json'], {
|
|
10
|
+
stdio: 'pipe',
|
|
11
|
+
});
|
|
12
|
+
const data = JSON.parse(result.stdout);
|
|
13
|
+
const models = data.items || [];
|
|
14
|
+
if (options.output === 'json') {
|
|
15
|
+
// Output the raw items for JSON format
|
|
16
|
+
console.log(JSON.stringify(models, null, 2));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
if (models.length === 0) {
|
|
20
|
+
output.info('No models found');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Just output the model names
|
|
24
|
+
models.forEach((model) => {
|
|
25
|
+
console.log(model.metadata.name);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
output.error('fetching models:', error instanceof Error ? error.message : error);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function createModelsCommand(_) {
|
|
35
|
+
const modelsCommand = new Command('models');
|
|
36
|
+
modelsCommand
|
|
37
|
+
.description('List available models')
|
|
38
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
39
|
+
.action(async (options) => {
|
|
40
|
+
await listModels(options);
|
|
41
|
+
});
|
|
42
|
+
const listCommand = new Command('list');
|
|
43
|
+
listCommand
|
|
44
|
+
.alias('ls')
|
|
45
|
+
.description('List available models')
|
|
46
|
+
.option('-o, --output <format>', 'Output format (json)', 'text')
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
await listModels(options);
|
|
49
|
+
});
|
|
50
|
+
modelsCommand.addCommand(listCommand);
|
|
51
|
+
// Add create command
|
|
52
|
+
const createCommand = new Command('create');
|
|
53
|
+
createCommand
|
|
54
|
+
.description('Create a new model')
|
|
55
|
+
.argument('[name]', 'Model name (optional)')
|
|
56
|
+
.action(async (name) => {
|
|
57
|
+
await createModel(name);
|
|
58
|
+
});
|
|
59
|
+
modelsCommand.addCommand(createCommand);
|
|
60
|
+
// Add query command
|
|
61
|
+
const queryCommand = new Command('query');
|
|
62
|
+
queryCommand
|
|
63
|
+
.description('Query a model')
|
|
64
|
+
.argument('<name>', 'Model name (e.g., default)')
|
|
65
|
+
.argument('<message>', 'Message to send')
|
|
66
|
+
.action(async (name, message) => {
|
|
67
|
+
await executeQuery({
|
|
68
|
+
targetType: 'model',
|
|
69
|
+
targetName: name,
|
|
70
|
+
message,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
modelsCommand.addCommand(queryCommand);
|
|
74
|
+
return modelsCommand;
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
const mockExeca = jest.fn();
|
|
4
|
+
jest.unstable_mockModule('execa', () => ({
|
|
5
|
+
execa: mockExeca,
|
|
6
|
+
}));
|
|
7
|
+
const mockOutput = {
|
|
8
|
+
info: jest.fn(),
|
|
9
|
+
error: jest.fn(),
|
|
10
|
+
};
|
|
11
|
+
jest.unstable_mockModule('../../lib/output.js', () => ({
|
|
12
|
+
default: mockOutput,
|
|
13
|
+
}));
|
|
14
|
+
const mockCreateModel = jest.fn();
|
|
15
|
+
jest.unstable_mockModule('./create.js', () => ({
|
|
16
|
+
createModel: mockCreateModel,
|
|
17
|
+
}));
|
|
18
|
+
const mockExecuteQuery = jest.fn();
|
|
19
|
+
jest.unstable_mockModule('../../lib/executeQuery.js', () => ({
|
|
20
|
+
executeQuery: mockExecuteQuery,
|
|
21
|
+
parseTarget: jest.fn(),
|
|
22
|
+
}));
|
|
23
|
+
const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {
|
|
24
|
+
throw new Error('process.exit called');
|
|
25
|
+
}));
|
|
26
|
+
const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
27
|
+
const { createModelsCommand } = await import('./index.js');
|
|
28
|
+
describe('models command', () => {
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
jest.clearAllMocks();
|
|
31
|
+
});
|
|
32
|
+
it('creates command with correct structure', () => {
|
|
33
|
+
const command = createModelsCommand({});
|
|
34
|
+
expect(command).toBeInstanceOf(Command);
|
|
35
|
+
expect(command.name()).toBe('models');
|
|
36
|
+
});
|
|
37
|
+
it('lists models in text format', async () => {
|
|
38
|
+
const mockModels = {
|
|
39
|
+
items: [{ metadata: { name: 'gpt-4' } }, { metadata: { name: 'claude-3' } }],
|
|
40
|
+
};
|
|
41
|
+
mockExeca.mockResolvedValue({ stdout: JSON.stringify(mockModels) });
|
|
42
|
+
const command = createModelsCommand({});
|
|
43
|
+
await command.parseAsync(['node', 'test']);
|
|
44
|
+
expect(mockExeca).toHaveBeenCalledWith('kubectl', ['get', 'models', '-o', 'json'], { stdio: 'pipe' });
|
|
45
|
+
expect(mockConsoleLog).toHaveBeenCalledWith('gpt-4');
|
|
46
|
+
expect(mockConsoleLog).toHaveBeenCalledWith('claude-3');
|
|
47
|
+
});
|
|
48
|
+
it('lists models in json format', async () => {
|
|
49
|
+
const mockModels = {
|
|
50
|
+
items: [{ metadata: { name: 'gpt-4' } }],
|
|
51
|
+
};
|
|
52
|
+
mockExeca.mockResolvedValue({ stdout: JSON.stringify(mockModels) });
|
|
53
|
+
const command = createModelsCommand({});
|
|
54
|
+
await command.parseAsync(['node', 'test', '-o', 'json']);
|
|
55
|
+
expect(mockConsoleLog).toHaveBeenCalledWith(JSON.stringify(mockModels.items, null, 2));
|
|
56
|
+
});
|
|
57
|
+
it('shows info when no models', async () => {
|
|
58
|
+
mockExeca.mockResolvedValue({ stdout: JSON.stringify({ items: [] }) });
|
|
59
|
+
const command = createModelsCommand({});
|
|
60
|
+
await command.parseAsync(['node', 'test']);
|
|
61
|
+
expect(mockOutput.info).toHaveBeenCalledWith('No models found');
|
|
62
|
+
});
|
|
63
|
+
it('handles errors', async () => {
|
|
64
|
+
mockExeca.mockRejectedValue(new Error('kubectl failed'));
|
|
65
|
+
const command = createModelsCommand({});
|
|
66
|
+
await expect(command.parseAsync(['node', 'test'])).rejects.toThrow('process.exit called');
|
|
67
|
+
expect(mockOutput.error).toHaveBeenCalledWith('fetching models:', 'kubectl failed');
|
|
68
|
+
expect(mockExit).toHaveBeenCalledWith(1);
|
|
69
|
+
});
|
|
70
|
+
it('list subcommand works', async () => {
|
|
71
|
+
mockExeca.mockResolvedValue({ stdout: JSON.stringify({ items: [] }) });
|
|
72
|
+
const command = createModelsCommand({});
|
|
73
|
+
await command.parseAsync(['node', 'test', 'list']);
|
|
74
|
+
expect(mockExeca).toHaveBeenCalled();
|
|
75
|
+
});
|
|
76
|
+
it('create subcommand works', async () => {
|
|
77
|
+
const command = createModelsCommand({});
|
|
78
|
+
await command.parseAsync(['node', 'test', 'create', 'my-model']);
|
|
79
|
+
expect(mockCreateModel).toHaveBeenCalledWith('my-model');
|
|
80
|
+
});
|
|
81
|
+
it('query subcommand works', async () => {
|
|
82
|
+
const command = createModelsCommand({});
|
|
83
|
+
await command.parseAsync([
|
|
84
|
+
'node',
|
|
85
|
+
'test',
|
|
86
|
+
'query',
|
|
87
|
+
'default',
|
|
88
|
+
'Hello world',
|
|
89
|
+
]);
|
|
90
|
+
expect(mockExecuteQuery).toHaveBeenCalledWith({
|
|
91
|
+
targetType: 'model',
|
|
92
|
+
targetName: 'default',
|
|
93
|
+
message: 'Hello world',
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Model, ArkApiClient } from '../../lib/arkApiClient.js';
|
|
2
|
+
interface ModelSelectorProps {
|
|
3
|
+
arkApiClient: ArkApiClient;
|
|
4
|
+
onSelect: (model: Model) => void;
|
|
5
|
+
onExit: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ModelSelector({ arkApiClient, onSelect, onExit, }: ModelSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|