@agents-at-scale/ark 0.1.35 → 0.1.36
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/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/chat/index.d.ts +3 -0
- package/dist/commands/chat/index.js +29 -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/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/dashboard/index.d.ts +4 -0
- package/dist/commands/dashboard/index.js +39 -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/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/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/status/index.d.ts +3 -0
- package/dist/commands/status/index.js +281 -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/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/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/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/components/ChatUI.d.ts +16 -0
- package/dist/components/ChatUI.js +801 -0
- package/dist/components/statusChecker.d.ts +14 -24
- package/dist/components/statusChecker.js +295 -129
- 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/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/errors.js +1 -1
- package/dist/lib/errors.spec.d.ts +1 -0
- package/dist/lib/errors.spec.js +221 -0
- 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/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
- package/dist/commands/cluster/get-ip.d.ts +0 -2
- package/dist/commands/cluster/get-ip.js +0 -32
- package/dist/commands/cluster/get-type.d.ts +0 -2
- package/dist/commands/cluster/get-type.js +0 -26
- package/dist/commands/completion.d.ts +0 -2
- package/dist/commands/completion.js +0 -108
- package/dist/commands/config.d.ts +0 -5
- package/dist/commands/config.js +0 -327
- package/dist/components/DashboardCLI.d.ts +0 -3
- package/dist/components/DashboardCLI.js +0 -149
- package/dist/config.d.ts +0 -42
- package/dist/config.js +0 -243
- package/dist/lib/arkClient.d.ts +0 -32
- package/dist/lib/arkClient.js +0 -43
- package/dist/lib/consts.d.ts +0 -10
- package/dist/lib/consts.js +0 -15
- package/dist/lib/exec.d.ts +0 -5
- package/dist/lib/exec.js +0 -20
- package/dist/lib/gatewayManager.d.ts +0 -24
- package/dist/lib/gatewayManager.js +0 -85
- package/dist/lib/kubernetes.d.ts +0 -28
- package/dist/lib/kubernetes.js +0 -122
- package/dist/lib/progress.d.ts +0 -128
- package/dist/lib/progress.js +0 -273
- package/dist/lib/wrappers/git.d.ts +0 -2
- package/dist/lib/wrappers/git.js +0 -43
package/dist/config.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import { homedir } from 'os';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
import Debug from 'debug';
|
|
6
|
-
import { ArkClient } from './lib/arkClient.js';
|
|
7
|
-
import { DEFAULT_ADDRESS_ARK_API, CONFIG_DIR_NAME, CONFIG_FILE_NAME, } from './lib/consts.js';
|
|
8
|
-
import { GatewayManager } from './lib/gatewayManager.js';
|
|
9
|
-
import { KubernetesConfigManager } from './lib/kubernetes.js';
|
|
10
|
-
const debug = Debug('ark:config');
|
|
11
|
-
/**
|
|
12
|
-
* ConfigManager handles ARK CLI configuration with automatic service discovery
|
|
13
|
-
* and multiple fallback mechanisms. Complex discovery logic can be debugged by
|
|
14
|
-
* setting DEBUG=ark:config or DEBUG=ark:* environment variable.
|
|
15
|
-
*
|
|
16
|
-
* Example usage:
|
|
17
|
-
* DEBUG=ark:config ark check status
|
|
18
|
-
* DEBUG=ark:* ark dashboard
|
|
19
|
-
*/
|
|
20
|
-
export class ConfigManager {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.kubeConfig = null;
|
|
23
|
-
this.configDir = join(homedir(), '.config', CONFIG_DIR_NAME);
|
|
24
|
-
this.configFile = join(this.configDir, CONFIG_FILE_NAME);
|
|
25
|
-
this.kubernetesManager = new KubernetesConfigManager();
|
|
26
|
-
this.gatewayManager = new GatewayManager();
|
|
27
|
-
}
|
|
28
|
-
async ensureConfigDir() {
|
|
29
|
-
try {
|
|
30
|
-
await fs.mkdir(this.configDir, { recursive: true });
|
|
31
|
-
}
|
|
32
|
-
catch (_error) {
|
|
33
|
-
// Directory might already exist
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async loadConfig() {
|
|
37
|
-
await this.ensureConfigDir();
|
|
38
|
-
try {
|
|
39
|
-
// Check if config file exists
|
|
40
|
-
await fs.access(this.configFile);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
// Config file doesn't exist - start with default config and enrich with kube config
|
|
44
|
-
if (error &&
|
|
45
|
-
typeof error === 'object' &&
|
|
46
|
-
'code' in error &&
|
|
47
|
-
error.code === 'ENOENT') {
|
|
48
|
-
return await this.getDefaultConfig();
|
|
49
|
-
}
|
|
50
|
-
// Other access errors (permissions, etc.) should be thrown
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
// Config file exists - try to read and parse it
|
|
55
|
-
const data = await fs.readFile(this.configFile, 'utf-8');
|
|
56
|
-
const config = JSON.parse(data);
|
|
57
|
-
// Merge with current Kubernetes config if not present
|
|
58
|
-
await this.initKubernetesConfig();
|
|
59
|
-
return {
|
|
60
|
-
...config,
|
|
61
|
-
kubeconfig: config.kubeconfig || this.kubeConfig?.kubeconfig,
|
|
62
|
-
currentContext: config.currentContext || this.kubeConfig?.currentContext,
|
|
63
|
-
kubeNamespace: config.kubeNamespace || this.kubeConfig?.namespace,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
// If it's a JSON parsing error, throw a clear error message
|
|
68
|
-
if (error instanceof SyntaxError) {
|
|
69
|
-
throw new Error(`Invalid JSON in config file ${this.configFile}: ${error.message}`);
|
|
70
|
-
}
|
|
71
|
-
// Other errors (read errors, etc.) should be thrown as-is
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async saveConfig(config) {
|
|
76
|
-
await this.ensureConfigDir();
|
|
77
|
-
const jsonData = JSON.stringify(config, null, 2);
|
|
78
|
-
await fs.writeFile(this.configFile, jsonData);
|
|
79
|
-
}
|
|
80
|
-
async updateConfig(updates) {
|
|
81
|
-
const currentConfig = await this.loadConfig();
|
|
82
|
-
const newConfig = { ...currentConfig, ...updates };
|
|
83
|
-
await this.saveConfig(newConfig);
|
|
84
|
-
return newConfig;
|
|
85
|
-
}
|
|
86
|
-
async getDefaultConfig() {
|
|
87
|
-
// Initialize Kubernetes config to get defaults
|
|
88
|
-
await this.initKubernetesConfig();
|
|
89
|
-
return {
|
|
90
|
-
defaultAgent: 'default',
|
|
91
|
-
defaultModel: 'default',
|
|
92
|
-
defaultNamespace: this.kubeConfig?.namespace || 'default',
|
|
93
|
-
apiBaseUrl: DEFAULT_ADDRESS_ARK_API,
|
|
94
|
-
kubeconfig: this.kubeConfig?.kubeconfig,
|
|
95
|
-
currentContext: this.kubeConfig?.currentContext,
|
|
96
|
-
kubeNamespace: this.kubeConfig?.namespace,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
async initializeConfig() {
|
|
100
|
-
const config = await this.loadConfig();
|
|
101
|
-
const defaultConfig = await this.getDefaultConfig();
|
|
102
|
-
const mergedConfig = { ...defaultConfig, ...config };
|
|
103
|
-
await this.saveConfig(mergedConfig);
|
|
104
|
-
return mergedConfig;
|
|
105
|
-
}
|
|
106
|
-
getConfigPath() {
|
|
107
|
-
return this.configFile;
|
|
108
|
-
}
|
|
109
|
-
async getApiBaseUrl() {
|
|
110
|
-
const config = await this.loadConfig();
|
|
111
|
-
// If apiBaseUrl is explicitly set in config, use it
|
|
112
|
-
if (config.apiBaseUrl && config.apiBaseUrl !== DEFAULT_ADDRESS_ARK_API) {
|
|
113
|
-
debug('using explicit config apiBaseUrl: %s', config.apiBaseUrl);
|
|
114
|
-
return config.apiBaseUrl;
|
|
115
|
-
}
|
|
116
|
-
// First try to detect localhost-gateway (works for everyone with standard setup)
|
|
117
|
-
if (await this.isLocalhostGatewayRunning()) {
|
|
118
|
-
const gatewayUrls = this.getLocalhostGatewayUrls();
|
|
119
|
-
const arkApiUrl = gatewayUrls['ark-api'];
|
|
120
|
-
if (arkApiUrl) {
|
|
121
|
-
debug('localhost-gateway detected, using: %s', arkApiUrl);
|
|
122
|
-
return arkApiUrl;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Try to discover ark-api service via Kubernetes (requires kubeconfig)
|
|
126
|
-
await this.initKubernetesConfig();
|
|
127
|
-
if (this.kubeConfig) {
|
|
128
|
-
try {
|
|
129
|
-
const namespace = config.kubeNamespace || config.defaultNamespace || 'default';
|
|
130
|
-
const discoveredUrl = await this.kubernetesManager.getArkApiUrl(namespace);
|
|
131
|
-
debug('kubernetes discovery successful in %s: %s', namespace, discoveredUrl);
|
|
132
|
-
return discoveredUrl;
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
debug('kubernetes discovery failed: %s', error instanceof Error ? error.message : error);
|
|
136
|
-
// Fall back to default if discovery fails
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const fallbackUrl = config.apiBaseUrl || DEFAULT_ADDRESS_ARK_API;
|
|
140
|
-
debug('falling back to default: %s', fallbackUrl);
|
|
141
|
-
return fallbackUrl;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Check if localhost-gateway is running by testing port 8080
|
|
145
|
-
*/
|
|
146
|
-
async isLocalhostGatewayRunning() {
|
|
147
|
-
try {
|
|
148
|
-
// Try to connect to the localhost gateway port
|
|
149
|
-
const response = await axios.get('http://127.0.0.1:8080', {
|
|
150
|
-
timeout: 2000,
|
|
151
|
-
validateStatus: () => true, // Accept any status code, we just want to know if it's reachable
|
|
152
|
-
});
|
|
153
|
-
debug('localhost-gateway check: available (status %d)', response.status);
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
debug('localhost-gateway check: unavailable (%s)', error instanceof Error ? error.message : error);
|
|
158
|
-
// Gateway not responding - fall back to other discovery methods
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Construct standard localhost-gateway URLs for known ARK services
|
|
164
|
-
*/
|
|
165
|
-
getLocalhostGatewayUrls() {
|
|
166
|
-
const port = 8080;
|
|
167
|
-
// Known services that are typically exposed via localhost-gateway
|
|
168
|
-
const knownServices = {
|
|
169
|
-
'ark-api': `http://ark-api.127.0.0.1.nip.io:${port}`,
|
|
170
|
-
'ark-dashboard': `http://dashboard.127.0.0.1.nip.io:${port}`,
|
|
171
|
-
'ark-api-a2a': `http://ark-api-a2a.127.0.0.1.nip.io:${port}`,
|
|
172
|
-
langfuse: `http://langfuse.telemetry.127.0.0.1.nip.io:${port}`, // Fixed URL to match HTTPRoute
|
|
173
|
-
// Add other services as they become available via gateway
|
|
174
|
-
};
|
|
175
|
-
return knownServices;
|
|
176
|
-
}
|
|
177
|
-
async initKubernetesConfig() {
|
|
178
|
-
if (!this.kubeConfig) {
|
|
179
|
-
try {
|
|
180
|
-
this.kubeConfig = await this.kubernetesManager.initializeConfig();
|
|
181
|
-
debug('kubernetes config loaded: context=%s namespace=%s', this.kubeConfig?.currentContext, this.kubeConfig?.namespace);
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
debug('kubernetes config unavailable: %s', error instanceof Error ? error.message : error);
|
|
185
|
-
// Kubernetes config not available - that's okay for some use cases
|
|
186
|
-
this.kubeConfig = null;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
async getKubernetesConfig() {
|
|
191
|
-
await this.initKubernetesConfig();
|
|
192
|
-
return this.kubeConfig;
|
|
193
|
-
}
|
|
194
|
-
async testClusterAccess() {
|
|
195
|
-
await this.initKubernetesConfig();
|
|
196
|
-
if (!this.kubeConfig) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
return await this.kubernetesManager.testClusterAccess();
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Discover service URLs from ark-api service discovery
|
|
203
|
-
*/
|
|
204
|
-
async discoverServicesFromApi() {
|
|
205
|
-
try {
|
|
206
|
-
const apiBaseUrl = await this.getApiBaseUrl();
|
|
207
|
-
const arkClient = new ArkClient(apiBaseUrl);
|
|
208
|
-
const config = await this.loadConfig();
|
|
209
|
-
const namespace = config.kubeNamespace || config.defaultNamespace || 'default';
|
|
210
|
-
debug('service discovery: querying ark-api at %s (namespace: %s)', apiBaseUrl, namespace);
|
|
211
|
-
const services = await arkClient.getArkServices(namespace);
|
|
212
|
-
const serviceUrls = {};
|
|
213
|
-
// Dynamically map all discovered services with HTTP routes
|
|
214
|
-
for (const service of services) {
|
|
215
|
-
if (service.httproutes && service.httproutes.length > 0) {
|
|
216
|
-
const serviceName = service.release_name || service.name;
|
|
217
|
-
const serviceUrl = service.httproutes[0].url; // Use first route URL
|
|
218
|
-
serviceUrls[serviceName] = serviceUrl;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const discoveredServices = Object.entries(serviceUrls).map(([key, url]) => `${key}: ${url}`);
|
|
222
|
-
debug('service discovery: found %d services - %s', discoveredServices.length, discoveredServices.join(', ') || 'none');
|
|
223
|
-
return serviceUrls;
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
debug('service discovery failed: %s', error instanceof Error ? error.message : error);
|
|
227
|
-
// Return empty object if discovery fails - will fall back to config/defaults
|
|
228
|
-
return {};
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
async getServiceUrls() {
|
|
232
|
-
// Try localhost-gateway detection (works for everyone with standard setup)
|
|
233
|
-
if (await this.isLocalhostGatewayRunning()) {
|
|
234
|
-
const gatewayUrls = this.getLocalhostGatewayUrls();
|
|
235
|
-
debug('localhost-gateway detected, using: %o', gatewayUrls);
|
|
236
|
-
return gatewayUrls;
|
|
237
|
-
}
|
|
238
|
-
// Try to discover services from ark-api (requires kubeconfig)
|
|
239
|
-
const discoveredUrls = await this.discoverServicesFromApi();
|
|
240
|
-
debug('discovered services: %o', discoveredUrls);
|
|
241
|
-
return discoveredUrls;
|
|
242
|
-
}
|
|
243
|
-
}
|
package/dist/lib/arkClient.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface ArkService {
|
|
2
|
-
name: string;
|
|
3
|
-
namespace: string;
|
|
4
|
-
release_name: string;
|
|
5
|
-
chart_name: string;
|
|
6
|
-
chart_version: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
routes?: HTTPRouteInfo[];
|
|
9
|
-
httproutes?: HTTPRouteInfo[];
|
|
10
|
-
}
|
|
11
|
-
export interface HTTPRouteInfo {
|
|
12
|
-
name: string;
|
|
13
|
-
namespace: string;
|
|
14
|
-
url: string;
|
|
15
|
-
rules: number;
|
|
16
|
-
}
|
|
17
|
-
export interface ArkServiceListResponse {
|
|
18
|
-
items: ArkService[];
|
|
19
|
-
}
|
|
20
|
-
export declare class ArkClient {
|
|
21
|
-
private client;
|
|
22
|
-
constructor(baseURL: string);
|
|
23
|
-
getBaseURL(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Get ARK services and their discovered URLs from gateway routes
|
|
26
|
-
*/
|
|
27
|
-
getArkServices(namespace?: string): Promise<ArkService[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Test if the API is reachable
|
|
30
|
-
*/
|
|
31
|
-
testConnection(): Promise<boolean>;
|
|
32
|
-
}
|
package/dist/lib/arkClient.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { DEFAULT_TIMEOUT_MS, DEFAULT_CONNECTION_TEST_TIMEOUT_MS, } from './consts.js';
|
|
3
|
-
export class ArkClient {
|
|
4
|
-
constructor(baseURL) {
|
|
5
|
-
this.client = axios.create({
|
|
6
|
-
baseURL,
|
|
7
|
-
timeout: DEFAULT_TIMEOUT_MS,
|
|
8
|
-
headers: {
|
|
9
|
-
'Content-Type': 'application/json',
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
getBaseURL() {
|
|
14
|
-
return this.client.defaults.baseURL || '';
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get ARK services and their discovered URLs from gateway routes
|
|
18
|
-
*/
|
|
19
|
-
async getArkServices(namespace = 'default') {
|
|
20
|
-
try {
|
|
21
|
-
const response = await this.client.get(`/v1/namespaces/${namespace}/ark-services`);
|
|
22
|
-
return response.data.items;
|
|
23
|
-
}
|
|
24
|
-
catch (_error) {
|
|
25
|
-
// If service discovery fails, return empty array to fall back to defaults
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Test if the API is reachable
|
|
31
|
-
*/
|
|
32
|
-
async testConnection() {
|
|
33
|
-
try {
|
|
34
|
-
await this.client.get('/health', {
|
|
35
|
-
timeout: DEFAULT_CONNECTION_TEST_TIMEOUT_MS,
|
|
36
|
-
});
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
package/dist/lib/consts.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_ADDRESS_ARK_API = "http://localhost:8000";
|
|
2
|
-
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
3
|
-
export declare const DEFAULT_CONNECTION_TEST_TIMEOUT_MS = 5000;
|
|
4
|
-
export declare const CONFIG_DIR_NAME = "ark";
|
|
5
|
-
export declare const CONFIG_FILE_NAME = "ark-cli.json";
|
|
6
|
-
export declare const DEFAULT_ARK_DASHBOARD_URL = "http://localhost:3000";
|
|
7
|
-
export declare const DEFAULT_ARK_A2A_URL = "http://localhost:8080";
|
|
8
|
-
export declare const DEFAULT_ARK_MEMORY_URL = "http://localhost:8081";
|
|
9
|
-
export declare const DEFAULT_ARK_OTEL_URL = "http://localhost:4318";
|
|
10
|
-
export declare const ARK_REPO_ERROR_MESSAGE = "Error: This command must be run inside the ARK repository.";
|
package/dist/lib/consts.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Default ARK API server address
|
|
2
|
-
export const DEFAULT_ADDRESS_ARK_API = 'http://localhost:8000';
|
|
3
|
-
// Default timeout values
|
|
4
|
-
export const DEFAULT_TIMEOUT_MS = 30000;
|
|
5
|
-
export const DEFAULT_CONNECTION_TEST_TIMEOUT_MS = 5000;
|
|
6
|
-
// Configuration paths
|
|
7
|
-
export const CONFIG_DIR_NAME = 'ark';
|
|
8
|
-
export const CONFIG_FILE_NAME = 'ark-cli.json';
|
|
9
|
-
// Default service URLs
|
|
10
|
-
export const DEFAULT_ARK_DASHBOARD_URL = 'http://localhost:3000';
|
|
11
|
-
export const DEFAULT_ARK_A2A_URL = 'http://localhost:8080';
|
|
12
|
-
export const DEFAULT_ARK_MEMORY_URL = 'http://localhost:8081';
|
|
13
|
-
export const DEFAULT_ARK_OTEL_URL = 'http://localhost:4318';
|
|
14
|
-
// Error message for different ARK repo
|
|
15
|
-
export const ARK_REPO_ERROR_MESSAGE = 'Error: This command must be run inside the ARK repository.';
|
package/dist/lib/exec.d.ts
DELETED
package/dist/lib/exec.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { execa } from 'execa';
|
|
3
|
-
export async function executeCommand(command, args = []) {
|
|
4
|
-
try {
|
|
5
|
-
const result = await execa(command, args);
|
|
6
|
-
return { stdout: result.stdout, stderr: result.stderr };
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
10
|
-
throw new Error(`Command failed: ${command} ${args.join(' ')}\n${errorMessage}`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function fileExists(path) {
|
|
14
|
-
try {
|
|
15
|
-
return fs.existsSync(path);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare class GatewayManager {
|
|
2
|
-
private kubernetesManager;
|
|
3
|
-
constructor();
|
|
4
|
-
/**
|
|
5
|
-
* Check if localhost-gateway port-forward is running by testing the endpoint
|
|
6
|
-
*/
|
|
7
|
-
isPortForwardRunning(port?: number): Promise<boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* Check if localhost-gateway service is deployed in cluster
|
|
10
|
-
*/
|
|
11
|
-
isGatewayDeployed(): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Check if port-forward is needed and provide setup instructions
|
|
14
|
-
*/
|
|
15
|
-
checkPortForwardStatus(port?: number): Promise<{
|
|
16
|
-
isRunning: boolean;
|
|
17
|
-
needsSetup: boolean;
|
|
18
|
-
instructions?: string;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Get setup instructions for fresh installations
|
|
22
|
-
*/
|
|
23
|
-
getSetupInstructions(): string;
|
|
24
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as k8s from '@kubernetes/client-node';
|
|
2
|
-
import { KubernetesConfigManager } from './kubernetes.js';
|
|
3
|
-
export class GatewayManager {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.kubernetesManager = new KubernetesConfigManager();
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Check if localhost-gateway port-forward is running by testing the endpoint
|
|
9
|
-
*/
|
|
10
|
-
async isPortForwardRunning(port = 8080) {
|
|
11
|
-
try {
|
|
12
|
-
const axios = (await import('axios')).default;
|
|
13
|
-
await axios.get(`http://127.0.0.1:${port}`, {
|
|
14
|
-
timeout: 2000,
|
|
15
|
-
validateStatus: () => true,
|
|
16
|
-
});
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Check if localhost-gateway service is deployed in cluster
|
|
25
|
-
*/
|
|
26
|
-
async isGatewayDeployed() {
|
|
27
|
-
try {
|
|
28
|
-
await this.kubernetesManager.initializeConfig();
|
|
29
|
-
const kc = this.kubernetesManager.getKubeConfig();
|
|
30
|
-
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
|
|
31
|
-
await k8sApi.readNamespacedService({
|
|
32
|
-
name: 'localhost-gateway-nginx',
|
|
33
|
-
namespace: 'ark-system',
|
|
34
|
-
});
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Check if port-forward is needed and provide setup instructions
|
|
43
|
-
*/
|
|
44
|
-
async checkPortForwardStatus(port = 8080) {
|
|
45
|
-
const isRunning = await this.isPortForwardRunning(port);
|
|
46
|
-
if (isRunning) {
|
|
47
|
-
return { isRunning: true, needsSetup: false };
|
|
48
|
-
}
|
|
49
|
-
const isDeployed = await this.isGatewayDeployed();
|
|
50
|
-
if (!isDeployed) {
|
|
51
|
-
return {
|
|
52
|
-
isRunning: false,
|
|
53
|
-
needsSetup: true,
|
|
54
|
-
instructions: this.getSetupInstructions(),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
isRunning: false,
|
|
59
|
-
needsSetup: true,
|
|
60
|
-
instructions: `Gateway is deployed but port-forward not running. Start it with:\nkubectl port-forward -n ark-system service/localhost-gateway-nginx ${port}:80`,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get setup instructions for fresh installations
|
|
65
|
-
*/
|
|
66
|
-
getSetupInstructions() {
|
|
67
|
-
return `
|
|
68
|
-
🔧 ARK Gateway Setup Required:
|
|
69
|
-
|
|
70
|
-
To enable service discovery, you need to install the localhost-gateway:
|
|
71
|
-
|
|
72
|
-
1. From your agents-at-scale project root, run:
|
|
73
|
-
make localhost-gateway-install
|
|
74
|
-
|
|
75
|
-
2. This will:
|
|
76
|
-
- Install Gateway API CRDs
|
|
77
|
-
- Deploy NGINX Gateway Fabric
|
|
78
|
-
- Set up port-forwarding to localhost:8080
|
|
79
|
-
|
|
80
|
-
3. Then run 'ark check status' again
|
|
81
|
-
|
|
82
|
-
For more info: docs/content/ark-101/ark-gateway.mdx
|
|
83
|
-
`;
|
|
84
|
-
}
|
|
85
|
-
}
|
package/dist/lib/kubernetes.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as k8s from '@kubernetes/client-node';
|
|
2
|
-
import { KubernetesConfig } from './types.js';
|
|
3
|
-
export declare class KubernetesConfigManager {
|
|
4
|
-
private kc;
|
|
5
|
-
constructor();
|
|
6
|
-
/**
|
|
7
|
-
* Get the KubeConfig instance for API client creation
|
|
8
|
-
*/
|
|
9
|
-
getKubeConfig(): k8s.KubeConfig;
|
|
10
|
-
/**
|
|
11
|
-
* Initialize Kubernetes configuration similar to fark's approach
|
|
12
|
-
* Priority: in-cluster config > KUBECONFIG env > ~/.kube/config
|
|
13
|
-
*/
|
|
14
|
-
initializeConfig(): Promise<KubernetesConfig>;
|
|
15
|
-
/**
|
|
16
|
-
* Get the API server URL for the current cluster
|
|
17
|
-
*/
|
|
18
|
-
getClusterApiUrl(): string;
|
|
19
|
-
/**
|
|
20
|
-
* Detect ark-api service URL in the cluster
|
|
21
|
-
* This mimics how fark discovers services
|
|
22
|
-
*/
|
|
23
|
-
getArkApiUrl(namespace?: string): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Check if we can access the cluster
|
|
26
|
-
*/
|
|
27
|
-
testClusterAccess(): Promise<boolean>;
|
|
28
|
-
}
|
package/dist/lib/kubernetes.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs';
|
|
2
|
-
import { homedir } from 'os';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import * as k8s from '@kubernetes/client-node';
|
|
5
|
-
export class KubernetesConfigManager {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.kc = new k8s.KubeConfig();
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Get the KubeConfig instance for API client creation
|
|
11
|
-
*/
|
|
12
|
-
getKubeConfig() {
|
|
13
|
-
return this.kc;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Initialize Kubernetes configuration similar to fark's approach
|
|
17
|
-
* Priority: in-cluster config > KUBECONFIG env > ~/.kube/config
|
|
18
|
-
*/
|
|
19
|
-
async initializeConfig() {
|
|
20
|
-
let kubeconfig;
|
|
21
|
-
let currentContext;
|
|
22
|
-
let namespace;
|
|
23
|
-
let inCluster = false;
|
|
24
|
-
// Check if we're explicitly in a Kubernetes pod environment
|
|
25
|
-
const isInPod = process.env.KUBERNETES_SERVICE_HOST &&
|
|
26
|
-
process.env.KUBERNETES_SERVICE_PORT &&
|
|
27
|
-
process.env.POD_NAMESPACE;
|
|
28
|
-
if (isInPod) {
|
|
29
|
-
try {
|
|
30
|
-
// Try in-cluster config only if we're definitely in a pod
|
|
31
|
-
this.kc.loadFromCluster();
|
|
32
|
-
inCluster = true;
|
|
33
|
-
kubeconfig = '/var/run/secrets/kubernetes.io/serviceaccount';
|
|
34
|
-
namespace = process.env.POD_NAMESPACE || 'default';
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw new Error(`Failed to load in-cluster Kubernetes configuration: ${error}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Use kubeconfig file for local development
|
|
42
|
-
try {
|
|
43
|
-
kubeconfig =
|
|
44
|
-
process.env.KUBECONFIG || join(homedir(), '.kube', 'config');
|
|
45
|
-
// Check if kubeconfig file exists
|
|
46
|
-
await fs.access(kubeconfig);
|
|
47
|
-
this.kc.loadFromFile(kubeconfig);
|
|
48
|
-
// Get current context and namespace
|
|
49
|
-
currentContext = this.kc.currentContext;
|
|
50
|
-
// Simplified namespace detection - just use default for now
|
|
51
|
-
// Complex namespace detection can be added later if needed
|
|
52
|
-
namespace = 'default';
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
throw new Error(`Failed to load Kubernetes configuration: ${error}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
kubeconfig,
|
|
60
|
-
currentContext,
|
|
61
|
-
namespace,
|
|
62
|
-
inCluster,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get the API server URL for the current cluster
|
|
67
|
-
*/
|
|
68
|
-
getClusterApiUrl() {
|
|
69
|
-
const cluster = this.kc.getCurrentCluster();
|
|
70
|
-
if (!cluster) {
|
|
71
|
-
throw new Error('No current cluster found in kubeconfig');
|
|
72
|
-
}
|
|
73
|
-
return cluster.server;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Detect ark-api service URL in the cluster
|
|
77
|
-
* This mimics how fark discovers services
|
|
78
|
-
*/
|
|
79
|
-
async getArkApiUrl(namespace = 'default') {
|
|
80
|
-
const k8sApi = this.kc.makeApiClient(k8s.CoreV1Api);
|
|
81
|
-
try {
|
|
82
|
-
// Try to find ark-api service
|
|
83
|
-
const service = await k8sApi.readNamespacedService({
|
|
84
|
-
name: 'ark-api',
|
|
85
|
-
namespace,
|
|
86
|
-
});
|
|
87
|
-
if (service.spec?.type === 'LoadBalancer' &&
|
|
88
|
-
service.status?.loadBalancer?.ingress?.[0]) {
|
|
89
|
-
const ingress = service.status.loadBalancer.ingress[0];
|
|
90
|
-
const host = ingress.ip || ingress.hostname;
|
|
91
|
-
const port = service.spec.ports?.[0]?.port || 8080;
|
|
92
|
-
return `http://${host}:${port}`;
|
|
93
|
-
}
|
|
94
|
-
if (service.spec?.type === 'NodePort' && service.spec.ports?.[0]) {
|
|
95
|
-
const nodePort = service.spec.ports[0].nodePort;
|
|
96
|
-
const clusterUrl = this.getClusterApiUrl();
|
|
97
|
-
const clusterHost = new URL(clusterUrl).hostname;
|
|
98
|
-
return `http://${clusterHost}:${nodePort}`;
|
|
99
|
-
}
|
|
100
|
-
// Default to port-forward style access
|
|
101
|
-
const port = service.spec?.ports?.[0]?.port || 8080;
|
|
102
|
-
return `http://localhost:${port}`;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
// Service not found or not accessible
|
|
106
|
-
throw new Error(`ark-api service not found or not accessible in namespace '${namespace}': ${error instanceof Error ? error.message : error}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Check if we can access the cluster
|
|
111
|
-
*/
|
|
112
|
-
async testClusterAccess() {
|
|
113
|
-
try {
|
|
114
|
-
const k8sApi = this.kc.makeApiClient(k8s.CoreV1Api);
|
|
115
|
-
await k8sApi.listNamespace();
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|