export interface XMTPMessage { /** Sender identifier. May be an Ethereum address (0x-prefixed) or an XMTP InboxId. * H-1 fix: Changed from `0x${string}` to `string` because XMTP InboxId is NOT * a valid Ethereum address. Consumers must validate format before using as an address. */ sender: string; content: string; contentType: string; timestamp: number; conversationId: string; } export type MessageHandler = (message: XMTPMessage) => Promise; /** Request to execute a service over XMTP */ export interface ServiceRequest { type: 'service-request'; /** Unique request identifier for correlating responses */ id?: string; /** Name of the service to invoke */ service: string; /** Request payload passed to the service handler */ payload: Record; /** Optional payment information for paid services */ payment?: { amount: string; currency: string; }; } /** Inquiry about a service's details, pricing, or availability */ export interface ServiceInquiry { type: 'service-inquiry'; /** Name of the service to inquire about */ service: string; /** Optional question about the service */ question?: string; } /** Response from a service execution */ export interface ServiceResponse { type: 'service-response'; /** Correlating request ID */ requestId?: string; /** Execution status */ status: 'success' | 'error' | 'payment-required'; /** Result data or error message */ result: unknown; /** HTTP endpoint for paid service access via x402 */ httpEndpoint?: string; /** Usage instructions */ usage?: unknown; /** List of available service names (returned on unknown service errors) */ available?: string[]; } /** Service metadata returned in capabilities or inquiry responses */ export interface ServiceDetail { name: string; description: string; price: string | null; method?: 'GET' | 'POST'; tags?: string[]; } /** Advertised capabilities menu for service discovery over XMTP */ export interface CapabilitiesResponse { type: 'capabilities'; /** Agent's Ethereum address */ agentAddress: `0x${string}`; /** Human-readable agent name */ name: string; /** All services offered by this agent */ services: ServiceDetail[]; /** Names of free (no payment required) services */ freeServices: string[]; /** Names of paid (x402 payment required) services */ paidServices: string[]; /** HTTP endpoint for x402-gated services */ httpEndpoint?: string; /** Usage examples for free and paid services */ usage?: { free: { type: string; service: string; payload: Record; } | null; paid: string | null; }; } /** Friend/connection request between agents */ export interface FriendRequest { type: 'friend-request'; /** Requester's Ethereum address */ agentAddress: `0x${string}`; /** Requester's display name */ name: string; /** Requester's reputation score (optional) */ reputation?: number; } /** Acceptance of a friend/connection request */ export interface FriendAccept { type: 'friend-accept'; /** Acceptor's Ethereum address */ agentAddress: `0x${string}`; /** Acceptor's display name */ name: string; } /** Error response for failed operations */ export interface ErrorResponse { type: 'error'; /** Human-readable error message */ error: string; /** Machine-readable error code */ code?: string; } /** Acknowledgement response for received messages */ export interface AckResponse { type: 'ack'; /** Type of message that was received */ received: string; /** Optional note about the acknowledgement */ note?: string; } /** Detailed service information returned in response to a service-inquiry */ export interface ServiceDetailsResponse { type: 'service-details'; /** Service name */ service: string; /** Whether the service exists on this agent */ available: boolean; /** Human-readable description (present when available=true) */ description?: string; /** Price string or null for free services (present when available=true) */ price?: string | null; /** HTTP method (present when available=true) */ method?: 'GET' | 'POST'; /** Whether the service requires payment (present when available=true) */ paid?: boolean; /** Capability tags (present when available=true) */ capabilities?: string[]; /** HTTP endpoint for x402 access (present when available=true) */ httpEndpoint?: string; /** Authentication method (present when available=true) */ authentication?: string; /** Payment method (present when available=true) */ payment?: string; /** List of all service names (present when available=false) */ allServices?: string[]; } /** Union of all structured message types exchanged over XMTP */ export type StructuredMessage = ServiceRequest | ServiceInquiry | ServiceResponse | ServiceDetailsResponse | CapabilitiesResponse | FriendRequest | FriendAccept | ErrorResponse | AckResponse; /** Handler function for executing a free service */ export type ServiceHandler = (sender: string, payload: Record) => Promise; /** Definition of a skill/service offered by an agent */ export interface SkillDefinition { /** Service name used for routing */ name: string; /** Human-readable description */ description: string; /** Price string (e.g., "$0.50") — null/undefined for free services */ price?: string; /** HTTP method for paid service access */ method?: 'GET' | 'POST'; /** Categorization tags */ tags?: string[]; } /** Configuration options for the MessageRouter */ export interface MessageRouterOptions { /** Skills/services this agent offers */ skills: SkillDefinition[]; /** Human-readable agent name */ agentName: string; /** Agent's Ethereum address */ agentAddress: `0x${string}`; /** HTTP endpoint for x402-gated paid services */ httpEndpoint?: string; /** Maximum messages per sender per minute (default 10) */ maxMessagesPerMinute?: number; /** Minimum reputation score required to use services (default 30) */ minReputationForService?: number; /** Async function to check a sender's reputation score */ reputationChecker?: (address: string) => Promise; /** Callback invoked when a friend request is received */ onFriendRequest?: (sender: string, req: FriendRequest) => Promise; /** Callback invoked when a friend accept is received */ onFriendAccept?: (sender: string, req: FriendAccept) => Promise; /** Fallback handler for plain text (non-JSON) messages. Return null to use default behavior. */ textFallbackHandler?: (sender: string, content: string) => Promise; } export interface XMTPConfig { /** XMTP environment */ env: 'production' | 'dev'; /** Path to store XMTP database files */ dbPath?: string; /** 32-byte hex encryption key for the XMTP database (0x-prefixed) */ dbEncryptionKey?: string; /** Rate limit: max messages per sender per minute (default 10) */ rateLimitPerMinute?: number; /** Reachability cache TTL in milliseconds (default 300_000 = 5 min) */ reachabilityCacheTtlMs?: number; /** Maximum message content length in bytes (default 10_000) */ maxMessageLength?: number; /** Enable auto-reply via MessageRouter for incoming messages (default false) */ autoReply?: boolean; } export interface XMTPConversation { id: string; peerAddress: `0x${string}`; createdAt: number; lastMessageAt?: number; lastMessagePreview?: string; } /** Context metadata attached to an incoming message for handler routing */ export interface MessageContext { sender: `0x${string}`; timestamp: number; conversationId: string; isStructured: boolean; structuredType?: string; } //# sourceMappingURL=messaging.d.ts.map