/** * Inter-Agent Protocol (I.A.P.) v1.0.0 * * TypeScript type definitions for standardized agent-to-agent communication * via the Subconscious Router. */ /** * Unique identifier for agents in the network */ export type AgentId = string; /** * Unique identifier for tasks */ export type TaskId = string; /** * Unique identifier for messages */ export type MessageId = string; /** * Timestamp in ISO 8601 format */ export type Timestamp = string; /** * Capability types that agents can advertise */ export declare enum CapabilityType { TEXT_GENERATION = "text_generation", CODE_EXECUTION = "code_execution", WEB_SEARCH = "web_search", DATA_ANALYSIS = "data_analysis", IMAGE_GENERATION = "image_generation", FILE_OPERATIONS = "file_operations", API_INTEGRATION = "api_integration", CUSTOM = "custom" } /** * Message types in the I.A.P. protocol */ export declare enum MessageType { HANDSHAKE = "handshake", HANDSHAKE_ACK = "handshake_ack", CAPABILITY_DISCOVERY = "capability_discovery", CAPABILITY_RESPONSE = "capability_response", TASK_PROPOSAL = "task_proposal", TASK_BID = "task_bid", TASK_ASSIGNMENT = "task_assignment", TASK_ACCEPTANCE = "task_acceptance", TASK_REJECTION = "task_rejection", CONTEXT_TRANSFER = "context_transfer", TASK_RESULT = "task_result", ERROR = "error", HEARTBEAT = "heartbeat", DISCONNECT = "disconnect" } /** * Status of a task in the system */ export declare enum TaskStatus { PROPOSED = "proposed", BIDDING = "bidding", ASSIGNED = "assigned", IN_PROGRESS = "in_progress", COMPLETED = "completed", FAILED = "failed", CANCELLED = "cancelled" } /** * Describes a specific capability/tool available to an agent */ export interface AgentCapability { /** Unique identifier for this capability */ id: string; /** Type of capability */ type: CapabilityType; /** Human-readable name */ name: string; /** Detailed description of what this capability does */ description: string; /** JSON Schema describing input parameters */ inputSchema?: Record; /** JSON Schema describing output format */ outputSchema?: Record; /** Estimated cost in tokens or API credits */ estimatedCost?: number; /** Average execution time in milliseconds */ averageLatency?: number; /** Additional metadata */ metadata?: Record; } /** * Initial handshake message sent by an agent joining the network */ export interface AgentHandshake { /** Unique identifier for this agent */ agentId: AgentId; /** Human-readable agent name */ name: string; /** Agent version (semantic versioning) */ version: string; /** Framework or platform (e.g., "LangChain", "CrewAI", "AutoGPT") */ framework?: string; /** List of capabilities this agent provides */ capabilities: AgentCapability[]; /** Maximum concurrent tasks this agent can handle */ maxConcurrentTasks?: number; /** Agent's current load (0.0 to 1.0) */ currentLoad?: number; /** Additional metadata about the agent */ metadata?: Record; /** Protocol version this agent supports */ protocolVersion: string; } /** * Acknowledgment of successful handshake */ export interface HandshakeAck { /** Router's acknowledgment */ success: boolean; /** Assigned session ID */ sessionId: string; /** Router version */ routerVersion: string; /** Number of currently connected agents */ connectedAgents: number; /** Optional welcome message or instructions */ message?: string; } /** * Request to discover available capabilities in the network */ export interface CapabilityDiscovery { /** Agent requesting discovery */ requesterId: AgentId; /** Optional filter by capability type */ filterByType?: CapabilityType[]; /** Optional filter by minimum performance criteria */ minPerformance?: { maxLatency?: number; maxCost?: number; }; } /** * Response containing available capabilities */ export interface CapabilityResponse { /** Map of agent IDs to their capabilities */ agents: Record; /** Total number of available agents */ totalAgents: number; /** Timestamp of response */ timestamp: Timestamp; } /** * Proposal for a task to be executed */ export interface TaskProposal { /** Unique task identifier */ taskId: TaskId; /** Agent proposing the task */ proposerId: AgentId; /** Human-readable task description */ description: string; /** Required capability type */ requiredCapability: CapabilityType; /** Specific capability ID if known */ specificCapabilityId?: string; /** Input parameters for the task */ input: Record; /** Maximum acceptable latency in milliseconds */ maxLatency?: number; /** Maximum acceptable cost */ maxCost?: number; /** Priority level (1-10, higher is more urgent) */ priority?: number; /** Deadline for task completion */ deadline?: Timestamp; /** Context data needed for execution */ context?: Record; } /** * Bid from an agent to execute a proposed task */ export interface TaskBid { /** Reference to the task being bid on */ taskId: TaskId; /** Agent making the bid */ bidderId: AgentId; /** Estimated execution time in milliseconds */ estimatedLatency: number; /** Estimated cost in tokens or credits */ estimatedCost: number; /** Confidence score (0.0 to 1.0) in successful execution */ confidence: number; /** Agent's current queue depth */ queueDepth: number; /** Earliest time the agent can start (if queued) */ earliestStartTime?: Timestamp; /** Additional notes or conditions */ notes?: string; } /** * Assignment of a task to a specific agent */ export interface TaskAssignment { /** Task being assigned */ taskId: TaskId; /** Agent assigned to execute */ assignedTo: AgentId; /** Original proposer */ proposerId: AgentId; /** Timestamp of assignment */ assignedAt: Timestamp; /** Expected completion time */ expectedCompletion?: Timestamp; } /** * Transfer of context/state between agents */ export interface ContextTransfer { /** Source agent */ fromAgent: AgentId; /** Destination agent */ toAgent: AgentId; /** Related task ID */ taskId: TaskId; /** Context type identifier */ contextType: string; /** The actual context data */ data: Record; /** Optional embedding vector for semantic indexing */ embedding?: number[]; /** Compression format if data is compressed */ compression?: 'gzip' | 'brotli' | 'none'; /** Checksum for data integrity */ checksum?: string; } /** * Result of a completed task */ export interface TaskResult { /** Task that was completed */ taskId: TaskId; /** Agent that executed the task */ executorId: AgentId; /** Execution status */ status: TaskStatus; /** Output data */ output?: Record; /** Error information if failed */ error?: { code: string; message: string; details?: any; }; /** Actual execution time in milliseconds */ actualLatency: number; /** Actual cost incurred */ actualCost: number; /** Timestamp of completion */ completedAt: Timestamp; /** Optional metadata about execution */ metadata?: Record; } /** * Error message */ export interface ErrorMessage { /** Error code */ code: string; /** Human-readable error message */ message: string; /** Related message ID if applicable */ relatedMessageId?: MessageId; /** Related task ID if applicable */ relatedTaskId?: TaskId; /** Additional error details */ details?: any; /** Whether the error is recoverable */ recoverable: boolean; } /** * Base message structure for all I.A.P. messages */ export interface IAPMessage { /** Unique message identifier */ messageId: MessageId; /** Type of message */ type: MessageType; /** Sender agent ID */ from: AgentId; /** Recipient agent ID (or 'router' for broadcast) */ to: AgentId | 'router'; /** Message timestamp */ timestamp: Timestamp; /** Protocol version */ protocolVersion: string; /** Message payload (type depends on message type) */ payload: AgentHandshake | HandshakeAck | CapabilityDiscovery | CapabilityResponse | TaskProposal | TaskBid | TaskAssignment | TaskResult | ContextTransfer | ErrorMessage | Record; /** Optional correlation ID for request-response tracking */ correlationId?: string; /** Optional metadata */ metadata?: Record; } /** * Heartbeat message to maintain connection */ export interface Heartbeat { /** Agent sending heartbeat */ agentId: AgentId; /** Current load (0.0 to 1.0) */ currentLoad: number; /** Number of active tasks */ activeTasks: number; /** Uptime in seconds */ uptime: number; } /** * Disconnect notification */ export interface DisconnectMessage { /** Agent disconnecting */ agentId: AgentId; /** Reason for disconnect */ reason: string; /** Whether disconnect is graceful */ graceful: boolean; } //# sourceMappingURL=types.d.ts.map