UNPKG

tlnt

Version:

TLNT - HMS-Powered Multi-Agent Platform with Government Agency Analysis, Deep Research, and Enterprise-Ready Deployment. Self-optimizing multi-domain AI agent with continuous learning and enterprise-grade performance monitoring.

160 lines 5.68 kB
/** * HMS-NET API Client * * Client for connecting to HMS-NET (Agent Network System) API * Provides agent orchestration and workflow management capabilities */ import axios from 'axios'; export class HMSNetClient { client; config; constructor(config) { this.config = { timeout: 30000, ...config, }; this.client = axios.create({ baseURL: this.config.baseURL, timeout: this.config.timeout, headers: { 'Content-Type': 'application/json', ...(this.config.apiKey && { 'Authorization': `Bearer ${this.config.apiKey}`, }), }, }); // Request interceptor for logging this.client.interceptors.request.use((config) => { console.log(`HMS-NET Request: ${config.method?.toUpperCase()} ${config.url}`); return config; }, (error) => { console.error('HMS-NET Request Error:', error); return Promise.reject(error); }); // Response interceptor for error handling this.client.interceptors.response.use((response) => { console.log(`HMS-NET Response: ${response.status} ${response.config.url}`); return response; }, (error) => { console.error('HMS-NET Response Error:', error.response?.status, error.response?.data); return Promise.reject(this.formatError(error)); }); } formatError(error) { if (error.response) { const message = error.response.data?.message || error.response.data?.error || 'HMS-NET API Error'; return new Error(`${message} (${error.response.status})`); } else if (error.request) { return new Error('HMS-NET connection timeout or network error'); } else { return new Error(`HMS-NET client error: ${error.message}`); } } // Health check async healthCheck() { const response = await this.client.get('/health'); return response.data; } // Agent Management async listAgents() { const response = await this.client.get('/api/v1/agents'); return response.data; } async createAgent(request) { const response = await this.client.post('/api/v1/agents', request); return response.data; } async getAgent(id) { const response = await this.client.get(`/api/v1/agents/${id}`); return response.data; } async updateAgent(id, updates) { const response = await this.client.put(`/api/v1/agents/${id}`, updates); return response.data; } async deleteAgent(id) { await this.client.delete(`/api/v1/agents/${id}`); } async executeAgent(id, request) { const response = await this.client.post(`/api/v1/agents/${id}/execute`, request); return response.data; } // Workflow Management async listWorkflows() { const response = await this.client.get('/api/v1/workflows'); return response.data; } async createWorkflow(request) { const response = await this.client.post('/api/v1/workflows', request); return response.data; } async getWorkflow(id) { const response = await this.client.get(`/api/v1/workflows/${id}`); return response.data; } async startWorkflow(id) { await this.client.post(`/api/v1/workflows/${id}/start`); } async stopWorkflow(id) { await this.client.post(`/api/v1/workflows/${id}/stop`); } async getWorkflowStatus(id) { const response = await this.client.get(`/api/v1/workflows/${id}/status`); return response.data; } // Data Processing (integrates with HMS-NFO) async requestDataProcessing(request) { const response = await this.client.post('/api/v1/data/request', request); return response.data; } async getDataProcessingStatus(id) { const response = await this.client.get(`/api/v1/data/status/${id}`); return response.data; } async getDataProcessingResult(id) { const response = await this.client.get(`/api/v1/data/result/${id}`); return response.data; } async requestAgencyAnalysis(agencyName, issueTopic, options = {}) { return this.requestDataProcessing({ type: 'agency-analysis', agent_id: `blax-agent-${Date.now()}`, parameters: { agency_name: agencyName, issue_topic: issueTopic, state: options.state, agency_type: options.agencyType, }, callback_url: options.callbackUrl, }); } async requestDeepResearch(query, options = {}) { return this.requestDataProcessing({ type: 'deep-research', agent_id: `blax-agent-${Date.now()}`, parameters: { query, depth: options.depth || 3, breadth: options.breadth || 5, }, callback_url: options.callbackUrl, }); } // Network Management async listNetworks() { const response = await this.client.get('/api/v1/networks'); return response.data; } async createNetwork(request) { const response = await this.client.post('/api/v1/networks', request); return response.data; } async getNetworkStatus(id) { const response = await this.client.get(`/api/v1/networks/${id}/status`); return response.data; } } export default HMSNetClient; //# sourceMappingURL=hmsNetClient.js.map