/** * Society Protocol — Adapter Host v1.0 * * HTTP bridge between Society P2P network and external AI agents. * Features: * - RESTful API for adapter registration * - Webhook support for push notifications * - Automatic step claiming based on capabilities * - Health monitoring * - SECURITY: API key authentication, rate limiting, CORS, input validation */ import { type Storage } from './storage.js'; import { type CocEngine } from './coc.js'; import { EventEmitter } from 'events'; import type { AdapterProfile } from './swp.js'; export interface SecurityConfig { apiKey?: string; apiKeyHeader?: string; allowedOrigins?: string[]; trustProxy?: boolean; rateLimitEnabled?: boolean; rateLimitWindowMs?: number; rateLimitMaxRequests?: number; maxBodySize?: string; securityHeaders?: boolean; } export interface AdapterConfig { port: number; host?: string; webhookSecret?: string; security?: SecurityConfig; } export interface AdapterRegistration { adapter_id: string; profile: AdapterProfile; registered_at: number; last_heartbeat: number; active_tasks: number; total_tasks_completed: number; health: 'healthy' | 'degraded' | 'unhealthy'; } export declare class AdapterHost extends EventEmitter { private storage; private coc; private config; private app; private server?; private adapters; private stepClaims; private healthCheckInterval?; private rateLimiter?; private cleanupInterval?; constructor(storage: Storage, coc: CocEngine, config: AdapterConfig); /** * Setup security middleware */ private setupSecurity; /** * Get client IP address */ private getClientIp; /** * Get client identifier for rate limiting */ private getClientIdentifier; /** * Constant-time string comparison to prevent timing attacks */ private constantTimeCompare; start(): void; stop(): void; private getParam; private sanitizeString; private sanitizeUrl; private isPrivateHost; private setupRoutes; private handleRegister; private handleGetAdapter; private handleUpdateCapabilities; private handleHeartbeat; private handlePollPending; private handleClaimStep; private handleSubmitStep; private handleGetStep; private handleListAdapters; private handleMetrics; private setupEventListeners; private findMatchingSteps; private notifyMatchingAdapters; private sendWebhookNotification; private runHealthChecks; getAdapter(adapterId: string): AdapterRegistration | undefined; getActiveAdapters(): AdapterRegistration[]; getStats(): { totalAdapters: number; healthyAdapters: number; totalActiveTasks: number; stepsClaimed: number; }; } //# sourceMappingURL=adapters.d.ts.map