import type { EnboxPlatformAgent } from './types/agent.js';
import type { PermissionsApi } from './types/permissions.js';
import type { GenericMessage, MessagesSyncDiffEntry, UnionMessageReply } from '@enbox/dwn-sdk-js';
/** Entry type for fetched messages with optional data stream and retry buffer. */
export type SyncMessageEntry = {
    message: GenericMessage;
    dataStream?: ReadableStream<Uint8Array>;
    /** Buffered data bytes for retry — avoids re-fetching from remote when stream is consumed. */
    bufferedData?: Uint8Array;
};
/**
 * 202: message was successfully written to the remote DWN
 * 204: an initial write message was written without any data
 * 409: message was already present on the remote DWN
 * RecordsDelete + 404: the initial write was not found or already deleted
 */
export declare function syncMessageReplyIsSuccessful(reply: UnionMessageReply): boolean;
/**
 * Helper to get the CID of a message for logging purposes.
 */
export declare function getMessageCid(message: GenericMessage): Promise<string>;
/**
 * Fetches missing messages from the remote DWN and processes them on the local DWN
 * in dependency order (topological sort).
 *
 * Small data payloads (≤ 1 MB) are buffered during the initial fetch so that
 * retries can replay the data from memory instead of re-fetching from remote.
 * Large payloads are re-fetched on retry since buffering them would consume
 * too much memory.
 */
export declare function pullMessages({ did, dwnUrl, delegateDid, protocol, messageCids, prefetched, agent, permissionsApi }: {
    did: string;
    dwnUrl: string;
    delegateDid?: string;
    protocol?: string;
    messageCids: string[];
    /** Pre-fetched message entries from the batched diff response (already have message + data). */
    prefetched?: MessagesSyncDiffEntry[];
    agent: EnboxPlatformAgent;
    permissionsApi: PermissionsApi;
}): Promise<void>;
/**
 * Fetches messages from a remote DWN by their CIDs using MessagesRead.
 */
export declare function fetchRemoteMessages({ did, dwnUrl, delegateDid, protocol, messageCids, agent, permissionsApi }: {
    did: string;
    dwnUrl: string;
    delegateDid?: string;
    protocol?: string;
    messageCids: string[];
    agent: EnboxPlatformAgent;
    permissionsApi: PermissionsApi;
}): Promise<SyncMessageEntry[]>;
/**
 * Reads missing messages from the local DWN and pushes them to the remote DWN.
 * Messages are fetched first, then sorted in dependency order (topological sort)
 * so that initial writes come before updates, and ProtocolsConfigures come before
 * records that reference those protocols.
 */
export declare function pushMessages({ did, dwnUrl, delegateDid, protocol, messageCids, agent, permissionsApi }: {
    did: string;
    dwnUrl: string;
    delegateDid?: string;
    protocol?: string;
    messageCids: string[];
    agent: EnboxPlatformAgent;
    permissionsApi: PermissionsApi;
}): Promise<void>;
/**
 * Reads a message from the local DWN by its CID using MessagesRead.
 */
export declare function getLocalMessage({ author, delegateDid, protocol, messageCid, agent, permissionsApi }: {
    author: string;
    delegateDid?: string;
    protocol?: string;
    messageCid: string;
    agent: EnboxPlatformAgent;
    permissionsApi: PermissionsApi;
}): Promise<SyncMessageEntry | undefined>;
//# sourceMappingURL=sync-messages.d.ts.map