@agents-at-scale/ark 0.1.34 → 0.1.35-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arkServices.d.ts +42 -0
- package/dist/arkServices.js +138 -0
- package/dist/arkServices.spec.d.ts +1 -0
- package/dist/arkServices.spec.js +24 -0
- package/dist/charts/charts.d.ts +5 -0
- package/dist/charts/charts.js +6 -0
- package/dist/charts/dependencies.d.ts +6 -0
- package/dist/charts/dependencies.js +50 -0
- package/dist/charts/types.d.ts +40 -0
- package/dist/charts/types.js +1 -0
- package/dist/commands/agents/index.d.ts +3 -0
- package/dist/commands/agents/index.js +51 -0
- package/dist/commands/agents/index.spec.d.ts +1 -0
- package/dist/commands/agents/index.spec.js +67 -0
- package/dist/commands/agents/selector.d.ts +8 -0
- package/dist/commands/agents/selector.js +53 -0
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.js +53 -0
- package/dist/commands/chat/index.d.ts +3 -0
- package/dist/commands/chat/index.js +29 -0
- package/dist/commands/chat.d.ts +2 -0
- package/dist/commands/chat.js +45 -0
- package/dist/commands/cluster/get.d.ts +2 -0
- package/dist/commands/cluster/get.js +39 -0
- package/dist/commands/cluster/get.spec.d.ts +1 -0
- package/dist/commands/cluster/get.spec.js +92 -0
- package/dist/commands/cluster/index.d.ts +2 -1
- package/dist/commands/cluster/index.js +3 -5
- package/dist/commands/cluster/index.spec.d.ts +1 -0
- package/dist/commands/cluster/index.spec.js +24 -0
- package/dist/commands/completion/index.d.ts +3 -0
- package/dist/commands/completion/index.js +268 -0
- package/dist/commands/completion/index.spec.d.ts +1 -0
- package/dist/commands/completion/index.spec.js +34 -0
- package/dist/commands/completion.js +159 -2
- package/dist/commands/config/index.d.ts +3 -0
- package/dist/commands/config/index.js +42 -0
- package/dist/commands/config/index.spec.d.ts +1 -0
- package/dist/commands/config/index.spec.js +78 -0
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.js +38 -321
- package/dist/commands/dashboard/index.d.ts +4 -0
- package/dist/commands/dashboard/index.js +39 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.js +39 -0
- package/dist/commands/dev/index.d.ts +3 -0
- package/dist/commands/dev/index.js +9 -0
- package/dist/commands/dev/tool/check.d.ts +2 -0
- package/dist/commands/dev/tool/check.js +142 -0
- package/dist/commands/dev/tool/clean.d.ts +2 -0
- package/dist/commands/dev/tool/clean.js +153 -0
- package/dist/commands/dev/tool/generate.d.ts +2 -0
- package/dist/commands/dev/tool/generate.js +28 -0
- package/dist/commands/dev/tool/index.d.ts +2 -0
- package/dist/commands/dev/tool/index.js +14 -0
- package/dist/commands/dev/tool/init.d.ts +2 -0
- package/dist/commands/dev/tool/init.js +320 -0
- package/dist/commands/dev/tool/shared.d.ts +5 -0
- package/dist/commands/dev/tool/shared.js +256 -0
- package/dist/commands/dev/tool/status.d.ts +2 -0
- package/dist/commands/dev/tool/status.js +136 -0
- package/dist/commands/dev/tool-generate.spec.d.ts +1 -0
- package/dist/commands/dev/tool-generate.spec.js +163 -0
- package/dist/commands/dev/tool.d.ts +2 -0
- package/dist/commands/dev/tool.js +559 -0
- package/dist/commands/dev/tool.spec.d.ts +1 -0
- package/dist/commands/dev/tool.spec.js +48 -0
- package/dist/commands/generate/config.js +5 -24
- package/dist/commands/generate/generators/mcpserver.d.ts +2 -1
- package/dist/commands/generate/generators/mcpserver.js +26 -5
- package/dist/commands/generate/generators/project.js +22 -41
- package/dist/commands/generate/index.d.ts +2 -1
- package/dist/commands/generate/index.js +1 -1
- package/dist/commands/install/index.d.ts +8 -0
- package/dist/commands/install/index.js +302 -0
- package/dist/commands/install/index.spec.d.ts +1 -0
- package/dist/commands/install/index.spec.js +135 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.js +147 -0
- package/dist/commands/models/create.d.ts +1 -0
- package/dist/commands/models/create.js +213 -0
- package/dist/commands/models/create.spec.d.ts +1 -0
- package/dist/commands/models/create.spec.js +125 -0
- package/dist/commands/models/index.d.ts +3 -0
- package/dist/commands/models/index.js +60 -0
- package/dist/commands/models/index.spec.d.ts +1 -0
- package/dist/commands/models/index.spec.js +76 -0
- package/dist/commands/models/selector.d.ts +8 -0
- package/dist/commands/models/selector.js +53 -0
- package/dist/commands/routes/index.d.ts +3 -0
- package/dist/commands/routes/index.js +93 -0
- package/dist/commands/routes.d.ts +2 -0
- package/dist/commands/routes.js +101 -0
- package/dist/commands/status/index.d.ts +4 -0
- package/dist/commands/status/index.js +232 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +33 -0
- package/dist/commands/targets/index.d.ts +3 -0
- package/dist/commands/targets/index.js +65 -0
- package/dist/commands/targets/index.spec.d.ts +1 -0
- package/dist/commands/targets/index.spec.js +105 -0
- package/dist/commands/targets.d.ts +2 -0
- package/dist/commands/targets.js +65 -0
- package/dist/commands/teams/index.d.ts +3 -0
- package/dist/commands/teams/index.js +49 -0
- package/dist/commands/teams/index.spec.d.ts +1 -0
- package/dist/commands/teams/index.spec.js +70 -0
- package/dist/commands/teams/selector.d.ts +8 -0
- package/dist/commands/teams/selector.js +55 -0
- package/dist/commands/tools/index.d.ts +3 -0
- package/dist/commands/tools/index.js +49 -0
- package/dist/commands/tools/index.spec.d.ts +1 -0
- package/dist/commands/tools/index.spec.js +70 -0
- package/dist/commands/tools/selector.d.ts +8 -0
- package/dist/commands/tools/selector.js +53 -0
- package/dist/commands/uninstall/index.d.ts +3 -0
- package/dist/commands/uninstall/index.js +107 -0
- package/dist/commands/uninstall/index.spec.d.ts +1 -0
- package/dist/commands/uninstall/index.spec.js +117 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.js +83 -0
- package/dist/components/ChatUI.d.ts +16 -0
- package/dist/components/ChatUI.js +801 -0
- package/dist/components/StatusView.d.ts +10 -0
- package/dist/components/StatusView.js +39 -0
- package/dist/components/statusChecker.d.ts +13 -23
- package/dist/components/statusChecker.js +275 -129
- package/dist/config.d.ts +3 -22
- package/dist/config.js +10 -161
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -42
- package/dist/lib/arkApiClient.d.ts +53 -0
- package/dist/lib/arkApiClient.js +102 -0
- package/dist/lib/arkApiProxy.d.ts +9 -0
- package/dist/lib/arkApiProxy.js +22 -0
- package/dist/lib/arkServiceProxy.d.ts +14 -0
- package/dist/lib/arkServiceProxy.js +95 -0
- package/dist/lib/arkStatus.d.ts +10 -0
- package/dist/lib/arkStatus.js +79 -0
- package/dist/lib/arkStatus.spec.d.ts +1 -0
- package/dist/lib/arkStatus.spec.js +49 -0
- package/dist/lib/chatClient.d.ts +33 -0
- package/dist/lib/chatClient.js +99 -0
- package/dist/lib/cluster.d.ts +2 -1
- package/dist/lib/cluster.js +37 -16
- package/dist/lib/cluster.spec.d.ts +1 -0
- package/dist/lib/cluster.spec.js +338 -0
- package/dist/lib/commandUtils.d.ts +4 -0
- package/dist/lib/commandUtils.js +18 -0
- package/dist/lib/commandUtils.test.d.ts +1 -0
- package/dist/lib/commandUtils.test.js +44 -0
- package/dist/lib/commands.d.ts +16 -0
- package/dist/lib/commands.js +29 -0
- package/dist/lib/commands.spec.d.ts +1 -0
- package/dist/lib/commands.spec.js +146 -0
- package/dist/lib/config.d.ts +26 -80
- package/dist/lib/config.js +70 -205
- package/dist/lib/config.spec.d.ts +1 -0
- package/dist/lib/config.spec.js +99 -0
- package/dist/lib/config.test.d.ts +1 -0
- package/dist/lib/config.test.js +93 -0
- package/dist/lib/consts.d.ts +0 -1
- package/dist/lib/consts.js +0 -2
- package/dist/lib/consts.spec.d.ts +1 -0
- package/dist/lib/consts.spec.js +15 -0
- package/dist/lib/dev/tools/analyzer.d.ts +30 -0
- package/dist/lib/dev/tools/analyzer.js +190 -0
- package/dist/lib/dev/tools/discover_tools.py +392 -0
- package/dist/lib/dev/tools/mcp-types.d.ts +28 -0
- package/dist/lib/dev/tools/mcp-types.js +86 -0
- package/dist/lib/dev/tools/types.d.ts +50 -0
- package/dist/lib/dev/tools/types.js +1 -0
- package/dist/lib/errors.js +1 -1
- package/dist/lib/errors.spec.d.ts +1 -0
- package/dist/lib/errors.spec.js +221 -0
- package/dist/lib/exec.d.ts +0 -4
- package/dist/lib/exec.js +0 -11
- package/dist/lib/output.d.ts +36 -0
- package/dist/lib/output.js +89 -0
- package/dist/lib/output.spec.d.ts +1 -0
- package/dist/lib/output.spec.js +123 -0
- package/dist/lib/portUtils.d.ts +8 -0
- package/dist/lib/portUtils.js +39 -0
- package/dist/lib/startup.d.ts +5 -0
- package/dist/lib/startup.js +73 -0
- package/dist/lib/startup.spec.d.ts +1 -0
- package/dist/lib/startup.spec.js +168 -0
- package/dist/lib/types.d.ts +10 -3
- package/dist/types/types.d.ts +40 -0
- package/dist/types/types.js +1 -0
- package/dist/ui/AgentSelector.d.ts +8 -0
- package/dist/ui/AgentSelector.js +53 -0
- package/dist/ui/MainMenu.d.ts +5 -1
- package/dist/ui/MainMenu.js +222 -91
- package/dist/ui/ModelSelector.d.ts +8 -0
- package/dist/ui/ModelSelector.js +53 -0
- package/dist/ui/TeamSelector.d.ts +8 -0
- package/dist/ui/TeamSelector.js +55 -0
- package/dist/ui/ToolSelector.d.ts +8 -0
- package/dist/ui/ToolSelector.js +53 -0
- package/dist/ui/statusFormatter.d.ts +22 -7
- package/dist/ui/statusFormatter.js +39 -39
- package/dist/ui/statusFormatter.spec.d.ts +1 -0
- package/dist/ui/statusFormatter.spec.js +58 -0
- package/package.json +17 -5
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
}
|
package/dist/lib/cluster.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export interface ClusterInfo {
|
|
|
2
2
|
type: 'minikube' | 'kind' | 'k3s' | 'docker-desktop' | 'cloud' | 'unknown';
|
|
3
3
|
ip?: string;
|
|
4
4
|
context?: string;
|
|
5
|
+
namespace?: string;
|
|
5
6
|
error?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function detectClusterType(): Promise<ClusterInfo>;
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function getClusterInfo(context?: string): Promise<ClusterInfo>;
|
package/dist/lib/cluster.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } from 'execa';
|
|
2
2
|
export async function detectClusterType() {
|
|
3
3
|
try {
|
|
4
|
-
const { stdout } = await
|
|
5
|
-
'config',
|
|
6
|
-
'current-context',
|
|
7
|
-
]);
|
|
4
|
+
const { stdout } = await execa('kubectl', ['config', 'current-context']);
|
|
8
5
|
const context = stdout.trim();
|
|
9
6
|
if (context.includes('minikube')) {
|
|
10
7
|
return { type: 'minikube', context };
|
|
@@ -28,12 +25,33 @@ export async function detectClusterType() {
|
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
catch (error) {
|
|
31
|
-
return {
|
|
28
|
+
return {
|
|
29
|
+
type: 'unknown',
|
|
30
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
31
|
+
};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
export async function
|
|
34
|
+
export async function getClusterInfo(context) {
|
|
35
35
|
try {
|
|
36
|
+
// If context is provided, use it
|
|
37
|
+
const contextArgs = context ? ['--context', context] : [];
|
|
38
|
+
// Get all config info in one command
|
|
39
|
+
const { stdout: configJson } = await execa('kubectl', [
|
|
40
|
+
'config',
|
|
41
|
+
'view',
|
|
42
|
+
'--minify',
|
|
43
|
+
'-o',
|
|
44
|
+
'json',
|
|
45
|
+
...contextArgs,
|
|
46
|
+
]);
|
|
47
|
+
const config = JSON.parse(configJson);
|
|
48
|
+
const currentContext = config['current-context'] || '';
|
|
49
|
+
const contextData = config.contexts?.find((c) => c.name === currentContext);
|
|
50
|
+
const namespace = contextData?.context?.namespace || 'default';
|
|
51
|
+
// Detect cluster type from context name
|
|
36
52
|
const clusterInfo = await detectClusterType();
|
|
53
|
+
clusterInfo.context = currentContext;
|
|
54
|
+
clusterInfo.namespace = namespace;
|
|
37
55
|
if (clusterInfo.error) {
|
|
38
56
|
return clusterInfo;
|
|
39
57
|
}
|
|
@@ -41,12 +59,12 @@ export async function getClusterIp(_context) {
|
|
|
41
59
|
switch (clusterInfo.type) {
|
|
42
60
|
case 'minikube':
|
|
43
61
|
try {
|
|
44
|
-
const { stdout } = await
|
|
62
|
+
const { stdout } = await execa('minikube', ['ip']);
|
|
45
63
|
ip = stdout.trim();
|
|
46
64
|
}
|
|
47
65
|
catch {
|
|
48
66
|
// Fallback to kubectl if minikube command fails
|
|
49
|
-
const { stdout } = await
|
|
67
|
+
const { stdout } = await execa('kubectl', [
|
|
50
68
|
'get',
|
|
51
69
|
'nodes',
|
|
52
70
|
'-o',
|
|
@@ -56,7 +74,7 @@ export async function getClusterIp(_context) {
|
|
|
56
74
|
}
|
|
57
75
|
break;
|
|
58
76
|
case 'kind': {
|
|
59
|
-
const { stdout: kindOutput } = await
|
|
77
|
+
const { stdout: kindOutput } = await execa('kubectl', [
|
|
60
78
|
'get',
|
|
61
79
|
'nodes',
|
|
62
80
|
'-o',
|
|
@@ -69,7 +87,7 @@ export async function getClusterIp(_context) {
|
|
|
69
87
|
ip = 'localhost';
|
|
70
88
|
break;
|
|
71
89
|
case 'k3s': {
|
|
72
|
-
const { stdout: k3sOutput } = await
|
|
90
|
+
const { stdout: k3sOutput } = await execa('kubectl', [
|
|
73
91
|
'get',
|
|
74
92
|
'nodes',
|
|
75
93
|
'-o',
|
|
@@ -81,7 +99,7 @@ export async function getClusterIp(_context) {
|
|
|
81
99
|
case 'cloud':
|
|
82
100
|
// For cloud clusters, try to get the external IP or load balancer IP
|
|
83
101
|
try {
|
|
84
|
-
const { stdout: lbOutput } = await
|
|
102
|
+
const { stdout: lbOutput } = await execa('kubectl', [
|
|
85
103
|
'get',
|
|
86
104
|
'svc',
|
|
87
105
|
'-n',
|
|
@@ -92,7 +110,7 @@ export async function getClusterIp(_context) {
|
|
|
92
110
|
]);
|
|
93
111
|
ip = lbOutput.trim();
|
|
94
112
|
if (!ip) {
|
|
95
|
-
const { stdout: hostnameOutput } = await
|
|
113
|
+
const { stdout: hostnameOutput } = await execa('kubectl', [
|
|
96
114
|
'get',
|
|
97
115
|
'svc',
|
|
98
116
|
'-n',
|
|
@@ -106,7 +124,7 @@ export async function getClusterIp(_context) {
|
|
|
106
124
|
}
|
|
107
125
|
catch {
|
|
108
126
|
// Fallback to node IP
|
|
109
|
-
const { stdout: nodeOutput } = await
|
|
127
|
+
const { stdout: nodeOutput } = await execa('kubectl', [
|
|
110
128
|
'get',
|
|
111
129
|
'nodes',
|
|
112
130
|
'-o',
|
|
@@ -116,7 +134,7 @@ export async function getClusterIp(_context) {
|
|
|
116
134
|
}
|
|
117
135
|
break;
|
|
118
136
|
default: {
|
|
119
|
-
const { stdout: defaultOutput } = await
|
|
137
|
+
const { stdout: defaultOutput } = await execa('kubectl', [
|
|
120
138
|
'get',
|
|
121
139
|
'nodes',
|
|
122
140
|
'-o',
|
|
@@ -129,6 +147,9 @@ export async function getClusterIp(_context) {
|
|
|
129
147
|
return { ...clusterInfo, ip };
|
|
130
148
|
}
|
|
131
149
|
catch (error) {
|
|
132
|
-
return {
|
|
150
|
+
return {
|
|
151
|
+
type: 'unknown',
|
|
152
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
153
|
+
};
|
|
133
154
|
}
|
|
134
155
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|