@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.
Files changed (167) hide show
  1. package/dist/arkServices.d.ts +42 -0
  2. package/dist/arkServices.js +138 -0
  3. package/dist/arkServices.spec.d.ts +1 -0
  4. package/dist/arkServices.spec.js +24 -0
  5. package/dist/commands/agents/index.d.ts +3 -0
  6. package/dist/commands/agents/index.js +65 -0
  7. package/dist/commands/agents/index.spec.d.ts +1 -0
  8. package/dist/commands/agents/index.spec.js +67 -0
  9. package/dist/commands/chat/index.d.ts +3 -0
  10. package/dist/commands/chat/index.js +29 -0
  11. package/dist/commands/cluster/get.d.ts +2 -0
  12. package/dist/commands/cluster/get.js +39 -0
  13. package/dist/commands/cluster/get.spec.d.ts +1 -0
  14. package/dist/commands/cluster/get.spec.js +92 -0
  15. package/dist/commands/cluster/index.d.ts +2 -1
  16. package/dist/commands/cluster/index.js +3 -5
  17. package/dist/commands/cluster/index.spec.d.ts +1 -0
  18. package/dist/commands/cluster/index.spec.js +24 -0
  19. package/dist/commands/completion/index.d.ts +3 -0
  20. package/dist/commands/completion/index.js +230 -0
  21. package/dist/commands/completion/index.spec.d.ts +1 -0
  22. package/dist/commands/completion/index.spec.js +34 -0
  23. package/dist/commands/config/index.d.ts +3 -0
  24. package/dist/commands/config/index.js +42 -0
  25. package/dist/commands/config/index.spec.d.ts +1 -0
  26. package/dist/commands/config/index.spec.js +78 -0
  27. package/dist/commands/dashboard/index.d.ts +4 -0
  28. package/dist/commands/dashboard/index.js +39 -0
  29. package/dist/commands/docs/index.d.ts +4 -0
  30. package/dist/commands/docs/index.js +18 -0
  31. package/dist/commands/generate/config.js +5 -24
  32. package/dist/commands/generate/generators/mcpserver.d.ts +2 -1
  33. package/dist/commands/generate/generators/mcpserver.js +26 -5
  34. package/dist/commands/generate/generators/project.js +22 -41
  35. package/dist/commands/generate/index.d.ts +2 -1
  36. package/dist/commands/generate/index.js +1 -1
  37. package/dist/commands/install/index.d.ts +8 -0
  38. package/dist/commands/install/index.js +295 -0
  39. package/dist/commands/install/index.spec.d.ts +1 -0
  40. package/dist/commands/install/index.spec.js +143 -0
  41. package/dist/commands/models/create.d.ts +1 -0
  42. package/dist/commands/models/create.js +213 -0
  43. package/dist/commands/models/create.spec.d.ts +1 -0
  44. package/dist/commands/models/create.spec.js +125 -0
  45. package/dist/commands/models/index.d.ts +3 -0
  46. package/dist/commands/models/index.js +75 -0
  47. package/dist/commands/models/index.spec.d.ts +1 -0
  48. package/dist/commands/models/index.spec.js +96 -0
  49. package/dist/commands/query/index.d.ts +3 -0
  50. package/dist/commands/query/index.js +24 -0
  51. package/dist/commands/query/index.spec.d.ts +1 -0
  52. package/dist/commands/query/index.spec.js +53 -0
  53. package/dist/commands/routes/index.d.ts +3 -0
  54. package/dist/commands/routes/index.js +93 -0
  55. package/dist/commands/status/index.d.ts +3 -0
  56. package/dist/commands/status/index.js +281 -0
  57. package/dist/commands/targets/index.d.ts +3 -0
  58. package/dist/commands/targets/index.js +72 -0
  59. package/dist/commands/targets/index.spec.d.ts +1 -0
  60. package/dist/commands/targets/index.spec.js +154 -0
  61. package/dist/commands/teams/index.d.ts +3 -0
  62. package/dist/commands/teams/index.js +64 -0
  63. package/dist/commands/teams/index.spec.d.ts +1 -0
  64. package/dist/commands/teams/index.spec.js +70 -0
  65. package/dist/commands/tools/index.d.ts +3 -0
  66. package/dist/commands/tools/index.js +49 -0
  67. package/dist/commands/tools/index.spec.d.ts +1 -0
  68. package/dist/commands/tools/index.spec.js +70 -0
  69. package/dist/commands/uninstall/index.d.ts +3 -0
  70. package/dist/commands/uninstall/index.js +101 -0
  71. package/dist/commands/uninstall/index.spec.d.ts +1 -0
  72. package/dist/commands/uninstall/index.spec.js +125 -0
  73. package/dist/components/ChatUI.d.ts +16 -0
  74. package/dist/components/ChatUI.js +801 -0
  75. package/dist/components/statusChecker.d.ts +14 -24
  76. package/dist/components/statusChecker.js +295 -129
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.js +42 -42
  79. package/dist/lib/arkApiClient.d.ts +53 -0
  80. package/dist/lib/arkApiClient.js +102 -0
  81. package/dist/lib/arkApiProxy.d.ts +9 -0
  82. package/dist/lib/arkApiProxy.js +22 -0
  83. package/dist/lib/arkServiceProxy.d.ts +14 -0
  84. package/dist/lib/arkServiceProxy.js +95 -0
  85. package/dist/lib/arkStatus.d.ts +10 -0
  86. package/dist/lib/arkStatus.js +79 -0
  87. package/dist/lib/arkStatus.spec.d.ts +1 -0
  88. package/dist/lib/arkStatus.spec.js +49 -0
  89. package/dist/lib/chatClient.d.ts +33 -0
  90. package/dist/lib/chatClient.js +93 -0
  91. package/dist/lib/cluster.d.ts +2 -1
  92. package/dist/lib/cluster.js +37 -16
  93. package/dist/lib/cluster.spec.d.ts +1 -0
  94. package/dist/lib/cluster.spec.js +338 -0
  95. package/dist/lib/commands.d.ts +16 -0
  96. package/dist/lib/commands.js +29 -0
  97. package/dist/lib/commands.spec.d.ts +1 -0
  98. package/dist/lib/commands.spec.js +146 -0
  99. package/dist/lib/config.d.ts +26 -80
  100. package/dist/lib/config.js +70 -205
  101. package/dist/lib/config.spec.d.ts +1 -0
  102. package/dist/lib/config.spec.js +99 -0
  103. package/dist/lib/errors.js +1 -1
  104. package/dist/lib/errors.spec.d.ts +1 -0
  105. package/dist/lib/errors.spec.js +221 -0
  106. package/dist/lib/executeQuery.d.ts +20 -0
  107. package/dist/lib/executeQuery.js +135 -0
  108. package/dist/lib/executeQuery.spec.d.ts +1 -0
  109. package/dist/lib/executeQuery.spec.js +170 -0
  110. package/dist/lib/nextSteps.d.ts +4 -0
  111. package/dist/lib/nextSteps.js +20 -0
  112. package/dist/lib/nextSteps.spec.d.ts +1 -0
  113. package/dist/lib/nextSteps.spec.js +59 -0
  114. package/dist/lib/output.d.ts +36 -0
  115. package/dist/lib/output.js +89 -0
  116. package/dist/lib/output.spec.d.ts +1 -0
  117. package/dist/lib/output.spec.js +123 -0
  118. package/dist/lib/startup.d.ts +9 -0
  119. package/dist/lib/startup.js +87 -0
  120. package/dist/lib/startup.spec.d.ts +1 -0
  121. package/dist/lib/startup.spec.js +152 -0
  122. package/dist/lib/types.d.ts +87 -3
  123. package/dist/lib/versions.d.ts +23 -0
  124. package/dist/lib/versions.js +51 -0
  125. package/dist/types/types.d.ts +40 -0
  126. package/dist/types/types.js +1 -0
  127. package/dist/ui/AgentSelector.d.ts +8 -0
  128. package/dist/ui/AgentSelector.js +53 -0
  129. package/dist/ui/MainMenu.d.ts +5 -1
  130. package/dist/ui/MainMenu.js +226 -91
  131. package/dist/ui/ModelSelector.d.ts +8 -0
  132. package/dist/ui/ModelSelector.js +53 -0
  133. package/dist/ui/TeamSelector.d.ts +8 -0
  134. package/dist/ui/TeamSelector.js +55 -0
  135. package/dist/ui/ToolSelector.d.ts +8 -0
  136. package/dist/ui/ToolSelector.js +53 -0
  137. package/dist/ui/statusFormatter.d.ts +22 -7
  138. package/dist/ui/statusFormatter.js +39 -39
  139. package/dist/ui/statusFormatter.spec.d.ts +1 -0
  140. package/dist/ui/statusFormatter.spec.js +58 -0
  141. package/package.json +16 -5
  142. package/dist/commands/cluster/get-ip.d.ts +0 -2
  143. package/dist/commands/cluster/get-ip.js +0 -32
  144. package/dist/commands/cluster/get-type.d.ts +0 -2
  145. package/dist/commands/cluster/get-type.js +0 -26
  146. package/dist/commands/completion.d.ts +0 -2
  147. package/dist/commands/completion.js +0 -108
  148. package/dist/commands/config.d.ts +0 -5
  149. package/dist/commands/config.js +0 -327
  150. package/dist/components/DashboardCLI.d.ts +0 -3
  151. package/dist/components/DashboardCLI.js +0 -149
  152. package/dist/config.d.ts +0 -42
  153. package/dist/config.js +0 -243
  154. package/dist/lib/arkClient.d.ts +0 -32
  155. package/dist/lib/arkClient.js +0 -43
  156. package/dist/lib/consts.d.ts +0 -10
  157. package/dist/lib/consts.js +0 -15
  158. package/dist/lib/exec.d.ts +0 -5
  159. package/dist/lib/exec.js +0 -20
  160. package/dist/lib/gatewayManager.d.ts +0 -24
  161. package/dist/lib/gatewayManager.js +0 -85
  162. package/dist/lib/kubernetes.d.ts +0 -28
  163. package/dist/lib/kubernetes.js +0 -122
  164. package/dist/lib/progress.d.ts +0 -128
  165. package/dist/lib/progress.js +0 -273
  166. package/dist/lib/wrappers/git.d.ts +0 -2
  167. package/dist/lib/wrappers/git.js +0 -43
