import type { PermissionsApi } from './types/permissions.js';
import type { Web5PlatformAgent } from './types/agent.js';
import type { GenericMessage, UnionMessageReply } from '@enbox/dwn-sdk-js';
/** Entry type for fetched messages with optional data stream. */
export type SyncMessageEntry = {
    message: GenericMessage;
    dataStream?: ReadableStream<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).
 *
 * Messages that fail processing are re-fetched from the remote before each retry
 * pass rather than buffered in memory. ReadableStream is single-use, so a failed
 * message's data stream is consumed on the first attempt. Re-fetching provides a
 * fresh stream without holding all record data in memory simultaneously.
 */
export declare function pullMessages({ did, dwnUrl, delegateDid, protocol, messageCids, agent, permissionsApi }: {
    did: string;
    dwnUrl: string;
    delegateDid?: string;
    protocol?: string;
    messageCids: string[];
    agent: Web5PlatformAgent;
    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: Web5PlatformAgent;
    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: Web5PlatformAgent;
    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: Web5PlatformAgent;
    permissionsApi: PermissionsApi;
}): Promise<SyncMessageEntry | undefined>;
//# sourceMappingURL=sync-messages.d.ts.map