@astrasyncai/sdk
Version:
Universal SDK for registering AI agents with AstraSync
60 lines • 2.58 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateTrustScore = exports.detectAgentFormat = exports.AstraSync = void 0;
const api_1 = require("./utils/api");
const detector_1 = require("./utils/detector");
const trustScore_1 = require("./utils/trustScore");
class AstraSync {
api;
constructor(options) {
this.api = new api_1.AstraSyncAPI(options.developerEmail, options.apiUrl);
}
async register(agentData) {
// Auto-detect format
const detection = (0, detector_1.detectAgentFormat)(agentData);
if (detection.format === 'unknown' || !detection.agent) {
throw new Error('Unable to detect agent format. Please check your agent data.');
}
// Calculate trust score
const trustScore = (0, trustScore_1.calculateTrustScore)(detection.agent);
// Register with API
const response = await this.api.registerAgent(detection.agent);
// Enhance response with detected format
return {
...response,
detectedFormat: detection.format,
trustScore: `${trustScore}%`
};
}
async verify(agentId) {
return this.api.verifyAgent(agentId);
}
detect(agentData) {
return (0, detector_1.detectAgentFormat)(agentData).format;
}
async health() {
return this.api.checkHealth();
}
}
exports.AstraSync = AstraSync;
// Export everything
__exportStar(require("./types"), exports);
var detector_2 = require("./utils/detector");
Object.defineProperty(exports, "detectAgentFormat", { enumerable: true, get: function () { return detector_2.detectAgentFormat; } });
var trustScore_2 = require("./utils/trustScore");
Object.defineProperty(exports, "calculateTrustScore", { enumerable: true, get: function () { return trustScore_2.calculateTrustScore; } });
//# sourceMappingURL=index.js.map