export interface EmailConfig {
    email: string;
    agentAddress: string;
    imapHost: string;
    imapPort: number;
    imapSecurity: "tls" | "starttls";
    smtpHost: string;
    smtpPort: number;
    smtpSecurity: "tls" | "starttls";
}
export interface PollState {
    agentSlug: string | null;
    pollIntervalMinutes: number;
    lastFetchedUid: number;
    lastPollAt: string | null;
    uidValidity: number | null;
}
export interface FullCredentials {
    config: EmailConfig;
    password: string;
}
/**
 * Read the email password from the credential file.
 * Throws if the file does not exist or is empty.
 */
export declare function readPassword(): string;
/**
 * Write the email password to the credential file (mode 0600).
 */
export declare function writePassword(password: string): void;
/**
 * Remove the password file (for rollback on partial setup failure).
 */
export declare function removePassword(): void;
/**
 * Read the EmailAccount config from the graph.
 * Returns null if no EmailAccount node exists for this account.
 */
export declare function readConfig(accountId: string): Promise<EmailConfig | null>;
/**
 * Write or update the EmailAccount config in the graph.
 * Uses MERGE to be idempotent — calling setup again overwrites the config.
 *
 * When agentAddress changes, updates recipientAddress on all existing Email
 * nodes for this account so stored emails remain consistent with the current
 * config. This prevents stale recipientAddress values from causing confusion
 * in queries (dedup is handled separately by the messageId pre-check).
 */
export declare function writeConfig(accountId: string, config: EmailConfig): Promise<void>;
/**
 * Remove the EmailAccount node from the graph (for rollback).
 *
 * Hard-delete is deliberate: EmailAccount holds credential/config
 * state, not user-domain content — it is semantically the graph-side
 * equivalent of deleting the `.email-password` file above. There is no
 * user-facing "restore my deleted EmailAccount" flow; re-running email-setup
 * re-creates it via MERGE. Email content nodes are protected separately by
 * the `contact-erase` cascade, which this function does not touch.
 */
export declare function removeConfig(accountId: string): Promise<void>;
/**
 * Read poll state from the EmailAccount node.
 * Returns defaults if properties are not yet set (first run).
 */
export declare function readPollState(accountId: string): Promise<PollState | null>;
/**
 * Update poll tracking state after a successful fetch cycle.
 */
export declare function updatePollState(accountId: string, lastFetchedUid: number, uidValidity: number): Promise<void>;
/**
 * Set the agentSlug and poll config on an EmailAccount.
 * Called during email-setup to bind an agent to an email address.
 */
export declare function writeBindingConfig(accountId: string, agentSlug: string, pollIntervalMinutes: number): Promise<void>;
/**
 * Check if an email address is already bound to a different agent.
 * Returns the conflicting agentSlug if claimed, or null if available.
 */
export declare function checkAddressBinding(agentAddress: string, currentSlug: string): Promise<string | null>;
/**
 * Load full credentials (config + password).
 * Returns null with a reason if either piece is missing.
 */
export declare function loadCredentials(accountId: string): Promise<{
    credentials: FullCredentials;
} | {
    error: string;
}>;
//# sourceMappingURL=credentials.d.ts.map