@agents-at-scale/ark 0.1.35-rc1 → 0.1.35
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/commands/cluster/index.d.ts +1 -2
- package/dist/commands/cluster/index.js +5 -3
- package/dist/commands/completion.js +2 -159
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.js +321 -38
- package/dist/commands/generate/config.js +24 -5
- package/dist/commands/generate/generators/agent.js +2 -2
- package/dist/commands/generate/generators/mcpserver.d.ts +1 -2
- package/dist/commands/generate/generators/mcpserver.js +5 -26
- package/dist/commands/generate/generators/project.js +41 -22
- package/dist/commands/generate/generators/team.js +2 -2
- package/dist/commands/generate/index.d.ts +1 -2
- package/dist/commands/generate/index.js +1 -1
- package/dist/components/statusChecker.d.ts +23 -13
- package/dist/components/statusChecker.js +129 -275
- package/dist/config.d.ts +22 -3
- package/dist/config.js +161 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -40
- package/dist/lib/cluster.d.ts +1 -2
- package/dist/lib/cluster.js +16 -37
- package/dist/lib/config.d.ts +80 -26
- package/dist/lib/config.js +205 -70
- package/dist/lib/consts.d.ts +1 -0
- package/dist/lib/consts.js +2 -0
- package/dist/lib/errors.js +1 -1
- package/dist/lib/exec.d.ts +4 -0
- package/dist/lib/exec.js +11 -0
- package/dist/lib/types.d.ts +3 -10
- package/dist/ui/MainMenu.d.ts +1 -5
- package/dist/ui/MainMenu.js +91 -222
- package/dist/ui/statusFormatter.d.ts +7 -22
- package/dist/ui/statusFormatter.js +39 -39
- package/package.json +5 -17
- package/dist/arkServices.d.ts +0 -42
- package/dist/arkServices.js +0 -138
- package/dist/arkServices.spec.d.ts +0 -1
- package/dist/arkServices.spec.js +0 -24
- package/dist/charts/charts.d.ts +0 -5
- package/dist/charts/charts.js +0 -6
- package/dist/charts/dependencies.d.ts +0 -6
- package/dist/charts/dependencies.js +0 -50
- package/dist/charts/types.d.ts +0 -40
- package/dist/charts/types.js +0 -1
- package/dist/commands/agents/index.d.ts +0 -3
- package/dist/commands/agents/index.js +0 -51
- package/dist/commands/agents/index.spec.d.ts +0 -1
- package/dist/commands/agents/index.spec.js +0 -67
- package/dist/commands/agents/selector.d.ts +0 -8
- package/dist/commands/agents/selector.js +0 -53
- package/dist/commands/agents.d.ts +0 -2
- package/dist/commands/agents.js +0 -53
- package/dist/commands/chat/index.d.ts +0 -3
- package/dist/commands/chat/index.js +0 -29
- package/dist/commands/chat.d.ts +0 -2
- package/dist/commands/chat.js +0 -45
- package/dist/commands/cluster/get.d.ts +0 -2
- package/dist/commands/cluster/get.js +0 -39
- package/dist/commands/cluster/get.spec.d.ts +0 -1
- package/dist/commands/cluster/get.spec.js +0 -92
- package/dist/commands/cluster/index.spec.d.ts +0 -1
- package/dist/commands/cluster/index.spec.js +0 -24
- package/dist/commands/completion/index.d.ts +0 -3
- package/dist/commands/completion/index.js +0 -268
- package/dist/commands/completion/index.spec.d.ts +0 -1
- package/dist/commands/completion/index.spec.js +0 -34
- package/dist/commands/config/index.d.ts +0 -3
- package/dist/commands/config/index.js +0 -42
- package/dist/commands/config/index.spec.d.ts +0 -1
- package/dist/commands/config/index.spec.js +0 -78
- package/dist/commands/dashboard/index.d.ts +0 -4
- package/dist/commands/dashboard/index.js +0 -39
- package/dist/commands/dashboard.d.ts +0 -3
- package/dist/commands/dashboard.js +0 -39
- package/dist/commands/dev/index.d.ts +0 -3
- package/dist/commands/dev/index.js +0 -9
- package/dist/commands/dev/tool/check.d.ts +0 -2
- package/dist/commands/dev/tool/check.js +0 -142
- package/dist/commands/dev/tool/clean.d.ts +0 -2
- package/dist/commands/dev/tool/clean.js +0 -153
- package/dist/commands/dev/tool/generate.d.ts +0 -2
- package/dist/commands/dev/tool/generate.js +0 -28
- package/dist/commands/dev/tool/index.d.ts +0 -2
- package/dist/commands/dev/tool/index.js +0 -14
- package/dist/commands/dev/tool/init.d.ts +0 -2
- package/dist/commands/dev/tool/init.js +0 -320
- package/dist/commands/dev/tool/shared.d.ts +0 -5
- package/dist/commands/dev/tool/shared.js +0 -256
- package/dist/commands/dev/tool/status.d.ts +0 -2
- package/dist/commands/dev/tool/status.js +0 -136
- package/dist/commands/dev/tool-generate.spec.d.ts +0 -1
- package/dist/commands/dev/tool-generate.spec.js +0 -163
- package/dist/commands/dev/tool.d.ts +0 -2
- package/dist/commands/dev/tool.js +0 -559
- package/dist/commands/dev/tool.spec.d.ts +0 -1
- package/dist/commands/dev/tool.spec.js +0 -48
- package/dist/commands/install/index.d.ts +0 -8
- package/dist/commands/install/index.js +0 -302
- package/dist/commands/install/index.spec.d.ts +0 -1
- package/dist/commands/install/index.spec.js +0 -135
- package/dist/commands/install.d.ts +0 -3
- package/dist/commands/install.js +0 -147
- package/dist/commands/models/create.d.ts +0 -1
- package/dist/commands/models/create.js +0 -213
- package/dist/commands/models/create.spec.d.ts +0 -1
- package/dist/commands/models/create.spec.js +0 -125
- package/dist/commands/models/index.d.ts +0 -3
- package/dist/commands/models/index.js +0 -60
- package/dist/commands/models/index.spec.d.ts +0 -1
- package/dist/commands/models/index.spec.js +0 -76
- package/dist/commands/models/selector.d.ts +0 -8
- package/dist/commands/models/selector.js +0 -53
- package/dist/commands/routes/index.d.ts +0 -3
- package/dist/commands/routes/index.js +0 -93
- package/dist/commands/routes.d.ts +0 -2
- package/dist/commands/routes.js +0 -101
- package/dist/commands/status/index.d.ts +0 -4
- package/dist/commands/status/index.js +0 -232
- package/dist/commands/status.d.ts +0 -3
- package/dist/commands/status.js +0 -33
- package/dist/commands/targets/index.d.ts +0 -3
- package/dist/commands/targets/index.js +0 -65
- package/dist/commands/targets/index.spec.d.ts +0 -1
- package/dist/commands/targets/index.spec.js +0 -105
- package/dist/commands/targets.d.ts +0 -2
- package/dist/commands/targets.js +0 -65
- package/dist/commands/teams/index.d.ts +0 -3
- package/dist/commands/teams/index.js +0 -49
- package/dist/commands/teams/index.spec.d.ts +0 -1
- package/dist/commands/teams/index.spec.js +0 -70
- package/dist/commands/teams/selector.d.ts +0 -8
- package/dist/commands/teams/selector.js +0 -55
- package/dist/commands/tools/index.d.ts +0 -3
- package/dist/commands/tools/index.js +0 -49
- package/dist/commands/tools/index.spec.d.ts +0 -1
- package/dist/commands/tools/index.spec.js +0 -70
- package/dist/commands/tools/selector.d.ts +0 -8
- package/dist/commands/tools/selector.js +0 -53
- package/dist/commands/uninstall/index.d.ts +0 -3
- package/dist/commands/uninstall/index.js +0 -107
- package/dist/commands/uninstall/index.spec.d.ts +0 -1
- package/dist/commands/uninstall/index.spec.js +0 -117
- package/dist/commands/uninstall.d.ts +0 -2
- package/dist/commands/uninstall.js +0 -83
- package/dist/components/ChatUI.d.ts +0 -16
- package/dist/components/ChatUI.js +0 -801
- package/dist/components/StatusView.d.ts +0 -10
- package/dist/components/StatusView.js +0 -39
- package/dist/lib/arkApiClient.d.ts +0 -53
- package/dist/lib/arkApiClient.js +0 -102
- package/dist/lib/arkApiProxy.d.ts +0 -9
- package/dist/lib/arkApiProxy.js +0 -22
- package/dist/lib/arkServiceProxy.d.ts +0 -14
- package/dist/lib/arkServiceProxy.js +0 -95
- package/dist/lib/arkStatus.d.ts +0 -10
- package/dist/lib/arkStatus.js +0 -79
- package/dist/lib/arkStatus.spec.d.ts +0 -1
- package/dist/lib/arkStatus.spec.js +0 -49
- package/dist/lib/chatClient.d.ts +0 -33
- package/dist/lib/chatClient.js +0 -99
- package/dist/lib/cluster.spec.d.ts +0 -1
- package/dist/lib/cluster.spec.js +0 -338
- package/dist/lib/commandUtils.d.ts +0 -4
- package/dist/lib/commandUtils.js +0 -18
- package/dist/lib/commandUtils.test.d.ts +0 -1
- package/dist/lib/commandUtils.test.js +0 -44
- package/dist/lib/commands.d.ts +0 -16
- package/dist/lib/commands.js +0 -29
- package/dist/lib/commands.spec.d.ts +0 -1
- package/dist/lib/commands.spec.js +0 -146
- package/dist/lib/config.spec.d.ts +0 -1
- package/dist/lib/config.spec.js +0 -99
- package/dist/lib/config.test.d.ts +0 -1
- package/dist/lib/config.test.js +0 -93
- package/dist/lib/consts.spec.d.ts +0 -1
- package/dist/lib/consts.spec.js +0 -15
- package/dist/lib/dev/tools/analyzer.d.ts +0 -30
- package/dist/lib/dev/tools/analyzer.js +0 -190
- package/dist/lib/dev/tools/discover_tools.py +0 -392
- package/dist/lib/dev/tools/mcp-types.d.ts +0 -28
- package/dist/lib/dev/tools/mcp-types.js +0 -86
- package/dist/lib/dev/tools/types.d.ts +0 -50
- package/dist/lib/dev/tools/types.js +0 -1
- package/dist/lib/errors.spec.d.ts +0 -1
- package/dist/lib/errors.spec.js +0 -221
- package/dist/lib/output.d.ts +0 -36
- package/dist/lib/output.js +0 -89
- package/dist/lib/output.spec.d.ts +0 -1
- package/dist/lib/output.spec.js +0 -123
- package/dist/lib/portUtils.d.ts +0 -8
- package/dist/lib/portUtils.js +0 -39
- package/dist/lib/startup.d.ts +0 -5
- package/dist/lib/startup.js +0 -73
- package/dist/lib/startup.spec.d.ts +0 -1
- package/dist/lib/startup.spec.js +0 -168
- package/dist/types/types.d.ts +0 -40
- package/dist/types/types.js +0 -1
- package/dist/ui/AgentSelector.d.ts +0 -8
- package/dist/ui/AgentSelector.js +0 -53
- package/dist/ui/ModelSelector.d.ts +0 -8
- package/dist/ui/ModelSelector.js +0 -53
- package/dist/ui/TeamSelector.d.ts +0 -8
- package/dist/ui/TeamSelector.js +0 -55
- package/dist/ui/ToolSelector.d.ts +0 -8
- package/dist/ui/ToolSelector.js +0 -53
- package/dist/ui/statusFormatter.spec.d.ts +0 -1
- package/dist/ui/statusFormatter.spec.js +0 -58
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { StatusData } from '../lib/types.js';
|
|
3
|
-
interface StatusViewProps {
|
|
4
|
-
statusData: StatusData | null;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
error: string | null;
|
|
7
|
-
onBack: () => void;
|
|
8
|
-
}
|
|
9
|
-
declare const StatusView: React.FC<StatusViewProps>;
|
|
10
|
-
export default StatusView;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text, useInput } from 'ink';
|
|
3
|
-
const StatusView = ({ statusData, isLoading, error, onBack, }) => {
|
|
4
|
-
useInput((input, key) => {
|
|
5
|
-
if (key.escape || input === 'q' || key.return) {
|
|
6
|
-
onBack();
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
const renderServiceStatus = (service) => {
|
|
10
|
-
const statusColor = service.status === 'healthy'
|
|
11
|
-
? 'green'
|
|
12
|
-
: service.status === 'unhealthy'
|
|
13
|
-
? 'red'
|
|
14
|
-
: 'yellow';
|
|
15
|
-
const statusIcon = service.status === 'healthy'
|
|
16
|
-
? '✓'
|
|
17
|
-
: service.status === 'unhealthy'
|
|
18
|
-
? '✗'
|
|
19
|
-
: '?';
|
|
20
|
-
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsxs(Box, { children: [_jsxs(Text, { color: statusColor, children: [statusIcon, " "] }), _jsxs(Text, { bold: true, children: [service.name, ": "] }), _jsx(Text, { color: statusColor, children: service.status })] }), service.url && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "gray", children: ["URL: ", service.url] }) })), service.details && (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "gray", children: service.details }) }))] }, service.name));
|
|
21
|
-
};
|
|
22
|
-
const renderDependencyStatus = (dep) => {
|
|
23
|
-
const statusColor = dep.installed ? 'green' : 'red';
|
|
24
|
-
const statusIcon = dep.installed ? '✓' : '✗';
|
|
25
|
-
const statusText = dep.installed ? 'installed' : 'missing';
|
|
26
|
-
return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [_jsxs(Box, { children: [_jsxs(Text, { color: statusColor, children: [statusIcon, " "] }), _jsxs(Text, { bold: true, children: [dep.name, ": "] }), _jsx(Text, { color: statusColor, children: statusText })] }), dep.version && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "gray", children: ["Version: ", dep.version] }) })), dep.details && (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "gray", children: dep.details }) }))] }, dep.name));
|
|
27
|
-
};
|
|
28
|
-
if (isLoading) {
|
|
29
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "yellow", children: "\uD83D\uDD0D Checking ARK system status..." }), _jsx(Text, { color: "gray", children: "Please wait while we verify services and dependencies." })] }));
|
|
30
|
-
}
|
|
31
|
-
if (error) {
|
|
32
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "red", children: "\u274C Error checking status:" }), _jsx(Text, { color: "red", children: error }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Press ESC, 'q', or Enter to return to menu..." }) })] }));
|
|
33
|
-
}
|
|
34
|
-
if (!statusData) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: "\uD83D\uDD0D ARK System Status" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "cyan", bold: true, children: "\uD83D\uDCE1 ARK Services:" }) }), statusData.services.map(renderServiceStatus), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "cyan", bold: true, children: "\uD83D\uDEE0\uFE0F System Dependencies:" }) }), statusData.dependencies.map(renderDependencyStatus), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "Press ESC, 'q', or Enter to return to menu..." }) })] }));
|
|
38
|
-
};
|
|
39
|
-
export default StatusView;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import OpenAI from 'openai';
|
|
2
|
-
export interface QueryTarget {
|
|
3
|
-
id: string;
|
|
4
|
-
name: string;
|
|
5
|
-
type: 'agent' | 'model' | 'tool' | string;
|
|
6
|
-
description?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Agent {
|
|
9
|
-
name: string;
|
|
10
|
-
namespace: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
model_ref?: string;
|
|
13
|
-
prompt?: string;
|
|
14
|
-
status?: string;
|
|
15
|
-
annotations?: Record<string, string>;
|
|
16
|
-
}
|
|
17
|
-
export interface Model {
|
|
18
|
-
name: string;
|
|
19
|
-
namespace: string;
|
|
20
|
-
type: string;
|
|
21
|
-
model: string;
|
|
22
|
-
status: string;
|
|
23
|
-
annotations?: Record<string, string>;
|
|
24
|
-
}
|
|
25
|
-
export interface Tool {
|
|
26
|
-
name: string;
|
|
27
|
-
namespace: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
labels?: Record<string, string>;
|
|
30
|
-
annotations?: Record<string, string>;
|
|
31
|
-
}
|
|
32
|
-
export interface Team {
|
|
33
|
-
name: string;
|
|
34
|
-
namespace: string;
|
|
35
|
-
description?: string;
|
|
36
|
-
strategy?: string;
|
|
37
|
-
members_count?: number;
|
|
38
|
-
status?: string;
|
|
39
|
-
}
|
|
40
|
-
export declare class ArkApiClient {
|
|
41
|
-
private openai;
|
|
42
|
-
private baseUrl;
|
|
43
|
-
private namespace;
|
|
44
|
-
constructor(arkApiUrl: string, namespace?: string);
|
|
45
|
-
getBaseUrl(): string;
|
|
46
|
-
getQueryTargets(): Promise<QueryTarget[]>;
|
|
47
|
-
getAgents(): Promise<Agent[]>;
|
|
48
|
-
getModels(): Promise<Model[]>;
|
|
49
|
-
getTools(): Promise<Tool[]>;
|
|
50
|
-
getTeams(): Promise<Team[]>;
|
|
51
|
-
createChatCompletion(params: OpenAI.Chat.Completions.ChatCompletionCreateParams): Promise<OpenAI.Chat.Completions.ChatCompletion>;
|
|
52
|
-
createChatCompletionStream(params: OpenAI.Chat.Completions.ChatCompletionCreateParams): AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>;
|
|
53
|
-
}
|
package/dist/lib/arkApiClient.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import OpenAI from 'openai';
|
|
2
|
-
export class ArkApiClient {
|
|
3
|
-
constructor(arkApiUrl, namespace = 'default') {
|
|
4
|
-
this.baseUrl = arkApiUrl;
|
|
5
|
-
this.namespace = namespace;
|
|
6
|
-
this.openai = new OpenAI({
|
|
7
|
-
baseURL: `${arkApiUrl}/openai/v1`,
|
|
8
|
-
apiKey: 'dummy', // ark-api doesn't require an API key
|
|
9
|
-
dangerouslyAllowBrowser: false,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
getBaseUrl() {
|
|
13
|
-
return this.baseUrl;
|
|
14
|
-
}
|
|
15
|
-
async getQueryTargets() {
|
|
16
|
-
try {
|
|
17
|
-
const models = await this.openai.models.list();
|
|
18
|
-
const targets = models.data.map((model) => {
|
|
19
|
-
const parts = model.id.split('/');
|
|
20
|
-
const type = parts[0] || 'model';
|
|
21
|
-
const name = parts.slice(1).join('/') || model.id;
|
|
22
|
-
return {
|
|
23
|
-
id: model.id,
|
|
24
|
-
name,
|
|
25
|
-
type,
|
|
26
|
-
description: model.id,
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
return targets;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new Error(`Failed to get query targets: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async getAgents() {
|
|
36
|
-
try {
|
|
37
|
-
const response = await fetch(`${this.baseUrl}/v1/namespaces/${this.namespace}/agents`);
|
|
38
|
-
if (!response.ok) {
|
|
39
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
40
|
-
}
|
|
41
|
-
const data = (await response.json());
|
|
42
|
-
return data.items || [];
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
throw new Error(`Failed to get agents: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async getModels() {
|
|
49
|
-
try {
|
|
50
|
-
const response = await fetch(`${this.baseUrl}/v1/namespaces/${this.namespace}/models`);
|
|
51
|
-
if (!response.ok) {
|
|
52
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
53
|
-
}
|
|
54
|
-
const data = (await response.json());
|
|
55
|
-
return data.items || [];
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw new Error(`Failed to get models: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async getTools() {
|
|
62
|
-
try {
|
|
63
|
-
const response = await fetch(`${this.baseUrl}/v1/namespaces/${this.namespace}/tools`);
|
|
64
|
-
if (!response.ok) {
|
|
65
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
66
|
-
}
|
|
67
|
-
const data = (await response.json());
|
|
68
|
-
return data.items || [];
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
throw new Error(`Failed to get tools: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async getTeams() {
|
|
75
|
-
try {
|
|
76
|
-
const response = await fetch(`${this.baseUrl}/v1/namespaces/${this.namespace}/teams`);
|
|
77
|
-
if (!response.ok) {
|
|
78
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
79
|
-
}
|
|
80
|
-
const data = (await response.json());
|
|
81
|
-
return data.items || [];
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
throw new Error(`Failed to get teams: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async createChatCompletion(params) {
|
|
88
|
-
return (await this.openai.chat.completions.create({
|
|
89
|
-
...params,
|
|
90
|
-
stream: false,
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
async *createChatCompletionStream(params) {
|
|
94
|
-
const stream = await this.openai.chat.completions.create({
|
|
95
|
-
...params,
|
|
96
|
-
stream: true,
|
|
97
|
-
});
|
|
98
|
-
for await (const chunk of stream) {
|
|
99
|
-
yield chunk;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
package/dist/lib/arkApiProxy.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ArkApiClient } from './arkApiClient.js';
|
|
2
|
-
import { ArkServiceProxy } from './arkServiceProxy.js';
|
|
3
|
-
import { arkServices } from '../arkServices.js';
|
|
4
|
-
export class ArkApiProxy {
|
|
5
|
-
constructor(localPort) {
|
|
6
|
-
const arkApiService = arkServices['ark-api'];
|
|
7
|
-
this.serviceProxy = new ArkServiceProxy(arkApiService, localPort);
|
|
8
|
-
}
|
|
9
|
-
async start() {
|
|
10
|
-
const arkApiUrl = await this.serviceProxy.start();
|
|
11
|
-
return new ArkApiClient(arkApiUrl);
|
|
12
|
-
}
|
|
13
|
-
stop() {
|
|
14
|
-
this.serviceProxy.stop();
|
|
15
|
-
}
|
|
16
|
-
isRunning() {
|
|
17
|
-
return this.serviceProxy.isRunning();
|
|
18
|
-
}
|
|
19
|
-
getLocalUrl() {
|
|
20
|
-
return this.serviceProxy.getLocalUrl();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ArkService } from '../arkServices.js';
|
|
2
|
-
export declare class ArkServiceProxy {
|
|
3
|
-
private kubectlProcess?;
|
|
4
|
-
private localPort;
|
|
5
|
-
private isReady;
|
|
6
|
-
private service;
|
|
7
|
-
constructor(service: ArkService, localPort?: number);
|
|
8
|
-
private getRandomPort;
|
|
9
|
-
start(): Promise<string>;
|
|
10
|
-
stop(): void;
|
|
11
|
-
isRunning(): boolean;
|
|
12
|
-
getLocalUrl(): string;
|
|
13
|
-
getService(): ArkService;
|
|
14
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
export class ArkServiceProxy {
|
|
3
|
-
constructor(service, localPort) {
|
|
4
|
-
this.isReady = false;
|
|
5
|
-
this.service = service;
|
|
6
|
-
this.localPort =
|
|
7
|
-
localPort || service.k8sPortForwardLocalPort || this.getRandomPort();
|
|
8
|
-
}
|
|
9
|
-
getRandomPort() {
|
|
10
|
-
return Math.floor(Math.random() * (65535 - 1024) + 1024);
|
|
11
|
-
}
|
|
12
|
-
async start() {
|
|
13
|
-
if (!this.service.k8sServiceName || !this.service.k8sServicePort) {
|
|
14
|
-
throw new Error(`${this.service.name} service configuration missing k8sServiceName or k8sServicePort`);
|
|
15
|
-
}
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
const args = [
|
|
18
|
-
'port-forward',
|
|
19
|
-
`service/${this.service.k8sServiceName}`,
|
|
20
|
-
`${this.localPort}:${this.service.k8sServicePort}`,
|
|
21
|
-
];
|
|
22
|
-
// Add namespace flag only if namespace is defined
|
|
23
|
-
if (this.service.namespace) {
|
|
24
|
-
args.push('--namespace', this.service.namespace);
|
|
25
|
-
}
|
|
26
|
-
this.kubectlProcess = spawn('kubectl', args, {
|
|
27
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
28
|
-
});
|
|
29
|
-
let setupComplete = false;
|
|
30
|
-
const setupTimeout = setTimeout(() => {
|
|
31
|
-
if (!setupComplete) {
|
|
32
|
-
this.stop();
|
|
33
|
-
reject(new Error(`${this.service.name} port forward setup timeout`));
|
|
34
|
-
}
|
|
35
|
-
}, 10000);
|
|
36
|
-
this.kubectlProcess.stdout?.on('data', (data) => {
|
|
37
|
-
const output = data.toString();
|
|
38
|
-
if (output.includes('Forwarding from') && !setupComplete) {
|
|
39
|
-
setupComplete = true;
|
|
40
|
-
clearTimeout(setupTimeout);
|
|
41
|
-
this.isReady = true;
|
|
42
|
-
const localUrl = `http://localhost:${this.localPort}`;
|
|
43
|
-
resolve(localUrl);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
this.kubectlProcess.stderr?.on('data', (data) => {
|
|
47
|
-
const errorOutput = data.toString();
|
|
48
|
-
if (!setupComplete) {
|
|
49
|
-
setupComplete = true;
|
|
50
|
-
clearTimeout(setupTimeout);
|
|
51
|
-
this.stop();
|
|
52
|
-
reject(new Error(`${this.service.name} port forward failed: ${errorOutput.trim()}`));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
this.kubectlProcess.on('error', (error) => {
|
|
56
|
-
if (!setupComplete) {
|
|
57
|
-
setupComplete = true;
|
|
58
|
-
clearTimeout(setupTimeout);
|
|
59
|
-
reject(new Error(`Failed to start ${this.service.name} port forward: ${error.message}`));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
this.kubectlProcess.on('exit', (code) => {
|
|
63
|
-
this.isReady = false;
|
|
64
|
-
if (!setupComplete && code !== 0) {
|
|
65
|
-
setupComplete = true;
|
|
66
|
-
clearTimeout(setupTimeout);
|
|
67
|
-
reject(new Error(`${this.service.name} port forward exited with code ${code}`));
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
stop() {
|
|
73
|
-
if (this.kubectlProcess) {
|
|
74
|
-
// Use SIGTERM for graceful shutdown
|
|
75
|
-
this.kubectlProcess.kill('SIGTERM');
|
|
76
|
-
// Give it a second to clean up, then force kill if needed
|
|
77
|
-
setTimeout(() => {
|
|
78
|
-
if (this.kubectlProcess && !this.kubectlProcess.killed) {
|
|
79
|
-
this.kubectlProcess.kill('SIGKILL');
|
|
80
|
-
}
|
|
81
|
-
}, 1000);
|
|
82
|
-
this.kubectlProcess = undefined;
|
|
83
|
-
}
|
|
84
|
-
this.isReady = false;
|
|
85
|
-
}
|
|
86
|
-
isRunning() {
|
|
87
|
-
return this.isReady && this.kubectlProcess !== undefined;
|
|
88
|
-
}
|
|
89
|
-
getLocalUrl() {
|
|
90
|
-
return `http://localhost:${this.localPort}`;
|
|
91
|
-
}
|
|
92
|
-
getService() {
|
|
93
|
-
return this.service;
|
|
94
|
-
}
|
|
95
|
-
}
|
package/dist/lib/arkStatus.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get current installed ARK version
|
|
3
|
-
* @returns version string if found, undefined otherwise
|
|
4
|
-
*/
|
|
5
|
-
export declare function getArkVersion(): Promise<string | undefined>;
|
|
6
|
-
/**
|
|
7
|
-
* Check if ARK is ready by verifying the ark-controller is running
|
|
8
|
-
* @returns true if ark-controller deployment exists and has ready replicas
|
|
9
|
-
*/
|
|
10
|
-
export declare function isArkReady(): Promise<boolean>;
|
package/dist/lib/arkStatus.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
import { arkServices } from '../arkServices.js';
|
|
3
|
-
/**
|
|
4
|
-
* Get current installed ARK version
|
|
5
|
-
* @returns version string if found, undefined otherwise
|
|
6
|
-
*/
|
|
7
|
-
export async function getArkVersion() {
|
|
8
|
-
try {
|
|
9
|
-
const controller = arkServices['ark-controller'];
|
|
10
|
-
const { stdout } = await execa('helm', ['list', '-n', controller.namespace, '-o', 'json'], { stdio: 'pipe' });
|
|
11
|
-
const releases = JSON.parse(stdout);
|
|
12
|
-
const arkController = releases.find((r) => r.name === controller.helmReleaseName);
|
|
13
|
-
return arkController?.app_version;
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Check if ARK is ready by verifying the ark-controller is running
|
|
21
|
-
* @returns true if ark-controller deployment exists and has ready replicas
|
|
22
|
-
*/
|
|
23
|
-
export async function isArkReady() {
|
|
24
|
-
try {
|
|
25
|
-
// Check if ark-controller deployment exists and get its status
|
|
26
|
-
const result = await execa('kubectl', ['get', 'deployment', 'ark-controller', '-n', 'ark-system', '-o', 'json'], { stdio: 'pipe' });
|
|
27
|
-
const deployment = JSON.parse(result.stdout);
|
|
28
|
-
const readyReplicas = deployment.status?.readyReplicas || 0;
|
|
29
|
-
const replicas = deployment.spec?.replicas || 0;
|
|
30
|
-
// If main deployment has 0 replicas, check devspace deployment
|
|
31
|
-
if (replicas === 0) {
|
|
32
|
-
try {
|
|
33
|
-
const devResult = await execa('kubectl', [
|
|
34
|
-
'get',
|
|
35
|
-
'deployment',
|
|
36
|
-
'ark-controller-devspace',
|
|
37
|
-
'-n',
|
|
38
|
-
'ark-system',
|
|
39
|
-
'-o',
|
|
40
|
-
'json',
|
|
41
|
-
], { stdio: 'pipe' });
|
|
42
|
-
const devDeployment = JSON.parse(devResult.stdout);
|
|
43
|
-
const devReadyReplicas = devDeployment.status?.readyReplicas || 0;
|
|
44
|
-
const devReplicas = devDeployment.spec?.replicas || 0;
|
|
45
|
-
// ARK is ready if devspace deployment has ready replicas
|
|
46
|
-
return devReadyReplicas > 0 && devReadyReplicas === devReplicas;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// Devspace deployment doesn't exist
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// ARK is ready if deployment exists and has at least one ready replica
|
|
54
|
-
return readyReplicas > 0 && readyReplicas === replicas;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
// Main deployment doesn't exist, try devspace deployment
|
|
58
|
-
try {
|
|
59
|
-
const devResult = await execa('kubectl', [
|
|
60
|
-
'get',
|
|
61
|
-
'deployment',
|
|
62
|
-
'ark-controller-devspace',
|
|
63
|
-
'-n',
|
|
64
|
-
'ark-system',
|
|
65
|
-
'-o',
|
|
66
|
-
'json',
|
|
67
|
-
], { stdio: 'pipe' });
|
|
68
|
-
const devDeployment = JSON.parse(devResult.stdout);
|
|
69
|
-
const devReadyReplicas = devDeployment.status?.readyReplicas || 0;
|
|
70
|
-
const devReplicas = devDeployment.spec?.replicas || 0;
|
|
71
|
-
// ARK is ready if devspace deployment has ready replicas
|
|
72
|
-
return devReadyReplicas > 0 && devReadyReplicas === devReplicas;
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
// Neither deployment exists or kubectl failed
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, jest, beforeEach } from '@jest/globals';
|
|
2
|
-
// Mock execa using unstable_mockModule
|
|
3
|
-
jest.unstable_mockModule('execa', () => ({
|
|
4
|
-
execa: jest.fn(),
|
|
5
|
-
}));
|
|
6
|
-
// Dynamic imports after mock
|
|
7
|
-
const { execa } = await import('execa');
|
|
8
|
-
const { isArkReady } = await import('./arkStatus.js');
|
|
9
|
-
describe('arkStatus with __mocks__', () => {
|
|
10
|
-
describe('isArkReady', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
jest.clearAllMocks();
|
|
13
|
-
});
|
|
14
|
-
it('should return true when ark-controller is deployed and ready', async () => {
|
|
15
|
-
// Mock successful kubectl response with ready deployment
|
|
16
|
-
const mockDeployment = {
|
|
17
|
-
metadata: { name: 'ark-controller' },
|
|
18
|
-
spec: { replicas: 3 },
|
|
19
|
-
status: {
|
|
20
|
-
readyReplicas: 3,
|
|
21
|
-
availableReplicas: 3,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
execa.mockResolvedValue({
|
|
25
|
-
stdout: JSON.stringify(mockDeployment),
|
|
26
|
-
stderr: '',
|
|
27
|
-
exitCode: 0,
|
|
28
|
-
failed: false,
|
|
29
|
-
});
|
|
30
|
-
const result = await isArkReady();
|
|
31
|
-
expect(result).toBe(true);
|
|
32
|
-
expect(execa).toHaveBeenCalledWith('kubectl', [
|
|
33
|
-
'get',
|
|
34
|
-
'deployment',
|
|
35
|
-
'ark-controller',
|
|
36
|
-
'-n',
|
|
37
|
-
'ark-system',
|
|
38
|
-
'-o',
|
|
39
|
-
'json',
|
|
40
|
-
], { stdio: 'pipe' });
|
|
41
|
-
});
|
|
42
|
-
it('should return false when kubectl fails', async () => {
|
|
43
|
-
// Mock kubectl failure
|
|
44
|
-
execa.mockRejectedValue(new Error('kubectl not found'));
|
|
45
|
-
const result = await isArkReady();
|
|
46
|
-
expect(result).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
package/dist/lib/chatClient.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ArkApiClient, QueryTarget } from './arkApiClient.js';
|
|
2
|
-
export { QueryTarget };
|
|
3
|
-
export interface ChatConfig {
|
|
4
|
-
streamingEnabled: boolean;
|
|
5
|
-
currentTarget?: QueryTarget;
|
|
6
|
-
}
|
|
7
|
-
export interface ToolCall {
|
|
8
|
-
id: string;
|
|
9
|
-
type: 'function';
|
|
10
|
-
function: {
|
|
11
|
-
name: string;
|
|
12
|
-
arguments: string;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface ArkMetadata {
|
|
16
|
-
agent?: string;
|
|
17
|
-
team?: string;
|
|
18
|
-
model?: string;
|
|
19
|
-
query?: string;
|
|
20
|
-
target?: string;
|
|
21
|
-
}
|
|
22
|
-
export declare class ChatClient {
|
|
23
|
-
private arkApiClient;
|
|
24
|
-
constructor(arkApiClient: ArkApiClient);
|
|
25
|
-
getQueryTargets(): Promise<QueryTarget[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Send a chat completion request
|
|
28
|
-
*/
|
|
29
|
-
sendMessage(targetId: string, messages: Array<{
|
|
30
|
-
role: 'user' | 'assistant' | 'system';
|
|
31
|
-
content: string;
|
|
32
|
-
}>, config: ChatConfig, onChunk?: (chunk: string, toolCalls?: ToolCall[], arkMetadata?: ArkMetadata) => void, signal?: AbortSignal): Promise<string>;
|
|
33
|
-
}
|
package/dist/lib/chatClient.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
export class ChatClient {
|
|
2
|
-
constructor(arkApiClient) {
|
|
3
|
-
this.arkApiClient = arkApiClient;
|
|
4
|
-
}
|
|
5
|
-
async getQueryTargets() {
|
|
6
|
-
return await this.arkApiClient.getQueryTargets();
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Send a chat completion request
|
|
10
|
-
*/
|
|
11
|
-
async sendMessage(targetId, messages, config, onChunk, signal) {
|
|
12
|
-
const shouldStream = config.streamingEnabled && !!onChunk;
|
|
13
|
-
try {
|
|
14
|
-
const params = {
|
|
15
|
-
model: targetId,
|
|
16
|
-
messages: messages,
|
|
17
|
-
signal: signal,
|
|
18
|
-
};
|
|
19
|
-
if (shouldStream) {
|
|
20
|
-
let fullResponse = '';
|
|
21
|
-
const toolCallsById = new Map();
|
|
22
|
-
const stream = this.arkApiClient.createChatCompletionStream(params);
|
|
23
|
-
for await (const chunk of stream) {
|
|
24
|
-
if (signal?.aborted) {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
const delta = chunk.choices[0]?.delta;
|
|
28
|
-
// Extract ARK metadata if present
|
|
29
|
-
const arkMetadata = chunk.ark;
|
|
30
|
-
// Handle regular content
|
|
31
|
-
const content = delta?.content || '';
|
|
32
|
-
if (content) {
|
|
33
|
-
fullResponse += content;
|
|
34
|
-
if (onChunk) {
|
|
35
|
-
onChunk(content, undefined, arkMetadata);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// Handle tool calls
|
|
39
|
-
if (delta?.tool_calls) {
|
|
40
|
-
for (const toolCallDelta of delta.tool_calls) {
|
|
41
|
-
const index = toolCallDelta.index;
|
|
42
|
-
// Initialize tool call if this is the first chunk for this index
|
|
43
|
-
if (!toolCallsById.has(index)) {
|
|
44
|
-
toolCallsById.set(index, {
|
|
45
|
-
id: toolCallDelta.id || '',
|
|
46
|
-
type: toolCallDelta.type || 'function',
|
|
47
|
-
function: {
|
|
48
|
-
name: toolCallDelta.function?.name || '',
|
|
49
|
-
arguments: '',
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// Accumulate function arguments
|
|
54
|
-
const toolCall = toolCallsById.get(index);
|
|
55
|
-
if (toolCallDelta.function?.arguments) {
|
|
56
|
-
toolCall.function.arguments += toolCallDelta.function.arguments;
|
|
57
|
-
}
|
|
58
|
-
// Send the current state of all tool calls
|
|
59
|
-
if (onChunk) {
|
|
60
|
-
const toolCallsArray = Array.from(toolCallsById.values());
|
|
61
|
-
onChunk('', toolCallsArray, arkMetadata);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return fullResponse;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const response = await this.arkApiClient.createChatCompletion(params);
|
|
70
|
-
const message = response.choices[0]?.message;
|
|
71
|
-
const content = message?.content || '';
|
|
72
|
-
// Handle tool calls in non-streaming mode
|
|
73
|
-
if (message?.tool_calls && message.tool_calls.length > 0) {
|
|
74
|
-
const toolCalls = message.tool_calls.map((tc) => ({
|
|
75
|
-
id: tc.id,
|
|
76
|
-
type: tc.type || 'function',
|
|
77
|
-
function: {
|
|
78
|
-
name: tc.function?.name || '',
|
|
79
|
-
arguments: tc.function?.arguments || '',
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
// Send tool calls first
|
|
83
|
-
if (onChunk) {
|
|
84
|
-
onChunk('', toolCalls);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// Send content after tool calls
|
|
88
|
-
if (content && onChunk) {
|
|
89
|
-
onChunk(content);
|
|
90
|
-
}
|
|
91
|
-
return content;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
// Don't log here - error will be displayed in the message thread
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|