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.
94 lines • 3.04 kB
JavaScript
import { blaxConfig } from '../config/blax.js';
export class BlaxApiClient {
baseUrl;
token;
constructor(token) {
this.baseUrl = blaxConfig.api.baseUrl;
this.token = token || process.env.BLAX_API_TOKEN;
}
async request(endpoint, options = {}) {
const url = `${this.baseUrl}${endpoint}`;
const headers = {
'Content-Type': 'application/json',
'User-Agent': 'blax-cli/1.0.0',
...(options.headers || {}),
};
if (this.token) {
headers['Authorization'] = `Bearer ${this.token}`;
}
try {
const response = await fetch(url, {
...options,
headers,
signal: AbortSignal.timeout(blaxConfig.api.timeout),
});
const data = await response.json();
if (!response.ok) {
return {
success: false,
error: data.error || `HTTP ${response.status}: ${response.statusText}`,
};
}
return {
success: true,
data: data,
meta: {
timestamp: Date.now(),
requestId: response.headers.get('X-Request-ID') || 'unknown',
version: response.headers.get('X-API-Version') || '1.0.0',
},
};
}
catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : String(error),
};
}
}
async getAgents() {
return this.request('/v1/agents');
}
async getAgent(agentId) {
return this.request(`/v1/agents/${agentId}`);
}
async getDeals() {
return this.request('/v1/deals');
}
async createDeal(deal) {
return this.request('/v1/deals', {
method: 'POST',
body: JSON.stringify(deal),
});
}
async executeSkill(agentId, skillName, args) {
return this.request(`/v1/agents/${agentId}/skills/${skillName}`, {
method: 'POST',
body: JSON.stringify({ args }),
});
}
async getAgentLogs(agentId, options = {}) {
const params = new URLSearchParams();
if (options.since)
params.set('since', options.since);
if (options.limit)
params.set('limit', options.limit.toString());
const query = params.toString();
const endpoint = `/v1/agents/${agentId}/logs${query ? `?${query}` : ''}`;
return this.request(endpoint);
}
async getSystemStatus() {
return this.request('/v1/status');
}
async authenticate(credentials) {
return this.request('/v1/auth/login', {
method: 'POST',
body: JSON.stringify(credentials),
});
}
setToken(token) {
this.token = token;
}
}
export const blaxApi = new BlaxApiClient();
//# sourceMappingURL=blaxApiClient.js.map