UNPKG

agentic-qe

Version:

Agentic Quality Engineering Fleet System - AI-driven quality management platform

189 lines 5.17 kB
/** * Agent - Base class for all autonomous agents in the AQE Fleet * * @remarks * The Agent class provides the foundational capabilities for autonomous agents * including lifecycle management, task execution, capability advertisement, * and performance metrics tracking. * * All concrete agent implementations must extend this class and implement * the abstract methods for agent-specific behavior. * * @example * ```typescript * class CustomAgent extends Agent { * protected async onInitialize(): Promise<void> { * // Custom initialization logic * } * * protected async executeTaskLogic(task: Task): Promise<any> { * // Custom task execution logic * return { success: true }; * } * } * ``` * * @public */ /// <reference types="node" /> import { EventEmitter } from 'events'; import { Task } from './Task'; import { EventBus } from './EventBus'; import { Logger } from '../utils/Logger'; /** * Operational status of an agent * * @public */ export declare enum AgentStatus { /** Agent is being initialized */ INITIALIZING = "initializing", /** Agent is idle and ready to accept tasks */ IDLE = "idle", /** Agent is active and monitoring for tasks */ ACTIVE = "active", /** Agent is currently executing a task */ BUSY = "busy", /** Agent encountered an error */ ERROR = "error", /** Agent is in the process of stopping */ STOPPING = "stopping", /** Agent has been stopped */ STOPPED = "stopped" } /** * Describes a capability that an agent can perform * * @public */ export interface AgentCapability { /** Name of the capability */ name: string; /** Version of the capability implementation */ version: string; /** Human-readable description */ description: string; /** Types of tasks this capability can handle */ taskTypes: string[]; } /** * Performance metrics for an agent * * @public */ export interface AgentMetrics { /** Total number of tasks completed successfully */ tasksCompleted: number; /** Total number of failed tasks */ tasksFailured: number; /** Average task execution time in milliseconds */ averageExecutionTime: number; /** Agent uptime in milliseconds */ uptime: number; /** Timestamp of last activity */ lastActivity: Date; } export declare abstract class Agent extends EventEmitter { protected readonly id: string; protected readonly type: string; protected readonly config: any; protected readonly eventBus: EventBus; protected readonly logger: Logger; protected status: AgentStatus; protected currentTask: Task | null; protected capabilities: AgentCapability[]; protected metrics: AgentMetrics; protected startTime: Date | null; constructor(id: string, type: string, config: any, eventBus: EventBus); /** * Initialize the agent and its capabilities * * @remarks * Performs initialization sequence including capability setup and * agent-specific initialization logic. * * @returns A promise that resolves when initialization is complete * @throws {Error} If initialization fails * @fires agent:initialized * * @public */ initialize(): Promise<void>; /** * Start the agent */ start(): Promise<void>; /** * Stop the agent */ stop(): Promise<void>; /** * Assign a task to this agent for execution * * @param task - The task to assign * @returns A promise that resolves when the task is assigned * @throws {Error} If agent is not available or cannot handle the task type * @fires task:assigned * * @public */ assignTask(task: Task): Promise<void>; /** * Execute a task */ private executeTask; /** * Check if agent can handle a specific task type * * @param taskType - The task type to check * @returns True if the agent has a capability for this task type * * @public */ canHandleTaskType(taskType: string): boolean; /** * Get agent ID */ getId(): string; /** * Get agent type */ getType(): string; /** * Get agent status */ getStatus(): AgentStatus; /** * Get agent capabilities */ getCapabilities(): AgentCapability[]; /** * Get agent performance metrics * * @returns Current metrics including task counts and execution times * * @public */ getMetrics(): AgentMetrics; /** * Get current task */ getCurrentTask(): Task | null; /** * Abstract methods to be implemented by specific agent types */ protected abstract onInitialize(): Promise<void>; protected abstract onStart(): Promise<void>; protected abstract onStop(): Promise<void>; protected abstract executeTaskLogic(task: Task): Promise<any>; protected abstract initializeCapabilities(): Promise<void>; /** * Update agent metrics */ private updateMetrics; /** * Setup event handlers */ private setupEventHandlers; } //# sourceMappingURL=Agent.d.ts.map