export declare enum MessageType { HandshakeInit = 1, HandshakeAck = 2, Ping = 16, Pong = 17, HttpRequest = 32, HttpResponse = 33, HttpResponseChunk = 34, HttpResponseEnd = 35, HttpResponseError = 36, HttpRequestChunk = 37, HttpRequestEnd = 38, HttpResponseAck = 39, HttpRequestCancel = 40, SpendingAuth = 80, AuthAck = 81, FreeUsageOpen = 82, FreeUsageAuth = 83, FreeUsageAck = 84, NeedFreeUsageAuth = 85, PaymentRequired = 86, NeedAuth = 88, CloseChannelRequest = 89, CloseChannelResult = 90, PeerReport = 96, ReportAck = 97, PeerRating = 112, RatingQuery = 113, RatingResponse = 114, VerificationResponseAuth = 128, SweepRequest = 160, SweepReceipt = 161, Disconnect = 240, Error = 255 } import type { UnitBillingUsageReportV1 } from "./billing.js"; export declare const CONNECTION_CAPABILITY_RESPONSE_AUTH_V1: "verification.response-auth.v1"; export declare const CONNECTION_CAPABILITY_RELAYS_SWEEPS_V1: "payments.relays-sweeps.v1"; /** Seller honours buyer-initiated cooperative channel close (0x59 / 0x5A). */ export declare const CONNECTION_CAPABILITY_COOPERATIVE_CLOSE_V1: "payments.cooperative-close.v1"; /** * Seller runs periodic model health self-checks and unadvertises services * that stop working, so its announced service list reflects live health. */ export declare const CONNECTION_CAPABILITY_MODEL_HEALTH_V1: "seller.model-health.v1"; /** Peer signs WebRTC SDP over the signaling socket (DTLS fingerprint binding). */ export declare const CONNECTION_CAPABILITY_SIGNED_SDP_V1: "transport.signed-sdp.v1"; /** Peer supports the encrypted TCP transport handshake (X25519 + AES-256-GCM). */ export declare const CONNECTION_CAPABILITY_TCP_ENC_V1: "transport.tcp-enc.v1"; /** Peer has a working WebRTC stack and accepts `hello` signaling. */ export declare const CONNECTION_CAPABILITY_WEBRTC_V1: "transport.webrtc.v1"; export declare function peerRelaysSweeps(peer: { capabilities?: string[]; metadata?: { capabilities?: string[]; }; }): boolean; export declare function peerSupportsCooperativeClose(peer: { capabilities?: string[]; metadata?: { capabilities?: string[]; }; }): boolean; export declare function peerRunsModelHealthChecks(peer: { capabilities?: string[]; metadata?: { capabilities?: string[]; }; }): boolean; export interface FramedMessage { type: MessageType; messageId: number; payload: Uint8Array; } export declare const FRAME_HEADER_SIZE = 9; export declare const MAX_PAYLOAD_SIZE: number; /** * Buyer authorizes spending via a single EIP-712 SpendingAuth signature. * The signature covers channelId, cumulativeAmount, and metadataHash. */ export interface SpendingAuthPayload { channelId: string; cumulativeAmount: string; metadataHash: string; metadata: string; spendingAuthSig: string; reserveSalt?: string; reserveMaxAmount?: string; reserveDeadline?: number; /** Threshold SpendingAuth and final ReserveAuth executed together with a reserve change. */ reserveBatch?: { cumulativeAmount: string; metadataHash: string; metadata: string; spendingAuthSig: string; maxAmount: string; deadline: number; reserveAuthSig: string; }; /** * Marks the initial SpendingAuth of a one-off channel with the requestId it * pays for (the 402'd request, resent unchanged). The seller binds the new * channel to this request instead of treating it as the buyer's session * channel, never closes the session channel for it, and closes the one-off * channel once its single request is paid or abandoned. */ oneOffRequestId?: string; } /** * Seller acknowledges the spending authorization was reserved on-chain. */ export interface AuthAckPayload { channelId: string; } /** * Buyer opens a zero-price usage channel. This does not require deposits. */ export interface FreeUsageOpenPayload { channelId: string; salt: string; deadline: number; openSig: string; } /** * Buyer authorizes a cumulative zero-price usage record after the seller reports * usage for a served request. */ export interface FreeUsageAuthPayload { channelId: string; cumulativeInputTokens: string; cumulativeOutputTokens: string; sequence: string; metadataHash: string; metadata: string; deadline: number; usageSig: string; } /** * Seller acknowledges a free usage channel/open or record was accepted for * on-chain reporting. */ export interface FreeUsageAckPayload { channelId: string; acceptedSequence?: string; } /** * Seller asks the buyer to sign zero-price usage for a completed request. */ export interface NeedFreeUsageAuthPayload { channelId: string; requiredSequence: string; currentAcceptedSequence: string; requestId?: string; inputTokens?: string; outputTokens?: string; service?: string; } /** * Seller tells buyer what's needed to start a payment session. * Sent via PaymentMux alongside the HTTP 402 response. */ export interface PaymentRequiredPayload { minBudgetPerRequest: string; suggestedAmount: string; requestId: string; inputUsdPerMillion?: number; outputUsdPerMillion?: number; cachedInputUsdPerMillion?: number; /** * For budget-exhausted 402s on an existing channel: the cumulative * amount the buyer must sign to catch up with the seller's recorded * spend and unblock further requests. Absent for pre-session 402s. */ requiredCumulativeAmount?: string; /** Seller-side cumulative spend at the time the 402 was emitted. */ currentSpent?: string; /** Seller-side last-accepted cumulative at the time the 402 was emitted. */ currentAcceptedCumulative?: string; /** Channel ID for the exhausted session (so buyer can match it locally). */ channelId?: string; /** * On-chain reserve ceiling for this channel. When present and the seller's * `requiredCumulativeAmount` exceeds it, the channel is permanently * exhausted and the buyer must retire it and open a new one — no amount * of additional signing on the same channel will be accepted. */ reserveMaxAmount?: string; /** * Stable machine-readable code so callers can switch on it without coupling * to internal phrasing. Only set on irrecoverable 402s today. */ code?: PaymentRequiredCode; /** Present with code `one_off_channel_required`: open a dedicated channel for this request. */ oneOffPlan?: OneOffChannelPlan; } /** * Terms of a one-off channel that pays for exactly one request (a video). * Opened with reserve(openingReserveAmount). When the price is above the * opening reserve, the buyer also signs a SpendingAuth for * requiredCumulativeAmount (the contract's TOP_UP_SETTLED_THRESHOLD_BPS share * of the opening reserve, the "serious fee") and a ReserveAuth for the full * requestCost, which the seller submits with topUp(). */ export interface OneOffChannelPlan { openingReserveAmount: string; /** Cumulative SpendingAuth settled by topUp(); '0' when no top-up is needed. */ requiredCumulativeAmount: string; /** Independently verifiable estimated price of this request; also the final on-chain reserve. */ requestCost: string; } /** AntseedChannels FIRST_SIGN_CAP default: the largest reserve() a fresh channel may open with. */ export declare const DEFAULT_FIRST_SIGN_CAP = 1000000n; /** * AntseedChannels TOP_UP_SETTLED_THRESHOLD_BPS default, used by the seller when * the live, owner-configurable value (Base mainnet: 6500) cannot be read. It * only makes the serious fee larger, never too small to unlock topUp(). Buyers * never assume it: they refuse a plan they cannot check against the contract. */ export declare const DEFAULT_TOP_UP_SETTLED_THRESHOLD_BPS = 8500n; /** * The one canonical one-off plan for a price. Buyer and seller both compute * it from on-chain FIRST_SIGN_CAP and TOP_UP_SETTLED_THRESHOLD_BPS, so the * buyer can reject any other terms. */ export declare function computeOneOffChannelPlan(requestCost: bigint, firstSignCap: bigint, thresholdBps: bigint): OneOffChannelPlan; export declare const PAYMENT_CODE_CHANNEL_EXHAUSTED: "channel_exhausted"; export declare const PAYMENT_CODE_ONE_OFF_CHANNEL_REQUIRED: "one_off_channel_required"; export type PaymentRequiredCode = typeof PAYMENT_CODE_CHANNEL_EXHAUSTED | typeof PAYMENT_CODE_ONE_OFF_CHANNEL_REQUIRED; /** * Seller tells buyer that the current cumulative authorization is insufficient. * After every served request the seller includes the cost of that request so * the buyer can validate before signing a new SpendingAuth. */ export interface NeedAuthPayload { channelId: string; requiredCumulativeAmount: string; currentAcceptedCumulative: string; deposit: string; /** requestId of the request whose cost is reported below. */ requestId?: string; /** Seller-computed cost for the last request (USDC base units). */ lastRequestCost?: string; /** Total input tokens consumed by the last request (provider-style total — may include cached). */ inputTokens?: string; /** Output tokens consumed by the last request. */ outputTokens?: string; /** Cached input tokens consumed by the last request. */ cachedInputTokens?: string; /** * Fresh (non-cached) input tokens consumed by the last request. * Sent explicitly by the seller so the buyer doesn't have to guess at * OpenAI-vs-Anthropic cached-token semantics (OpenAI: prompt_tokens * includes cached; Anthropic: input_tokens excludes cached). When absent, * the buyer falls back to `inputTokens - cachedInputTokens` (OpenAI * convention) for backward compat with older sellers. */ freshInputTokens?: string; /** Service/model name for service-specific pricing validation. */ service?: string; /** Compact v1 unit billing evidence for cost validation. */ billingUsage?: UnitBillingUsageReportV1; } /** * Buyer asks the seller to close a payment channel now, skipping the on-chain * `requestClose()` → 15-minute grace → `withdraw()` path. * * The buyer MAY attach its latest SpendingAuth so the seller can close at that * cumulative even if the seller never received it (e.g. the frame was lost on * disconnect). The seller closes at whichever cumulative is higher — its own * last-accepted auth or the one attached here — so neither side can use this * message to under-report spend. * * All four auth fields travel together: either all are present or none are. */ export interface CloseChannelRequestPayload { version: 1; /** Channel the buyer wants closed. Must match the seller's active channel. */ channelId: string; /** Cumulative USDC (base units) the attached signature authorizes. */ cumulativeAmount?: string; /** bytes32 keccak256 of `metadata`. */ metadataHash?: string; /** Hex-encoded abi.encode(...) usage metadata covered by the signature. */ metadata?: string; /** EIP-712 SpendingAuth signature over (channelId, cumulativeAmount, metadataHash). */ spendingAuthSig?: string; } /** Why a seller declined to close a channel on request. */ export declare const CLOSE_CHANNEL_REJECT_CODES: readonly ["busy", "pending_auth", "no_channel", "invalid_auth", "close_failed", "unsupported"]; export type CloseChannelRejectCode = typeof CLOSE_CHANNEL_REJECT_CODES[number]; /** * Seller's answer to a CloseChannelRequest. On success it carries the * transaction hash of the on-chain `close()`; on refusal, a stable code the * buyer can switch on. */ export interface CloseChannelResultPayload { version: 1; channelId: string; status: 'closed' | 'rejected'; /** Present when status === 'closed'. */ txHash?: string; /** Cumulative the channel was closed at (base units). Present on success. */ finalAmount?: string; /** Present when status === 'rejected'. */ code?: CloseChannelRejectCode; /** Human-readable detail. Never load-bearing — switch on `code`. */ reason?: string; /** Hint for 'busy' / 'pending_auth': wait this long before retrying. */ retryAfterMs?: number; /** For 'pending_auth': the cumulative the buyer must sign before retrying. */ requiredCumulativeAmount?: string; } /** * Buyer broadcasts a signed gasless deposit sweep for permissionless relayers * (sellers by default) to submit on-chain. Carries everything * AntseedDepositRelay.sweepDeposit needs; the relayer earns the contract's * fixed, immutable FEE in USDC. The single EIP-3009 signature — addressed to * the relay contract — is the buyer's consent to those terms. Replay-safe via * the EIP-3009 nonce; losing a submission race is harmless. */ export interface SweepRequestPayload { version: 1; evmChainId: number; /** AntseedDepositRelay address the buyer signed against. Relayers must only * submit when this matches their own configured relay address. */ relayAddress: string; from: string; /** Total USDC pulled via EIP-3009, base units (uint256 decimal string). */ amount: string; validAfter: number; validBefore: number; /** EIP-3009 authorization nonce (bytes32 hex). Also the correlation key. */ nonce: string; /** Buyer signature over the USDC ReceiveWithAuthorization typed data. */ sig3009: string; } export type SweepReceiptStatus = 'submitted' | 'confirmed' | 'rejected'; /** * Optional relayer progress report for a SweepRequest, correlated by the * EIP-3009 nonce. Purely informational — the buyer's source of truth is its * Deposits balance on-chain. */ export interface SweepReceiptPayload { version: 1; authNonce: string; status: SweepReceiptStatus; txHash?: string; reason?: string; } /** * Seller-signed commitment for one completed inference response. * Carries hashes and context only; plaintext request/response bytes stay local. */ export interface ResponseAuthPayload { version: 1; requestId: string; channelId?: string; buyerPeerId: string; sellerPeerId: string; advertisedService: string; provider: string; statusCode: number; requestHash: string; responseHash: string; responseStartedAt: number; responseCompletedAt: number; signature: string; } //# sourceMappingURL=messages.d.ts.map