import { type CandidateFetch, type CandidateTransportAuthorization } from "./candidate-uploader.js"; export declare const MULTIPART_PART_SIZE_BYTES: number; export declare const MAX_MULTIPART_PARTS_IN_FLIGHT = 2; export declare const MAX_MULTIPART_BYTES_IN_FLIGHT: number; type Sha256 = `sha256:${string}`; export interface MultipartPart { partNumber: number; etag: string; checksum: Sha256; } export interface MultipartUploadResult { status: "candidate-ready"; attemptId: string; candidateVersionId: string; } export interface MultipartUploaderOptions { apiUrl: string; fetchImpl?: CandidateFetch; now?: () => number; authorizationTimeoutMs?: number; /** Shared by all uploaders in one process; defaults to the process limiter. */ byteBudget?: MultipartByteBudget; } export interface MultipartUploadInput { authorization: CandidateTransportAuthorization; spool: DurableAttemptSpool; /** Returns the live source digest. A mismatch never mutates this attempt. */ sourceChecksum?: () => Promise; } export interface OrphanEvidence { attemptId: string; uploadId?: string; reason: string; recordedAt: string; error?: string; } /** Raised only after the old upload was aborted and its spool deliberately retained. */ export declare class MultipartSourceChangedError extends Error { readonly attemptId: string; constructor(attemptId: string); } /** An abort that cannot be confirmed always leaves durable recovery evidence. */ export declare class MultipartAbortError extends Error { readonly evidencePath: string; constructor(evidencePath: string, cause: unknown); } /** * Process-wide byte semaphore. A caller reserves exactly the in-memory part * buffer it is about to read, so total transfer buffers cannot exceed 64 MiB. */ export declare class MultipartByteBudget { readonly maximumBytes: number; private usedBytes; private readonly waiters; constructor(maximumBytes?: number); acquire(bytes: number): Promise<() => void>; get inUseBytes(): number; private drain; } /** A checksummed, immutable local byte source that survives process loss. */ export declare class DurableAttemptSpool { readonly attemptId: string; readonly filePath: string; readonly size: number; readonly sha256: Sha256; readonly evidencePath: string; private constructor(); static create(directory: string, attemptId: string, bytes: Uint8Array): DurableAttemptSpool; /** Reopens and verifies an existing spool before permitting any network I/O. */ static open(attemptId: string, filePath: string, expected: { size: number; sha256: Sha256; }): DurableAttemptSpool; readPart(partNumber: number): Buffer; recordOrphanEvidence(evidence: OrphanEvidence): Promise; } export declare class MultipartUploader { private readonly apiUrl; private readonly fetchImpl; private readonly now; private readonly authorizationTimeoutMs; private readonly byteBudget; constructor(options: MultipartUploaderOptions); upload(input: MultipartUploadInput): Promise; /** Source-change and recovery paths may call abort repeatedly; 204 is idempotent. */ abort(authorization: CandidateTransportAuthorization, spool: DurableAttemptSpool, reason: string): Promise; private uploadPartWithRenewal; private assertSourceUnchanged; private renewPartAuthority; private multipartPath; private controlJson; private controlHeaders; private assertAuthorization; private assertPlan; private assertAuthorities; private requestPresigned; } export {}; //# sourceMappingURL=multipart-uploader.d.ts.map