@@ -0,0 +1,51 @@
1
+ import { execa } from 'execa';
2
+ import { arkServices } from '../arkServices.js';
3
+ /**
4
+ * Fetch the latest ARK version from GitHub releases
5
+ * @returns Latest version string or undefined if fetch fails
6
+ */
7
+ export async function fetchLatestVersion() {
8
+ try {
9
+ const response = await fetch('https://api.github.com/repos/mckinsey/agents-at-scale-ark/releases/latest');
10
+ if (response.ok) {
11
+ const data = (await response.json());
12
+ // Remove 'v' prefix if present for consistent comparison
13
+ return data.tag_name.replace(/^v/, '');
14
+ }
15
+ }
16
+ catch {
17
+ // Silently fail
18
+ }
19
+ return undefined;
20
+ }
21
+ /**
22
+ * Get current installed ARK version from Helm
23
+ * @returns Current version string or undefined if not found
24
+ */
25
+ export async function fetchCurrentVersion() {
26
+ try {
27
+ const controller = arkServices['ark-controller'];
28
+ const { stdout } = await execa('helm', ['list', '-n', controller.namespace, '-o', 'json'], { stdio: 'pipe' });
29
+ const releases = JSON.parse(stdout);
30
+ const arkController = releases.find((r) => r.name === controller.helmReleaseName);
31
+ return arkController?.app_version;
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ /**
38
+ * Fetch both current and latest versions in parallel
39
+ * @returns Version information
40
+ */
41
+ export async function fetchVersionInfo() {
42
+ const [current, latest] = await Promise.all([
43
+ fetchCurrentVersion(),
44
+ fetchLatestVersion(),
45
+ ]);
46
+ return {
47
+ current,
48
+ latest,
49
+ updateAvailable: current && latest ? current !== latest : undefined,
50
+ };
51
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Represents a Helm chart configuration for ARK components
3
+ */
4
+ export interface ArkChart {
5
+ /** Name of the chart (used as release name) */
6
+ name: string;
7
+ /** Full chart path (OCI registry or local path) */
8
+ chartPath: string;
9
+ /** Kubernetes namespace to install into */
10
+ namespace: string;
11
+ /** Additional arguments to pass to helm (e.g., --create-namespace, --wait, --timeout 300s, --set key=value) */
12
+ args?: string[];
13
+ /** Description of what this chart provides */
14
+ description?: string;
15
+ }
16
+ /**
17
+ * Collection of ARK charts
18
+ */
19
+ export interface ChartCollection {
20
+ [key: string]: ArkChart;
21
+ }
22
+ /**
23
+ * Represents a dependency that needs to be installed
24
+ */
25
+ export interface Dependency {
26
+ /** Name of the dependency */
27
+ name: string;
28
+ /** Command to execute (helm, kubectl, etc.) */
29
+ command: string;
30
+ /** Arguments to pass to the command */
31
+ args: string[];
32
+ /** Description of what this dependency provides */
33
+ description?: string;
34
+ }
35
+ /**
36
+ * Collection of dependencies
37
+ */
38
+ export interface DependencyCollection {
39
+ [key: string]: Dependency;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Agent, ArkApiClient } from '../lib/arkApiClient.js';
2
+ interface AgentSelectorProps {
3
+ arkApiClient: ArkApiClient;
4
+ onSelect: (agent: Agent) => void;
5
+ onExit: () => void;
6
+ }
7
+ export declare function AgentSelector({ arkApiClient, onSelect, onExit, }: AgentSelectorProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { Box, Text, useInput } from 'ink';
4
+ export function AgentSelector({ arkApiClient, onSelect, onExit, }) {
5
+ const [selectedIndex, setSelectedIndex] = useState(0);
6
+ const [agents, setAgents] = useState([]);
7
+ const [loading, setLoading] = useState(true);
8
+ const [error, setError] = useState(null);
9
+ useEffect(() => {
10
+ arkApiClient
11
+ .getAgents()
12
+ .then((fetchedAgents) => {
13
+ setAgents(fetchedAgents);
14
+ setLoading(false);
15
+ })
16
+ .catch((err) => {
17
+ setError(err.message || 'Failed to fetch agents');
18
+ setLoading(false);
19
+ });
20
+ }, [arkApiClient]);
21
+ useInput((input, key) => {
22
+ if (key.escape) {
23
+ onExit();
24
+ }
25
+ else if (key.upArrow || input === 'k') {
26
+ setSelectedIndex((prev) => (prev === 0 ? agents.length - 1 : prev - 1));
27
+ }
28
+ else if (key.downArrow || input === 'j') {
29
+ setSelectedIndex((prev) => (prev === agents.length - 1 ? 0 : prev + 1));
30
+ }
31
+ else if (key.return) {
32
+ onSelect(agents[selectedIndex]);
33
+ }
34
+ else {
35
+ // Handle number keys for quick selection
36
+ const num = parseInt(input, 10);
37
+ if (!isNaN(num) && num >= 1 && num <= agents.length) {
38
+ onSelect(agents[num - 1]);
39
+ }
40
+ }
41
+ });
42
+ if (loading) {
43
+ return (_jsx(Box, { children: _jsx(Text, { children: "Loading agents..." }) }));
44
+ }
45
+ if (error) {
46
+ return (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) }));
47
+ }
48
+ if (agents.length === 0) {
49
+ return (_jsx(Box, { children: _jsx(Text, { children: "No agents available" }) }));
50
+ }
51
+ const selectedAgent = agents[selectedIndex];
52
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Select Agent" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { dimColor: true, children: "Choose an agent to start a conversation with" }) }), _jsx(Box, { flexDirection: "column", children: agents.map((agent, index) => (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: index === selectedIndex ? 'green' : undefined, children: [index === selectedIndex ? '❯ ' : ' ', index + 1, ". ", agent.name] }) }, agent.name))) }), selectedAgent.description && (_jsx(Box, { marginTop: 1, paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "wrap", children: selectedAgent.description }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Enter to confirm \u00B7 Number to select \u00B7 Esc to exit" }) })] }));
53
+ }
@@ -1,3 +1,7 @@
1
1
  import * as React from 'react';
