import type { GenericMessage, MessagesFilter, MessagesQueryReply, ProgressToken } from '@enbox/dwn-sdk-js';
import type { EnboxPlatformAgent } from './types/agent.js';
import type { PermissionsApi } from './types/permissions.js';
import type { PushResult } from './types/sync.js';
/** Entry type for fetched messages with optional data stream and retry buffer. */
export type SyncMessageEntry = {
    message: GenericMessage;
    dataStream?: ReadableStream<Uint8Array>;
    dataStreamConsumed?: boolean;
    dataStreamFactory?: () => Promise<ReadableStream<Uint8Array> | undefined>;
    /** Source feed attestation. Latest RecordsWrite entries must carry data before apply. */
    isLatestBaseState?: boolean;
    /** Buffered data bytes for retry — avoids re-fetching from remote when stream is consumed. */
    bufferedData?: Uint8Array;
};
export type MessageFeedQuery = {
    did: string;
    delegateDid?: string;
    permissionGrantIds?: string[];
    filters?: MessagesFilter[];
    cursor?: ProgressToken;
    limit?: number;
    cidsOnly?: boolean;
    agent: EnboxPlatformAgent;
};
/** Raised when an in-flight pull is cancelled before local apply can continue. */
export declare class SyncPullAbortedError extends Error {
    constructor();
}
export declare class SyncDataSizeLimitExceededError extends Error {
    constructor(dataSize: number);
}
/**
 * Helper to get the CID of a message for logging purposes.
 */
export declare function getMessageCid(message: GenericMessage): Promise<string>;
export declare function capRecordsWriteDataStream(message: GenericMessage, dataStream: ReadableStream<Uint8Array>): ReadableStream<Uint8Array>;
/**
 * Queries a remote DWN's durable message feed using MessagesQuery.
 */
export declare function queryRemoteMessageFeed({ did, dwnUrl, delegateDid, permissionGrantIds, filters, cursor, limit, cidsOnly, agent, }: MessageFeedQuery & {
    dwnUrl: string;
}): Promise<MessagesQueryReply>;
/**
 * Queries the local DWN's durable message feed using MessagesQuery.
 */
export declare function queryLocalMessageFeed({ did, delegateDid, permissionGrantIds, filters, cursor, limit, cidsOnly, agent, }: MessageFeedQuery): Promise<MessagesQueryReply>;
/**
 * Fetches messages from a remote DWN by their CIDs using MessagesRead.
 */
export declare function fetchRemoteMessages({ did, dwnUrl, delegateDid, permissionGrantIds, messageCids, agent }: {
    did: string;
    dwnUrl: string;
    delegateDid?: string;
    permissionGrantIds?: string[];
    messageCids: string[];
    agent: EnboxPlatformAgent;
}): Promise<SyncMessageEntry[]>;
/**
 * Reads local roots and pushes them through the remote DWN replication entry.
 * The remote DWN is the dependency authority: `Incomplete` results request the
 * exact local dependency refs to fetch and retry.
 *
 * Returns a {@link PushResult} with per-CID outcome tracking instead of throwing
 * on the first failure. Callers use failures to retry transient push problems,
 * dead-letter `Invalid` remote rejections, or mark links for reconciliation.
 */
export declare function pushMessages({ did, dwnUrl, delegateDid, permissionGrantIds, messageCids, agent, permissionsApi }: {
    did: string;
    dwnUrl: string;
    delegateDid?: string;
    permissionGrantIds?: string[];
    messageCids: string[];
    agent: EnboxPlatformAgent;
    permissionsApi?: PermissionsApi;
}): Promise<PushResult>;
/**
 * Reads a message from the local DWN by its CID using MessagesRead.
 */
export declare function getLocalMessage({ author, delegateDid, permissionGrantIds, messageCid, agent }: {
    author: string;
    delegateDid?: string;
    permissionGrantIds?: string[];
    messageCid: string;
    agent: EnboxPlatformAgent;
}): Promise<SyncMessageEntry | undefined>;
//# sourceMappingURL=sync-messages.d.ts.map