Files
hive/mcp-server/dist/hive-client.js
anthonyrawlins fc0eec91ef Complete Hive platform functionality and expand cluster to 7 agents
Major Features Added:
- Fix Socket.IO connectivity by updating Dockerfile to use socket_app
- Resolve distributed workflows API to return arrays instead of errors
- Expand agent coverage from 3 to 7 agents (added OAK and ROSEWOOD)
- Create comprehensive systemd service for MCP server with auto-discovery
- Add daemon mode with periodic agent discovery every 5 minutes
- Implement comprehensive test suite with 100% pass rate

Infrastructure Improvements:
- Enhanced database connection handling with retry logic
- Improved agent registration with persistent storage
- Added proper error handling for distributed workflows endpoint
- Created management scripts for service lifecycle operations

Agent Cluster Expansion:
- ACACIA: deepseek-r1:7b (kernel_dev)
- WALNUT: starcoder2:15b (pytorch_dev)
- IRONWOOD: deepseek-coder-v2 (profiler)
- OAK: codellama:latest (docs_writer)
- OAK-TESTER: deepseek-r1:latest (tester)
- ROSEWOOD: deepseek-coder-v2:latest (kernel_dev)
- ROSEWOOD-VISION: llama3.2-vision:11b (tester)

System Status: All 7 agents healthy, Socket.IO operational, MCP server fully functional

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-10 08:41:34 +10:00

123 lines
4.1 KiB
JavaScript

/**
* Hive Client
*
* Handles communication with the Hive backend API
*/
import axios from 'axios';
import WebSocket from 'ws';
export class HiveClient {
api;
config;
wsConnection;
constructor(config) {
this.config = {
baseUrl: process.env.HIVE_API_URL || 'https://hive.home.deepblack.cloud/api',
wsUrl: process.env.HIVE_WS_URL || 'wss://hive.home.deepblack.cloud/socket.io',
timeout: parseInt(process.env.HIVE_TIMEOUT || '30000'),
...config,
};
this.api = axios.create({
baseURL: this.config.baseUrl,
timeout: this.config.timeout,
headers: {
'Content-Type': 'application/json',
},
});
}
async testConnection() {
try {
const response = await this.api.get('/health');
return response.data.status === 'healthy' || response.status === 200;
}
catch (error) {
throw new Error(`Failed to connect to Hive: ${error}`);
}
}
// Agent Management
async getAgents() {
const response = await this.api.get('/api/agents');
return response.data.agents || [];
}
async registerAgent(agentData) {
const response = await this.api.post('/api/agents', agentData);
return response.data;
}
// Task Management
async createTask(taskData) {
const response = await this.api.post('/api/tasks', taskData);
return response.data;
}
async getTask(taskId) {
const response = await this.api.get(`/api/tasks/${taskId}`);
return response.data;
}
async getTasks(filters) {
const params = new URLSearchParams();
if (filters?.status)
params.append('status', filters.status);
if (filters?.agent)
params.append('agent', filters.agent);
if (filters?.limit)
params.append('limit', filters.limit.toString());
const response = await this.api.get(`/api/tasks?${params}`);
return response.data.tasks || [];
}
// Workflow Management
async getWorkflows() {
const response = await this.api.get('/api/workflows');
return response.data.workflows || [];
}
async createWorkflow(workflowData) {
const response = await this.api.post('/api/workflows', workflowData);
return response.data;
}
async executeWorkflow(workflowId, inputs) {
const response = await this.api.post(`/api/workflows/${workflowId}/execute`, { inputs });
return response.data;
}
// Monitoring and Status
async getClusterStatus() {
const response = await this.api.get('/api/status');
return response.data;
}
async getMetrics() {
const response = await this.api.get('/api/metrics');
return response.data;
}
async getExecutions(workflowId) {
const url = workflowId ? `/api/executions?workflow_id=${workflowId}` : '/api/executions';
const response = await this.api.get(url);
return response.data.executions || [];
}
// Real-time Updates via WebSocket
async connectWebSocket(topic = 'general') {
return new Promise((resolve, reject) => {
const ws = new WebSocket(`${this.config.wsUrl}/ws/${topic}`);
ws.on('open', () => {
console.log(`🔗 Connected to Hive WebSocket (${topic})`);
this.wsConnection = ws;
resolve(ws);
});
ws.on('error', (error) => {
console.error('WebSocket error:', error);
reject(error);
});
ws.on('message', (data) => {
try {
const message = JSON.parse(data.toString());
console.log('📨 Hive update:', message);
}
catch (error) {
console.error('Failed to parse WebSocket message:', error);
}
});
});
}
async disconnect() {
if (this.wsConnection) {
this.wsConnection.close();
this.wsConnection = undefined;
}
}
}
//# sourceMappingURL=hive-client.js.map