2
- declare const MainMenu: React.FC;
2
+ import type { ArkConfig } from '../lib/config.js';
3
+ interface MainMenuProps {
4
+ config: ArkConfig;
5
+ }
6
+ declare const MainMenu: React.FC<MainMenuProps>;
3
7
  export default MainMenu;
@@ -1,70 +1,236 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Text, Box, useInput } from 'ink';
3
- import SelectInput from 'ink-select-input';
2
+ import { Text, Box, render, useInput } from 'ink';
3
+ import Spinner from 'ink-spinner';
4
4
  import * as React from 'react';
5
- import DashboardCLI from '../components/DashboardCLI.js';
6
- import GeneratorUI from '../components/GeneratorUI.js';
7
- import { StatusChecker } from '../components/statusChecker.js';
8
- import { ConfigManager } from '../config.js';
9
- import { ArkClient } from '../lib/arkClient.js';
10
- const EXIT_TIMEOUT_MS = 1000;
11
- const MainMenu = () => {
12
- const [selectedChoice, setSelectedChoice] = React.useState(null);
13
- const [statusData, setStatusData] = React.useState(null);
14
- const [isLoading, setIsLoading] = React.useState(false);
15
- const [error, setError] = React.useState(null);
16
- const choices = [
17
- { label: '🏷️ Dashboard', value: 'dashboard' },
18
- { label: '🔍 Status Check', value: 'status' },
19
- { label: '🎯 Generate', value: 'generate' },
20
- { label: '👋 Exit', value: 'exit' },
21
- ];
22
- React.useEffect(() => {
23
- if (selectedChoice === 'exit') {
24
- const timer = setTimeout(() => {
25
- process.exit(0);
26
- }, EXIT_TIMEOUT_MS);
27
- return () => clearTimeout(timer);
5
+ import { isArkReady } from '../lib/arkStatus.js';
6
+ import { fetchVersionInfo } from '../lib/versions.js';
7
+ // Helper function to unmount the main ink app - used when we move from a
8
+ // React TUI app to basic input/output.
9
+ async function unmountInkApp() {
10
+ const app = globalThis.inkApp;
11
+ if (app) {
12
+ // Unmount the Ink app
13
+ app.unmount();
14
+ // Clear the global reference
15
+ delete globalThis.inkApp;
16
+ // Reset terminal to normal mode
17
+ if (process.stdin.isTTY) {
18
+ process.stdin.setRawMode(false);
19
+ process.stdin.pause();
28
20
  }
29
- }, [selectedChoice]);
21
+ // Clear screen
22
+ console.clear();
23
+ // Small delay to ensure everything is flushed
24
+ await new Promise((resolve) => setTimeout(resolve, 50));
25
+ }
26
+ }
27
+ const MainMenu = ({ config }) => {
28
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
29
+ const [arkReady, setArkReady] = React.useState(null);
30
+ const [isChecking, setIsChecking] = React.useState(true);
31
+ const [versionInfo, setVersionInfo] = React.useState({});
30
32
  React.useEffect(() => {
31
- if (selectedChoice === 'status' && !statusData && !isLoading) {
32
- checkStatus();
33
+ const checkStatus = async () => {
34
+ setIsChecking(true);
35
+ // Run ark ready check and version fetch in parallel
36
+ const [ready, versions] = await Promise.all([
37
+ isArkReady(),
38
+ fetchVersionInfo(),
39
+ ]);
40
+ setArkReady(ready);
41
+ setVersionInfo(versions);
42
+ setIsChecking(false);
43
+ // Reset selected index to 0 after status check
44
+ setSelectedIndex(0);
45
+ };
46
+ checkStatus();
47
+ }, []);
48
+ // Handle Ctrl+C to properly unmount Ink and restore terminal
49
+ React.useEffect(() => {
50
+ const handleExit = () => {
51
+ const app = globalThis.inkApp;
52
+ if (app) {
53
+ app.unmount();
54
+ }
55
+ process.exit(0);
56
+ };
57
+ process.on('SIGINT', handleExit);
58
+ return () => {
59
+ process.removeListener('SIGINT', handleExit);
60
+ };
61
+ }, []);
62
+ // Check if upgrade is available
63
+ const hasUpgrade = React.useMemo(() => {
64
+ return versionInfo.updateAvailable === true;
65
+ }, [versionInfo.updateAvailable]);
66
+ const allChoices = [
67
+ {
68
+ label: 'Chat',
69
+ description: 'Interactive chat with Ark agents',
70
+ value: 'chat',
71
+ command: 'ark chat',
72
+ },
73
+ {
74
+ label: 'Install',
75
+ description: 'Install Ark',
76
+ value: 'install',
77
+ command: 'ark install',
78
+ },
79
+ {
80
+ label: 'Upgrade',
81
+ description: `Upgrade Ark from ${versionInfo.current || 'unknown'} to ${versionInfo.latest || 'unknown'}`,
82
+ value: 'upgrade',
83
+ command: 'ark install -y',
84
+ },
85
+ {
86
+ label: 'Dashboard',
87
+ description: 'Open Ark dashboard in browser',
88
+ value: 'dashboard',
89
+ command: 'ark dashboard',
90
+ },
91
+ {
92
+ label: 'Status',
93
+ description: 'Check Ark services status',
94
+ value: 'status',
95
+ command: 'ark status',
96
+ },
97
+ {
98
+ label: 'Generate',
99
+ description: 'Generate new Ark components',
100
+ value: 'generate',
101
+ command: 'ark generate',
102
+ },
103
+ { label: 'Exit', description: 'Exit Ark CLI', value: 'exit' },
104
+ ];
105
+ // Filter choices based on Ark readiness
106
+ const choices = React.useMemo(() => {
107
+ // Don't return any choices while checking
108
+ if (isChecking)
109
+ return [];
110
+ if (!arkReady) {
111
+ // Only show Install, Status, and Exit when Ark is not ready
112
+ return allChoices.filter((choice) => ['install', 'status', 'exit'].includes(choice.value));
33
113
  }
34
- }, [selectedChoice, statusData, isLoading]);
35
- const checkStatus = async () => {
36
- setIsLoading(true);
37
- setError(null);
38
- try {
39
- const configManager = new ConfigManager();
40
- const apiBaseUrl = await configManager.getApiBaseUrl();
41
- const serviceUrls = await configManager.getServiceUrls();
42
- const arkClient = new ArkClient(apiBaseUrl);
43
- const statusChecker = new StatusChecker(arkClient);
44
- const status = await statusChecker.checkAll(serviceUrls, apiBaseUrl);
45
- setStatusData(status);
114
+ // Ark is ready - filter out install (already installed) and conditionally show upgrade
115
+ const filteredChoices = allChoices.filter((choice) => {
116
+ // Never show install when Ark is ready (it's already installed)
117
+ if (choice.value === 'install')
118
+ return false;
119
+ // Only show upgrade if there's actually an upgrade available
120
+ if (choice.value === 'upgrade' && !hasUpgrade)
121
+ return false;
122
+ return true;
123
+ });
124
+ return filteredChoices;
125
+ }, [arkReady, isChecking, hasUpgrade, allChoices]);
126
+ useInput((input, key) => {
127
+ // Don't process input while checking status
128
+ if (isChecking)
129
+ return;
130
+ if (key.upArrow || input === 'k') {
131
+ setSelectedIndex((prev) => (prev > 0 ? prev - 1 : choices.length - 1));
46
132
  }
47
- catch (err) {
48
- setError(err instanceof Error ? err.message : 'Unknown error occurred');
133
+ else if (key.downArrow || input === 'j') {
134
+ setSelectedIndex((prev) => (prev < choices.length - 1 ? prev + 1 : 0));
49
135
  }
50
- finally {
51
- setIsLoading(false);
136
+ else if (key.return) {
137
+ handleSelect(choices[selectedIndex]);
52
138
  }
53
- };
54
- useInput((input, key) => {
55
- if (selectedChoice && selectedChoice !== 'exit') {
56
- if (key.escape || input === 'q' || key.return) {
57
- // For generate, only reset on specific key combinations to avoid conflicts
58
- if (selectedChoice === 'generate' && !(key.escape || input === 'q')) {
59
- return;
60
- }
61
- setSelectedChoice(null);
62
- setStatusData(null);
63
- setError(null);
139
+ else {
140
+ // Handle number keys for quick selection
141
+ const num = parseInt(input, 10);
142
+ if (!isNaN(num) && num >= 1 && num <= choices.length) {
143
+ handleSelect(choices[num - 1]);
64
144
  }
65
145
  }
66
146
  });
67
- const renderBanner = () => (_jsxs(Box, { flexDirection: "column", alignItems: "center", marginBottom: 1, children: [_jsx(Text, { color: "cyan", bold: true, children: `
147
+ const handleSelect = async (item) => {
148
+ switch (item.value) {
149
+ case 'exit':
150
+ process.exit(0);
151
+ break;
152
+ case 'chat': {
153
+ // Unmount fullscreen app and clear screen.
154
+ await unmountInkApp();
155
+ // Import and start ChatUI in the same process
156
+ const { render } = await import('ink');
157
+ const { ArkApiProxy } = await import('../lib/arkApiProxy.js');
158
+ const ChatUI = (await import('../components/ChatUI.js')).default;
159
+ try {
160
+ const proxy = new ArkApiProxy();
161
+ const arkApiClient = await proxy.start();
162
+ // Render ChatUI as a new Ink app
163
+ render(_jsx(ChatUI, { arkApiClient: arkApiClient, arkApiProxy: proxy }));
164
+ }
165
+ catch (error) {
166
+ const output = (await import('../lib/output.js')).default;
167
+ output.error(error instanceof Error
168
+ ? error.message
169
+ : 'Failed to connect to Ark API');
170
+ process.exit(1);
171
+ }
172
+ break;
173
+ }
174
+ case 'install': {
175
+ // Unmount fullscreen app and clear screen.
176
+ await unmountInkApp();
177
+ // Spawn as a new process to avoid Ink/inquirer signal conflicts
178
+ const { execFileSync } = await import('child_process');
179
+ try {
180
+ execFileSync(process.execPath, [process.argv[1], 'install'], {
181
+ stdio: 'inherit',
182
+ env: { ...process.env, FORCE_COLOR: '1' },
183
+ });
184
+ }
185
+ catch (error) {
186
+ // execFileSync throws if the process exits with non-zero
187
+ process.exit(error.status || 1);
188
+ }
189
+ process.exit(0);
190
+ break; // Add break even though process.exit prevents reaching here
191
+ }
192
+ case 'upgrade': {
193
+ // Unmount fullscreen app and clear screen.
194
+ await unmountInkApp();
195
+ // Spawn as a new process with -y flag for automatic upgrade
196
+ const { execFileSync } = await import('child_process');
197
+ try {
198
+ execFileSync(process.execPath, [process.argv[1], 'install', '-y'], {
199
+ stdio: 'inherit',
200
+ env: { ...process.env, FORCE_COLOR: '1' },
201
+ });
202
+ }
203
+ catch (error) {
204
+ // execFileSync throws if the process exits with non-zero
205
+ process.exit(error.status || 1);
206
+ }
207
+ process.exit(0);
208
+ break; // Add break even though process.exit prevents reaching here
209
+ }
210
+ case 'dashboard': {
211
+ // Unmount fullscreen app and clear screen.
212
+ await unmountInkApp();
213
+ const { openDashboard } = await import('../commands/dashboard/index.js');
214
+ await openDashboard();
215
+ break;
216
+ }
217
+ case 'status': {
218
+ // Unmount fullscreen app and clear screen.
219
+ await unmountInkApp();
220
+ const { checkStatus } = await import('../commands/status/index.js');
221
+ await checkStatus();
222
+ process.exit(0);
223
+ break; // Add break even though process.exit prevents reaching here
224
+ }
225
+ case 'generate': {
226
+ const GeneratorUI = (await import('../components/GeneratorUI.js'))
227
+ .default;
228
+ render(_jsx(GeneratorUI, {}));
229
+ break;
230
+ }
231
+ }
232
+ };
233
+ return (_jsxs(_Fragment, { children: [_jsxs(Box, { flexDirection: "column", alignItems: "center", marginBottom: 1, children: [_jsx(Text, { color: "cyan", bold: true, children: `
68
234
  ╔═══════════════════════════════════════╗
69
235
  ║ ║
70
236
  ║ █████╗ ██████╗ ██╗ ██╗ ║
@@ -77,40 +243,9 @@ const MainMenu = () => {
77
243
  ║ Agents at Scale Platform ║
78
244
  ║ ║
79
245
  ╚═══════════════════════════════════════╝
80
- ` }), _jsx(Text, { color: "green", bold: true, children: "Welcome to ARK! \uD83D\uDE80" }), _jsx(Text, { color: "gray", children: "Interactive terminal interface for ARK agents" })] }));
81
- const renderServiceStatus = (service) => {
82
- const statusColor = service.status === 'healthy'
83
- ? 'green'
84
- : service.status === 'unhealthy'
85
- ? 'red'
86
- : 'yellow';
87
- const statusIcon = service.status === 'healthy'
88
- ? '✓'
89
- : service.status === 'unhealthy'
90
- ? '✗'
91
- : '?';
92
- 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));
93
- };
94
- const renderDependencyStatus = (dep) => {
95
- const statusColor = dep.installed ? 'green' : 'red';
96
- const statusIcon = dep.installed ? '✓' : '✗';
97
- const statusText = dep.installed ? 'installed' : 'missing';
98
- 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));
99
- };
100
- const renderStatus = () => {
101
- if (isLoading) {
102
- 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." })] }));
103
- }
104
- if (error) {
105
- 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..." }) })] }));
106
- }
107
- if (!statusData) {
108
- return null;
109
- }
110
- 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..." }) })] }));
111
- };
112
- return (_jsxs(_Fragment, { children: [renderBanner(), !selectedChoice && (_jsx(SelectInput, { items: choices, onSelect: (choice) => {
113
- setSelectedChoice(choice.value);
114
- } })), selectedChoice === 'status' && renderStatus(), selectedChoice === 'dashboard' && (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "green", children: "\uD83C\uDFF7\uFE0F Dashboard feature selected" }), _jsx(DashboardCLI, {})] })), selectedChoice === 'generate' && _jsx(GeneratorUI, {}), selectedChoice === 'exit' && _jsx(Text, { color: "yellow", children: "\uD83D\uDC4B Goodbye!" })] }));
246
+ ` }), isChecking ? (_jsxs(Text, { color: "gray", children: [_jsx(Spinner, { type: "dots" }), " Checking Ark status..."] })) : arkReady ? (_jsxs(Box, { children: [_jsx(Text, { color: "green", bold: true, children: "\u25CF Ark is ready" }), _jsxs(Text, { color: "gray", children: [' ', "(", versionInfo.current || 'version unknown', ")"] })] })) : (_jsx(Text, { color: "yellow", bold: true, children: "\u25CF Ark is not installed" })), config.clusterInfo?.context ? (_jsxs(Text, { children: [_jsx(Text, { color: "gray", children: "Current context: " }), _jsx(Text, { color: "white", bold: true, children: config.clusterInfo.context })] })) : (_jsx(Text, { color: "gray", children: "No Kubernetes context configured" }))] }), !isChecking && (_jsx(Box, { flexDirection: "column", paddingX: 4, marginTop: 1, children: choices.map((choice, index) => {
247
+ const isSelected = index === selectedIndex;
248
+ return (_jsxs(Box, { flexDirection: "row", paddingY: 0, children: [_jsx(Text, { color: "gray", dimColor: true, children: isSelected ? '❯ ' : ' ' }), _jsxs(Text, { color: "gray", dimColor: true, children: [index + 1, "."] }), _jsx(Box, { marginLeft: 1, width: 20, children: _jsx(Text, { color: isSelected ? 'green' : 'white', bold: isSelected, children: choice.label }) }), _jsx(Text, { color: "gray", children: choice.description })] }, choice.value));
249
+ }) }))] }));
115
250
  };
116
251
  export default MainMenu;
@@ -0,0 +1,8 @@
1
+ import { Model, ArkApiClient } from '../lib/arkApiClient.js';
2
+ interface ModelSelectorProps {
3
+ arkApiClient: ArkApiClient;
4
+ onSelect: (model: Model) => void;
5
+ onExit: () => void;
6
+ }
7
+ export declare function ModelSelector({ arkApiClient, onSelect, onExit, }: ModelSelectorProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { Box, Text, useInput } from 'ink';
4
+ export function ModelSelector({ arkApiClient, onSelect, onExit, }) {
5
+ const [selectedIndex, setSelectedIndex] = useState(0);
6
+ const [models, setModels] = useState([]);
7
+ const [loading, setLoading] = useState(true);
8
+ const [error, setError] = useState(null);
9
+ useEffect(() => {
10
+ arkApiClient
11
+ .getModels()
12
+ .then((fetchedModels) => {
13
+ setModels(fetchedModels);
14
+ setLoading(false);
15
+ })
16
+ .catch((err) => {
17
+ setError(err.message || 'Failed to fetch models');
18
+ setLoading(false);
19
+ });
20
+ }, [arkApiClient]);
21
+ useInput((input, key) => {
22
+ if (key.escape) {
23
+ onExit();
24
+ }
25
+ else if (key.upArrow || input === 'k') {
26
+ setSelectedIndex((prev) => (prev === 0 ? models.length - 1 : prev - 1));
27
+ }
28
+ else if (key.downArrow || input === 'j') {
29
+ setSelectedIndex((prev) => (prev === models.length - 1 ? 0 : prev + 1));
30
+ }
31
+ else if (key.return) {
32
+ onSelect(models[selectedIndex]);
33
+ }
34
+ else {
35
+ // Handle number keys for quick selection
36
+ const num = parseInt(input, 10);
37
+ if (!isNaN(num) && num >= 1 && num <= models.length) {
38
+ onSelect(models[num - 1]);
39
+ }
40
+ }
41
+ });
42
+ if (loading) {
43
+ return (_jsx(Box, { children: _jsx(Text, { children: "Loading models..." }) }));
44
+ }
45
+ if (error) {
46
+ return (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) }));
47
+ }
48
+ if (models.length === 0) {
49
+ return (_jsx(Box, { children: _jsx(Text, { children: "No models available" }) }));
50
+ }
51
+ const selectedModel = models[selectedIndex];
52
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Select Model" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { dimColor: true, children: "Choose a model to start a conversation with" }) }), _jsx(Box, { flexDirection: "column", children: models.map((model, index) => (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: index === selectedIndex ? 'green' : undefined, children: [index === selectedIndex ? '❯ ' : ' ', index + 1, ". ", model.name, model.type ? ` (${model.type})` : ''] }) }, model.name))) }), selectedModel && selectedModel.model && (_jsx(Box, { marginTop: 1, paddingLeft: 2, children: _jsxs(Text, { dimColor: true, wrap: "wrap", children: ["Model: ", selectedModel.model] }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Enter to confirm \u00B7 Number to select \u00B7 Esc to exit" }) })] }));
53
+ }
@@ -0,0 +1,8 @@
1
+ import { Team, ArkApiClient } from '../lib/arkApiClient.js';
2
+ interface TeamSelectorProps {
3
+ arkApiClient: ArkApiClient;
4
+ onSelect: (team: Team) => void;
5
+ onExit: () => void;
6
+ }
7
+ export declare function TeamSelector({ arkApiClient, onSelect, onExit, }: TeamSelectorProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { Box, Text, useInput } from 'ink';
4
+ export function TeamSelector({ arkApiClient, onSelect, onExit, }) {
5
+ const [selectedIndex, setSelectedIndex] = useState(0);
6
+ const [teams, setTeams] = useState([]);
7
+ const [loading, setLoading] = useState(true);
8
+ const [error, setError] = useState(null);
9
+ useEffect(() => {
10
+ arkApiClient
11
+ .getTeams()
12
+ .then((fetchedTeams) => {
13
+ setTeams(fetchedTeams);
14
+ setLoading(false);
15
+ })
16
+ .catch((err) => {
17
+ setError(err.message || 'Failed to fetch teams');
18
+ setLoading(false);
19
+ });
20
+ }, [arkApiClient]);
21
+ useInput((input, key) => {
22
+ if (key.escape) {
23
+ onExit();
24
+ }
25
+ else if (key.upArrow || input === 'k') {
26
+ setSelectedIndex((prev) => (prev === 0 ? teams.length - 1 : prev - 1));
27
+ }
28
+ else if (key.downArrow || input === 'j') {
29
+ setSelectedIndex((prev) => (prev === teams.length - 1 ? 0 : prev + 1));
30
+ }
31
+ else if (key.return) {
32
+ onSelect(teams[selectedIndex]);
33
+ }
34
+ else {
35
+ // Handle number keys for quick selection
36
+ const num = parseInt(input, 10);
37
+ if (!isNaN(num) && num >= 1 && num <= teams.length) {
38
+ onSelect(teams[num - 1]);
39
+ }
40
+ }
41
+ });
42
+ if (loading) {
43
+ return (_jsx(Box, { children: _jsx(Text, { children: "Loading teams..." }) }));
44
+ }
45
+ if (error) {
46
+ return (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["Error: ", error] }) }));
47
+ }
48
+ if (teams.length === 0) {
49
+ return (_jsx(Box, { children: _jsx(Text, { children: "No teams available" }) }));
50
+ }
51
+ const selectedTeam = teams[selectedIndex];
52
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Select Team" }) }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { dimColor: true, children: "Choose a team to start a conversation with" }) }), _jsx(Box, { flexDirection: "column", children: teams.map((team, index) => (_jsx(Box, { marginBottom: 0, children: _jsxs(Text, { color: index === selectedIndex ? 'green' : undefined, children: [index === selectedIndex ? '❯ ' : ' ', index + 1, ". ", team.name, team.strategy ? ` (${team.strategy})` : ''] }) }, team.name))) }), selectedTeam &&
53
+ (selectedTeam.description || selectedTeam.members_count) && (_jsx(Box, { marginTop: 1, paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "wrap", children: selectedTeam.description ||
54
+ `Members: ${selectedTeam.members_count}` }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Enter to confirm \u00B7 Number to select \u00B7 Esc to exit" }) })] }));
55
+ }
@@ -0,0 +1,8 @@
1
+ import { Tool, ArkApiClient } from '../lib/arkApiClient.js';
2
+ interface ToolSelectorProps {
3
+ arkApiClient: ArkApiClient;
4
+ onSelect: (tool: Tool) => void;
5
+ onExit: () => void;
6
+ }
7
+ export declare function ToolSelector({ arkApiClient, onSelect, onExit, }: ToolSelectorProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};