import * as plugins from './plugins.js'; type TCoreMailDesiredState = plugins.servezoneInterfaces.data.ICoreMailDesiredState; type TCoreMailReconciliationStatus = plugins.servezoneInterfaces.data.ICoreMailReconciliationStatus; type TCoreMailReplicaIdentity = plugins.servezoneInterfaces.data.ICoreMailReplicaIdentity; type TCoreMailUploadGrant = plugins.servezoneInterfaces.data.ICoreMailUploadGrant; type TCoreMailSha256 = plugins.servezoneInterfaces.data.TCoreMailSha256; type TCoreMailGetServiceMailStatistics = plugins.servezoneInterfaces.requests.coremail.IReq_CoreMailGetServiceMailStatistics; export interface ICoreMailControlClientOptions { /** Canonical CoreMail control socket, `https://host/socket`. */ endpointUrl: string; credentialId: string; credentialVersion: number; credentialSecret: string; } export interface ICoreMailApplyDesiredStateOptions { /** * The `configEpoch` this client believes CoreMail currently has applied. * CoreMail refuses the preparation unless it still matches, which is what * makes a concurrent controller lose instead of both overwriting each other. */ expectedAppliedConfigEpoch: number; } /** * Thrown when a transfer could not be completed. `ambiguous` marks the case * where the request may or may not have reached CoreMail, so the caller must * restart the whole prepare/upload/apply sequence rather than assume either * outcome. */ export declare class CoreMailControlTransferError extends Error { readonly ambiguous: boolean; constructor(messageArg: string, ambiguous: boolean); } /** * Control-plane client for one CoreMail replica. * * Cloudly (clusters) and Onebox (single hosts) own the CoreMail control * session: they compose desired state, push it, and read reconciliation and * per-service mail statistics back. Workload-side mail submission is a * different session kind and lives in `@serve.zone/platformclient`. * * This package deliberately carries no argon2 or other native dependency: * `ICoreMailBindingCredentialVerifier.verificationHash` values are produced by * whoever mints the credential and arrive here already hashed. */ export declare class CoreMailControlClient { private readonly options; /** * Origin that path-only transfer grants resolve against. The control * authenticate response carries no `coreMailTransferOrigin` (unlike the * workload one), because a control caller already holds the authenticated * endpoint it dialled — so the origin is derived from it and never from * anything CoreMail sends back. */ private readonly transferOrigin; private readonly stopController; private readonly activeOperations; private stopped; private generation; private session?; private pendingSession?; private stopPromise?; constructor(optionsArg: ICoreMailControlClientOptions); /** Opens and authenticates the control session. */ start(): Promise; stop(): Promise; /** * Replica identity from the authenticate response. Available only while a * session is open, because it identifies the replica this client is actually * talking to — a stale copy across a reconnect would misattribute state. */ getReplicaIdentity(): TCoreMailReplicaIdentity; /** * Pushes one desired state through prepare, upload and apply. * * The returned status is CoreMail's own reconciliation status for the epoch * that was applied. */ applyDesiredState(desiredStateArg: TCoreMailDesiredState, optionsArg: ICoreMailApplyDesiredStateOptions): Promise; getReconciliationStatus(requestArg: { configEpoch: number; desiredStateDigest: TCoreMailSha256 | string; }): Promise; /** * Reads one page of per-service mail statistics. Pagination is CoreMail's: * follow `nextCursor` until it is absent. */ getServiceMailStatistics(requestArg: TCoreMailGetServiceMailStatistics['request']): Promise; private reconcileOnce; private assertUploadGrant; /** * The one HTTP step in an otherwise TypedSocket-native protocol. * * serve.zone/AGENTS.md records that a TypedSocket-native byte transfer is * planned to replace HTTP transfer grants. This method is therefore kept * deliberately small and is the single seam to swap when that lands: nothing * else in this class touches `fetch`, and its contract is just "make the * grant's bytes reach CoreMail, or throw". */ protected uploadDesiredState(grantArg: TCoreMailUploadGrant, bytesArg: Uint8Array): Promise; private probeAppliedStatus; private normalizeStatisticsRequest; private normalizeStatisticsResponse; private getAuthenticatedSession; private connectAndAuthenticate; private normalizeAuthenticationResponse; private fire; private invalidateSession; private assertGeneration; private trackOperation; private stopInner; private normalizeOptions; private deriveTransferOrigin; private resolveTransferUrl; private requireSafeInteger; /** * Mirrors the interfaces normalizer's `requireUtcCalendarDay`: the shape has * to parse AND be a day that exists, so '2026-02-30' is refused here rather * than by CoreMail. That helper is module-private in interfaces, so the * request side keeps its own copy of the rule. */ private requireDayUtc; private requireCursor; private isRetryable; private createTransferDeadline; private fetchTransfer; private copyBytesToArrayBuffer; private waitForDelay; private createAbortError; } export {};