/** * Inter-Agent Protocol (I.A.P.) v1.0.0 * * Protocol flow definitions and state machine logic */ import { MessageType, TaskStatus, AgentId, TaskId } from './types'; /** * Protocol flow states */ export declare enum FlowState { DISCONNECTED = "disconnected", HANDSHAKING = "handshaking", CONNECTED = "connected", IDLE = "idle", DISCOVERING = "discovering", PROPOSING = "proposing", BIDDING = "bidding", ASSIGNING = "assigning", EXECUTING = "executing", TRANSFERRING_CONTEXT = "transferring_context", COMPLETING = "completing", ERROR = "error", DISCONNECTING = "disconnecting" } /** * Valid state transitions */ export declare const VALID_TRANSITIONS: Record; /** * Message type to state mapping */ export declare const MESSAGE_TO_STATE: Record; /** * Protocol flow definitions */ export interface ProtocolFlow { name: string; description: string; steps: FlowStep[]; } /** * Individual step in a protocol flow */ export interface FlowStep { step: number; actor: 'agent' | 'router' | 'any'; messageType: MessageType; description: string; required: boolean; nextSteps?: number[]; } /** * Connection Flow: Agent joins the network */ export declare const CONNECTION_FLOW: ProtocolFlow; /** * Discovery Flow: Agent discovers available capabilities */ export declare const DISCOVERY_FLOW: ProtocolFlow; /** * Task Negotiation Flow: Task proposal, bidding, and assignment */ export declare const TASK_NEGOTIATION_FLOW: ProtocolFlow; /** * Context Transfer Flow: Stateful handoff between agents */ export declare const CONTEXT_TRANSFER_FLOW: ProtocolFlow; /** * Validates if a state transition is allowed */ export declare function isValidTransition(from: FlowState, to: FlowState): boolean; /** * Gets the expected state for a message type */ export declare function getStateForMessage(messageType: MessageType): FlowState; /** * Determines the next expected message types for a given state */ export declare function getExpectedMessages(state: FlowState): MessageType[]; /** * Task lifecycle tracker */ export declare class TaskLifecycle { private taskStates; private taskHistory; /** * Updates task status */ updateStatus(taskId: TaskId, status: TaskStatus): void; /** * Gets current task status */ getStatus(taskId: TaskId): TaskStatus | undefined; /** * Gets task history */ getHistory(taskId: TaskId): TaskStatus[]; /** * Validates task status transition */ private isValidTaskTransition; /** * Removes completed or failed tasks */ cleanup(olderThanMs?: number): void; } /** * Flow execution context */ export interface FlowContext { currentState: FlowState; agentId: AgentId; sessionId?: string; activeTaskId?: TaskId; lastMessageType?: MessageType; lastTransitionTime: number; } /** * Creates a new flow context */ export declare function createFlowContext(agentId: AgentId): FlowContext; /** * Transitions flow context to a new state */ export declare function transitionFlow(context: FlowContext, messageType: MessageType): FlowContext; //# sourceMappingURL=flows.d.ts.map