UNPKG

@astrasyncai/sdk

Version:

Universal SDK for registering AI agents with AstraSync

58 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AstraSyncAPI = void 0; const DEFAULT_API_URL = 'https://astrasync-api-production.up.railway.app'; class AstraSyncAPI { apiUrl; email; constructor(email, apiUrl = DEFAULT_API_URL) { this.email = email; this.apiUrl = apiUrl; } async registerAgent(agent) { const response = await fetch(`${this.apiUrl}/v1/register`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-source': 'sdk' }, body: JSON.stringify({ email: this.email, agent: { ...agent, // Spread first to allow overrides (fixes TS error) owner: this.email, capabilities: agent.capabilities || [], version: agent.version || '1.0.0' } }) }); if (!response.ok) { const error = await response.text(); throw new Error(`Registration failed: ${error}`); } // Type assertion to fix TS error return response.json(); } async verifyAgent(agentId) { try { const response = await fetch(`${this.apiUrl}/v1/verify/${agentId}`); // Type assertion for the response const data = await response.json(); return data.exists === true; } catch { return false; } } async checkHealth() { try { const response = await fetch(`${this.apiUrl}/`); return response.ok; } catch { return false; } } } exports.AstraSyncAPI = AstraSyncAPI; //# sourceMappingURL=api.js.map