@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.
Files changed (207) hide show
  1. package/dist/commands/cluster/index.d.ts +1 -2
  2. package/dist/commands/cluster/index.js +5 -3
  3. package/dist/commands/completion.js +2 -159
  4. package/dist/commands/config.d.ts +3 -0
  5. package/dist/commands/config.js +321 -38
  6. package/dist/commands/generate/config.js +24 -5
  7. package/dist/commands/generate/generators/agent.js +2 -2
  8. package/dist/commands/generate/generators/mcpserver.d.ts +1 -2
  9. package/dist/commands/generate/generators/mcpserver.js +5 -26
  10. package/dist/commands/generate/generators/project.js +41 -22
  11. package/dist/commands/generate/generators/team.js +2 -2
  12. package/dist/commands/generate/index.d.ts +1 -2
  13. package/dist/commands/generate/index.js +1 -1
  14. package/dist/components/statusChecker.d.ts +23 -13
  15. package/dist/components/statusChecker.js +129 -275
  16. package/dist/config.d.ts +22 -3
  17. package/dist/config.js +161 -10
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +42 -40
  20. package/dist/lib/cluster.d.ts +1 -2
  21. package/dist/lib/cluster.js +16 -37
  22. package/dist/lib/config.d.ts +80 -26
  23. package/dist/lib/config.js +205 -70
  24. package/dist/lib/consts.d.ts +1 -0
  25. package/dist/lib/consts.js +2 -0
  26. package/dist/lib/errors.js +1 -1
  27. package/dist/lib/exec.d.ts +4 -0
  28. package/dist/lib/exec.js +11 -0
  29. package/dist/lib/types.d.ts +3 -10
  30. package/dist/ui/MainMenu.d.ts +1 -5
  31. package/dist/ui/MainMenu.js +91 -222
  32. package/dist/ui/statusFormatter.d.ts +7 -22
  33. package/dist/ui/statusFormatter.js +39 -39
  34. package/package.json +5 -17
  35. package/dist/arkServices.d.ts +0 -42
  36. package/dist/arkServices.js +0 -138
  37. package/dist/arkServices.spec.d.ts +0 -1
  38. package/dist/arkServices.spec.js +0 -24
  39. package/dist/charts/charts.d.ts +0 -5
  40. package/dist/charts/charts.js +0 -6
  41. package/dist/charts/dependencies.d.ts +0 -6
  42. package/dist/charts/dependencies.js +0 -50
  43. package/dist/charts/types.d.ts +0 -40
  44. package/dist/charts/types.js +0 -1
  45. package/dist/commands/agents/index.d.ts +0 -3
  46. package/dist/commands/agents/index.js +0 -51
  47. package/dist/commands/agents/index.spec.d.ts +0 -1
  48. package/dist/commands/agents/index.spec.js +0 -67
  49. package/dist/commands/agents/selector.d.ts +0 -8
  50. package/dist/commands/agents/selector.js +0 -53
  51. package/dist/commands/agents.d.ts +0 -2
  52. package/dist/commands/agents.js +0 -53
  53. package/dist/commands/chat/index.d.ts +0 -3
  54. package/dist/commands/chat/index.js +0 -29
  55. package/dist/commands/chat.d.ts +0 -2
  56. package/dist/commands/chat.js +0 -45
  57. package/dist/commands/cluster/get.d.ts +0 -2
  58. package/dist/commands/cluster/get.js +0 -39
  59. package/dist/commands/cluster/get.spec.d.ts +0 -1
  60. package/dist/commands/cluster/get.spec.js +0 -92
  61. package/dist/commands/cluster/index.spec.d.ts +0 -1
  62. package/dist/commands/cluster/index.spec.js +0 -24
  63. package/dist/commands/completion/index.d.ts +0 -3
  64. package/dist/commands/completion/index.js +0 -268
  65. package/dist/commands/completion/index.spec.d.ts +0 -1
  66. package/dist/commands/completion/index.spec.js +0 -34
  67. package/dist/commands/config/index.d.ts +0 -3
  68. package/dist/commands/config/index.js +0 -42
  69. package/dist/commands/config/index.spec.d.ts +0 -1
  70. package/dist/commands/config/index.spec.js +0 -78
  71. package/dist/commands/dashboard/index.d.ts +0 -4
  72. package/dist/commands/dashboard/index.js +0 -39
  73. package/dist/commands/dashboard.d.ts +0 -3
  74. package/dist/commands/dashboard.js +0 -39
  75. package/dist/commands/dev/index.d.ts +0 -3
  76. package/dist/commands/dev/index.js +0 -9
  77. package/dist/commands/dev/tool/check.d.ts +0 -2
  78. package/dist/commands/dev/tool/check.js +0 -142
  79. package/dist/commands/dev/tool/clean.d.ts +0 -2
  80. package/dist/commands/dev/tool/clean.js +0 -153
  81. package/dist/commands/dev/tool/generate.d.ts +0 -2
  82. package/dist/commands/dev/tool/generate.js +0 -28
  83. package/dist/commands/dev/tool/index.d.ts +0 -2
  84. package/dist/commands/dev/tool/index.js +0 -14
  85. package/dist/commands/dev/tool/init.d.ts +0 -2
  86. package/dist/commands/dev/tool/init.js +0 -320
  87. package/dist/commands/dev/tool/shared.d.ts +0 -5
  88. package/dist/commands/dev/tool/shared.js +0 -256
  89. package/dist/commands/dev/tool/status.d.ts +0 -2
  90. package/dist/commands/dev/tool/status.js +0 -136
  91. package/dist/commands/dev/tool-generate.spec.d.ts +0 -1
  92. package/dist/commands/dev/tool-generate.spec.js +0 -163
  93. package/dist/commands/dev/tool.d.ts +0 -2
  94. package/dist/commands/dev/tool.js +0 -559
  95. package/dist/commands/dev/tool.spec.d.ts +0 -1
  96. package/dist/commands/dev/tool.spec.js +0 -48
  97. package/dist/commands/install/index.d.ts +0 -8
  98. package/dist/commands/install/index.js +0 -302
  99. package/dist/commands/install/index.spec.d.ts +0 -1
  100. package/dist/commands/install/index.spec.js +0 -135
  101. package/dist/commands/install.d.ts +0 -3
  102. package/dist/commands/install.js +0 -147
  103. package/dist/commands/models/create.d.ts +0 -1
  104. package/dist/commands/models/create.js +0 -213
  105. package/dist/commands/models/create.spec.d.ts +0 -1
  106. package/dist/commands/models/create.spec.js +0 -125
  107. package/dist/commands/models/index.d.ts +0 -3
  108. package/dist/commands/models/index.js +0 -60
  109. package/dist/commands/models/index.spec.d.ts +0 -1
  110. package/dist/commands/models/index.spec.js +0 -76
  111. package/dist/commands/models/selector.d.ts +0 -8
  112. package/dist/commands/models/selector.js +0 -53
  113. package/dist/commands/routes/index.d.ts +0 -3
  114. package/dist/commands/routes/index.js +0 -93
  115. package/dist/commands/routes.d.ts +0 -2
  116. package/dist/commands/routes.js +0 -101
  117. package/dist/commands/status/index.d.ts +0 -4
  118. package/dist/commands/status/index.js +0 -232
  119. package/dist/commands/status.d.ts +0 -3
  120. package/dist/commands/status.js +0 -33
  121. package/dist/commands/targets/index.d.ts +0 -3
  122. package/dist/commands/targets/index.js +0 -65
  123. package/dist/commands/targets/index.spec.d.ts +0 -1
  124. package/dist/commands/targets/index.spec.js +0 -105
  125. package/dist/commands/targets.d.ts +0 -2
  126. package/dist/commands/targets.js +0 -65
  127. package/dist/commands/teams/index.d.ts +0 -3
  128. package/dist/commands/teams/index.js +0 -49
  129. package/dist/commands/teams/index.spec.d.ts +0 -1
  130. package/dist/commands/teams/index.spec.js +0 -70
  131. package/dist/commands/teams/selector.d.ts +0 -8
  132. package/dist/commands/teams/selector.js +0 -55
  133. package/dist/commands/tools/index.d.ts +0 -3
  134. package/dist/commands/tools/index.js +0 -49
  135. package/dist/commands/tools/index.spec.d.ts +0 -1
  136. package/dist/commands/tools/index.spec.js +0 -70
  137. package/dist/commands/tools/selector.d.ts +0 -8
  138. package/dist/commands/tools/selector.js +0 -53
  139. package/dist/commands/uninstall/index.d.ts +0 -3
  140. package/dist/commands/uninstall/index.js +0 -107
  141. package/dist/commands/uninstall/index.spec.d.ts +0 -1
  142. package/dist/commands/uninstall/index.spec.js +0 -117
  143. package/dist/commands/uninstall.d.ts +0 -2
  144. package/dist/commands/uninstall.js +0 -83
  145. package/dist/components/ChatUI.d.ts +0 -16
  146. package/dist/components/ChatUI.js +0 -801
  147. package/dist/components/StatusView.d.ts +0 -10
  148. package/dist/components/StatusView.js +0 -39
  149. package/dist/lib/arkApiClient.d.ts +0 -53
  150. package/dist/lib/arkApiClient.js +0 -102
  151. package/dist/lib/arkApiProxy.d.ts +0 -9
  152. package/dist/lib/arkApiProxy.js +0 -22
  153. package/dist/lib/arkServiceProxy.d.ts +0 -14
  154. package/dist/lib/arkServiceProxy.js +0 -95
  155. package/dist/lib/arkStatus.d.ts +0 -10
  156. package/dist/lib/arkStatus.js +0 -79
  157. package/dist/lib/arkStatus.spec.d.ts +0 -1
  158. package/dist/lib/arkStatus.spec.js +0 -49
  159. package/dist/lib/chatClient.d.ts +0 -33
  160. package/dist/lib/chatClient.js +0 -99
  161. package/dist/lib/cluster.spec.d.ts +0 -1
  162. package/dist/lib/cluster.spec.js +0 -338
  163. package/dist/lib/commandUtils.d.ts +0 -4
  164. package/dist/lib/commandUtils.js +0 -18
  165. package/dist/lib/commandUtils.test.d.ts +0 -1
  166. package/dist/lib/commandUtils.test.js +0 -44
  167. package/dist/lib/commands.d.ts +0 -16
  168. package/dist/lib/commands.js +0 -29
  169. package/dist/lib/commands.spec.d.ts +0 -1
  170. package/dist/lib/commands.spec.js +0 -146
  171. package/dist/lib/config.spec.d.ts +0 -1
  172. package/dist/lib/config.spec.js +0 -99
  173. package/dist/lib/config.test.d.ts +0 -1
  174. package/dist/lib/config.test.js +0 -93
  175. package/dist/lib/consts.spec.d.ts +0 -1
  176. package/dist/lib/consts.spec.js +0 -15
  177. package/dist/lib/dev/tools/analyzer.d.ts +0 -30
  178. package/dist/lib/dev/tools/analyzer.js +0 -190
  179. package/dist/lib/dev/tools/discover_tools.py +0 -392
  180. package/dist/lib/dev/tools/mcp-types.d.ts +0 -28
  181. package/dist/lib/dev/tools/mcp-types.js +0 -86
  182. package/dist/lib/dev/tools/types.d.ts +0 -50
  183. package/dist/lib/dev/tools/types.js +0 -1
  184. package/dist/lib/errors.spec.d.ts +0 -1
  185. package/dist/lib/errors.spec.js +0 -221
  186. package/dist/lib/output.d.ts +0 -36
  187. package/dist/lib/output.js +0 -89
  188. package/dist/lib/output.spec.d.ts +0 -1
  189. package/dist/lib/output.spec.js +0 -123
  190. package/dist/lib/portUtils.d.ts +0 -8
  191. package/dist/lib/portUtils.js +0 -39
  192. package/dist/lib/startup.d.ts +0 -5
  193. package/dist/lib/startup.js +0 -73
  194. package/dist/lib/startup.spec.d.ts +0 -1
  195. package/dist/lib/startup.spec.js +0 -168
  196. package/dist/types/types.d.ts +0 -40
  197. package/dist/types/types.js +0 -1
  198. package/dist/ui/AgentSelector.d.ts +0 -8
  199. package/dist/ui/AgentSelector.js +0 -53
  200. package/dist/ui/ModelSelector.d.ts +0 -8
  201. package/dist/ui/ModelSelector.js +0 -53
  202. package/dist/ui/TeamSelector.d.ts +0 -8
  203. package/dist/ui/TeamSelector.js +0 -55
  204. package/dist/ui/ToolSelector.d.ts +0 -8
  205. package/dist/ui/ToolSelector.js +0 -53
  206. package/dist/ui/statusFormatter.spec.d.ts +0 -1
  207. 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
- }
@@ -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
- }
@@ -1,9 +0,0 @@
1
- import { ArkApiClient } from './arkApiClient.js';
2
- export declare class ArkApiProxy {
3
- private serviceProxy;
4
- constructor(localPort?: number);
5
- start(): Promise<ArkApiClient>;
6
- stop(): void;
7
- isRunning(): boolean;
8
- getLocalUrl(): string;
9
- }
@@ -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
- }
@@ -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>;
@@ -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
- });
@@ -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
- }
@@ -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 {};