UNPKG

@agentdao/core

Version:

Core functionality, skills, and ready-made UI components for AgentDAO - Web3 subscriptions, content generation, social media, help support, live chat, RSS fetching, web search, and agent pricing integration

184 lines (183 loc) 4.82 kB
export interface A2AAgent { id: string; name: string; description: string; capabilities: string[]; endpoint: string; version: string; framework?: string; metadata?: Record<string, any>; } export interface A2ATask { id: string; type: 'delegate' | 'collaborate' | 'query' | 'stream'; description: string; input: any; expectedOutput?: any; priority?: 'low' | 'medium' | 'high' | 'urgent'; timeout?: number; requiresResponse?: boolean; } export interface A2AMessage { id: string; fromAgent: string; toAgent: string; task: A2ATask; timestamp: Date; status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled'; result?: any; error?: string; metadata?: Record<string, any>; } export interface A2AStreamMessage { id: string; messageId: string; chunk: any; isComplete: boolean; timestamp: Date; } export interface A2AProtocolConfig { agentId: string; agentName: string; agentDescription: string; capabilities: string[]; endpoint: string; version: string; framework?: string; discovery: { enabled: boolean; registryUrl?: string; autoRegister: boolean; heartbeatInterval: number; }; communication: { protocol: 'http' | 'websocket' | 'grpc'; timeout: number; retryAttempts: number; retryDelay: number; }; security: { enabled: boolean; apiKey?: string; jwtSecret?: string; allowedAgents?: string[]; encryptionEnabled: boolean; }; taskManagement: { maxConcurrentTasks: number; taskTimeout: number; autoRetry: boolean; retryLimit: number; }; streaming: { enabled: boolean; chunkSize: number; maxStreamDuration: number; }; database?: { endpoint: string; apiKey?: string; }; } export interface A2ATaskResult { success: boolean; data?: any; error?: string; metadata?: Record<string, any>; executionTime?: number; } export interface A2AAgentDiscovery { agents: A2AAgent[]; total: number; filters?: Record<string, any>; } export declare class A2AProtocolSkill { private config; private activeTasks; private agentRegistry; private messageQueue; private isRunning; constructor(config: A2AProtocolConfig); /** * Initialize the A2A Protocol skill */ initialize(): Promise<void>; /** * Register this agent in the A2A registry */ registerAgent(): Promise<void>; /** * Discover available agents */ discoverAgents(filters?: Record<string, any>): Promise<A2AAgent[]>; /** * Send a task to another agent */ delegateTask(targetAgentId: string, task: Omit<A2ATask, 'id'>, options?: { timeout?: number; priority?: 'low' | 'medium' | 'high' | 'urgent'; metadata?: Record<string, any>; }): Promise<A2AMessage>; /** * Send a streaming task to another agent */ streamTask(targetAgentId: string, task: Omit<A2ATask, 'id' | 'type'>, onChunk: (chunk: A2AStreamMessage) => void, options?: { timeout?: number; priority?: 'low' | 'medium' | 'high' | 'urgent'; }): Promise<void>; /** * Collaborate with multiple agents on a complex task */ collaborate(agentIds: string[], task: Omit<A2ATask, 'id'>, coordinationStrategy?: 'parallel' | 'sequential' | 'hierarchical'): Promise<A2ATaskResult[]>; /** * Wait for task completion */ waitForCompletion(messageId: string, timeout?: number): Promise<A2ATaskResult>; /** * Handle incoming tasks from other agents */ handleIncomingTask(message: A2AMessage): Promise<A2ATaskResult>; /** * Process delegated tasks */ private processDelegatedTask; /** * Process collaboration tasks */ private processCollaborationTask; /** * Process query tasks */ private processQueryTask; /** * Process streaming tasks */ private processStreamingTask; /** * Get agent status and health */ getAgentStatus(): { agentId: string; agentName: string; status: 'online' | 'offline' | 'busy'; activeTasks: number; capabilities: string[]; lastHeartbeat: Date; }; /** * Get task statistics */ getTaskStats(): { totalTasks: number; completedTasks: number; failedTasks: number; pendingTasks: number; averageExecutionTime: number; }; private validateConfig; private getAuthHeaders; private generateMessageId; private generateTaskId; private startDiscoveryService; private startMessageProcessor; }