@zero-transfer/s3 0.1.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { SecureVersion, PeerCertificate } from 'node:tls';
3
3
  import { Readable } from 'node:stream';
4
- import { BaseAgent, Algorithms } from 'ssh2';
5
4
  import { Buffer } from 'node:buffer';
6
5
 
7
6
  /**
@@ -306,10 +305,25 @@ interface RemoteStat extends RemoteEntry {
306
305
  type TlsSecretSource = SecretSource | SecretSource[];
307
306
  /** Known-hosts material source accepted by SSH connection profiles. */
308
307
  type SshKnownHostsSource = SecretSource | SecretSource[];
308
+ /** Minimal SSH agent contract used by profile validation and SSH adapters. */
309
+ interface SshAgentLike {
310
+ /** Returns public identities exposed by the agent implementation. */
311
+ getIdentities: (...args: any[]) => unknown;
312
+ /** Signs payloads using a selected identity. */
313
+ sign: (...args: any[]) => unknown;
314
+ }
315
+ /** Ordered algorithm list mutation operations used by SSH adapters. */
316
+ interface SshAlgorithmMutations {
317
+ append?: string | readonly string[];
318
+ prepend?: string | readonly string[];
319
+ remove?: string | readonly string[];
320
+ }
321
+ /** Single SSH algorithm override value accepted by connection profiles. */
322
+ type SshAlgorithmOverride = readonly string[] | SshAlgorithmMutations;
309
323
  /** SSH agent source accepted by SFTP providers. */
310
- type SshAgentSource = string | BaseAgent;
324
+ type SshAgentSource = string | SshAgentLike;
311
325
  /** SSH transport algorithm overrides accepted by SFTP providers. */
312
- type SshAlgorithms = Algorithms;
326
+ type SshAlgorithms = Record<string, SshAlgorithmOverride | undefined>;
313
327
  /** Context passed to SSH socket factories before opening an SSH session. */
314
328
  interface SshSocketFactoryContext {
315
329
  /** Target SSH host from the resolved connection profile. */
@@ -327,7 +341,7 @@ interface SshSocketFactoryContext {
327
341
  * Use this hook for HTTP CONNECT, SOCKS, bastion, or custom tunnel integrations.
328
342
  *
329
343
  * @param context - Resolved SSH target information for the socket being opened.
330
- * @returns Preconnected readable stream, or a promise for one, passed to ssh2's `sock` option.
344
+ * @returns Preconnected readable stream, or a promise for one, passed to the SSH adapter socket option.
331
345
  */
332
346
  type SshSocketFactory = (context: SshSocketFactoryContext) => Readable | Promise<Readable>;
333
347
  /** Prompt metadata supplied by an SSH keyboard-interactive server challenge. */
@@ -1629,6 +1643,65 @@ interface RunConnectionDiagnosticsOptions {
1629
1643
  */
1630
1644
  declare function runConnectionDiagnostics(options: RunConnectionDiagnosticsOptions): Promise<ConnectionDiagnosticsResult>;
1631
1645
 
1646
+ /** Options for {@link createPooledTransferClient}. */
1647
+ interface ConnectionPoolOptions {
1648
+ /**
1649
+ * Maximum number of *idle* sessions retained per pool key.
1650
+ *
1651
+ * Active leases are not counted against this limit — the cap only applies
1652
+ * to sessions waiting in the pool. When more than `maxIdlePerKey` sessions
1653
+ * become idle simultaneously, the oldest ones are disconnected. Defaults
1654
+ * to `4`.
1655
+ */
1656
+ maxIdlePerKey?: number;
1657
+ /**
1658
+ * How long an idle session may sit unused before it is automatically
1659
+ * disconnected. Defaults to `60_000` ms. Set to `0` to disable the timer
1660
+ * (idle sessions persist until `drainPool()` is called).
1661
+ */
1662
+ idleTimeoutMs?: number;
1663
+ /**
1664
+ * Custom pool key derivation. Receives the resolved
1665
+ * {@link ConnectionProfile} (after TransferClient validation) and must
1666
+ * return a string. Sessions with matching keys are pooled together; never
1667
+ * include secrets in the key.
1668
+ *
1669
+ * The default derives the key from `provider`, `host`, `port`, and
1670
+ * `username`.
1671
+ */
1672
+ keyOf?: (profile: ConnectionProfile) => string;
1673
+ }
1674
+ /**
1675
+ * Pool-aware {@link TransferClient} returned by
1676
+ * {@link createPooledTransferClient}.
1677
+ */
1678
+ interface PooledTransferClient {
1679
+ /** Opens (or leases) a pooled provider session. */
1680
+ connect(profile: ConnectionProfile): Promise<TransferSession>;
1681
+ /** Inspects the registered providers (delegated to the underlying client). */
1682
+ hasProvider(providerId: ProviderId): boolean;
1683
+ /** Returns the registered capability snapshots (delegated). */
1684
+ getCapabilities(): CapabilitySet[];
1685
+ /** Returns a specific capability snapshot (delegated). */
1686
+ getCapabilities(providerId: ProviderId): CapabilitySet;
1687
+ /**
1688
+ * Disconnects every idle session and prevents further pooling. After
1689
+ * `drainPool()` resolves, subsequent `connect()` calls still work but
1690
+ * always create fresh sessions (and never return them to the pool).
1691
+ */
1692
+ drainPool(): Promise<void>;
1693
+ /** Returns the number of idle sessions currently held in the pool. */
1694
+ poolSize(): number;
1695
+ }
1696
+ /**
1697
+ * Wraps a {@link TransferClient} with connection pooling.
1698
+ *
1699
+ * @param inner - Underlying client used to create real provider sessions.
1700
+ * @param options - Pool sizing, eviction, and key-derivation overrides.
1701
+ * @returns A {@link PooledTransferClient} that reuses idle sessions.
1702
+ */
1703
+ declare function createPooledTransferClient(inner: TransferClient, options?: ConnectionPoolOptions): PooledTransferClient;
1704
+
1632
1705
  /** Options used to create a local file-system provider factory. */
1633
1706
  interface LocalProviderOptions {
1634
1707
  /** Root directory exposed as `/`. When omitted, `profile.host` is treated as the root path. */
@@ -3180,7 +3253,14 @@ interface S3ProviderOptions {
3180
3253
  }
3181
3254
  /** Multipart upload tuning for the S3 provider. */
3182
3255
  interface S3MultipartOptions {
3183
- /** Enable multipart upload. Defaults to `false`. */
3256
+ /**
3257
+ * Enable multipart upload. **Defaults to `true`** so large objects stream
3258
+ * in fixed-size parts instead of being buffered in memory before a single
3259
+ * `PUT`. Payloads at or below {@link S3MultipartOptions.thresholdBytes}
3260
+ * still fall back to a single-shot `PUT` automatically. Set to `false` to
3261
+ * force the legacy single-shot behaviour (e.g. when targeting an
3262
+ * S3-compatible endpoint that does not support `CreateMultipartUpload`).
3263
+ */
3184
3264
  enabled?: boolean;
3185
3265
  /** Object size threshold in bytes above which multipart is used. Defaults to 8 MiB. */
3186
3266
  thresholdBytes?: number;
@@ -3226,6 +3306,41 @@ interface S3MultipartResumeStore {
3226
3306
  }
3227
3307
  /** Creates an in-memory {@link S3MultipartResumeStore}. */
3228
3308
  declare function createMemoryS3MultipartResumeStore(): S3MultipartResumeStore;
3309
+ /** Options for {@link createFileSystemS3MultipartResumeStore}. */
3310
+ interface FileSystemS3MultipartResumeStoreOptions {
3311
+ /**
3312
+ * Directory under which checkpoint JSON files are written. Created
3313
+ * recursively if it does not exist. Each upload occupies a single file
3314
+ * named after a SHA-256 hash of the resume key, so the directory is safe
3315
+ * to share across many concurrent uploads.
3316
+ */
3317
+ directory: string;
3318
+ }
3319
+ /**
3320
+ * File-system backed {@link S3MultipartResumeStore} that survives process
3321
+ * restarts. Each in-flight multipart upload is checkpointed to a single
3322
+ * JSON file in `options.directory` after every part. On retry the upload
3323
+ * reuses the stored `uploadId` and skips parts that S3 has already
3324
+ * accepted.
3325
+ *
3326
+ * The implementation writes atomically (`<file>.tmp` then `rename`) so a
3327
+ * crash mid-write cannot leave a corrupt checkpoint.
3328
+ *
3329
+ * @example
3330
+ * ```ts
3331
+ * import { createFileSystemS3MultipartResumeStore, createS3ProviderFactory }
3332
+ * from "@zero-transfer/sdk";
3333
+ *
3334
+ * const resumeStore = createFileSystemS3MultipartResumeStore({
3335
+ * directory: "./.zt-s3-resume",
3336
+ * });
3337
+ *
3338
+ * const factory = createS3ProviderFactory({
3339
+ * multipart: { enabled: true, resumeStore },
3340
+ * });
3341
+ * ```
3342
+ */
3343
+ declare function createFileSystemS3MultipartResumeStore(options: FileSystemS3MultipartResumeStoreOptions): S3MultipartResumeStore;
3229
3344
  /**
3230
3345
  * Creates an S3-compatible provider factory.
3231
3346
  *
@@ -3263,4 +3378,4 @@ declare function createMemoryS3MultipartResumeStore(): S3MultipartResumeStore;
3263
3378
  */
3264
3379
  declare function createS3ProviderFactory(options?: S3ProviderOptions): ProviderFactory;
3265
3380
 
3266
- export { AbortError, type AtomicDeployActivateOperation, type AtomicDeployActivateStep, type AtomicDeployPlan, type AtomicDeployPruneStep, type AtomicDeployStrategy, type AuthenticationCapability, AuthenticationError, AuthorizationError, type BandwidthSleep, type BandwidthThrottle, type BandwidthThrottleOptions, type Base64EnvSecretSource, type BuiltInProviderId, CLASSIC_PROVIDER_IDS, type CapabilitySet, type ChecksumCapability, type ClassicProviderId, type ClientDiagnostics, type CompareRemoteManifestsOptions, ConfigurationError, type ConnectionDiagnosticTimings, type ConnectionDiagnosticsResult, ConnectionError, type ConnectionProfile, type CopyBetweenOptions, type CreateAtomicDeployPlanOptions, type CreateRemoteBrowserOptions, type CreateRemoteManifestOptions, type CreateSyncPlanOptions, type DiffRemoteTreesOptions, type DownloadFileOptions, type EnvSecretSource, type FileSecretSource, type FileZillaSite, type FriendlyTransferOptions, type FtpReplyErrorInput, type ImportFileZillaSitesResult, type ImportOpenSshConfigOptions, type ImportOpenSshConfigResult, type ImportWinScpSessionsResult, type KnownHostsEntry, type KnownHostsMarker, type ListOptions, type LocalProviderOptions, type LogLevel, type LogRecord, type LogRecordInput, type LoggerMethod, type MemoryProviderEntry, type MemoryProviderOptions, type MetadataCapability, type MkdirOptions, type OAuthAccessToken, type OAuthRefreshCallback, type OAuthTokenSecretSourceOptions, type OpenSshConfigEntry, ParseError, PathAlreadyExistsError, PathNotFoundError, PermissionDeniedError, type ProgressEventInput, ProtocolError, type AuthenticationCapability as ProviderAuthenticationCapability, type CapabilitySet as ProviderCapabilities, type ChecksumCapability as ProviderChecksumCapability, type ProviderFactory, type ProviderId, type MetadataCapability as ProviderMetadataCapability, ProviderRegistry, type ProviderSelection, type ProviderTransferEndpointRole, type ProviderTransferExecutorOptions, type ProviderTransferOperations, type ProviderTransferReadRequest, type ProviderTransferReadResult, type ProviderTransferRequest, type ProviderTransferSessionResolver, type ProviderTransferSessionResolverInput, type ProviderTransferWriteRequest, type ProviderTransferWriteResult, REDACTED, REMOTE_MANIFEST_FORMAT_VERSION, type RemoteBreadcrumb, type RemoteBrowser, type RemoteBrowserFilter, type RemoteBrowserSnapshot, type RemoteEntry, type RemoteEntrySortKey, type RemoteEntrySortOrder, type RemoteEntryType, type RemoteFileAdapter, type RemoteFileEndpoint, type RemoteFileSystem, type RemoteManifest, type RemoteManifestEntry, type RemotePermissions, type RemoteProtocol, type RemoteStat, type RemoteTreeDiff, type RemoteTreeDiffEntry, type RemoteTreeDiffReason, type RemoteTreeDiffStatus, type RemoteTreeDiffSummary, type RemoteTreeEntry, type RemoteTreeFilter, type RemoveOptions, type RenameOptions, type ResolveSecretOptions, type ResolvedConnectionProfile, type ResolvedOpenSshHost, type ResolvedSshProfile, type ResolvedTlsProfile, type RmdirOptions, type RunConnectionDiagnosticsOptions, type S3MultipartCheckpoint, type S3MultipartOptions, type S3MultipartPart, type S3MultipartResumeKey, type S3MultipartResumeStore, type S3ProviderOptions, type SecretProvider, type SecretSource, type SecretValue, type SpecializedErrorDetails, type SshAgentSource, type SshAlgorithms, type SshKeyboardInteractiveChallenge, type SshKeyboardInteractiveHandler, type SshKeyboardInteractivePrompt, type SshKnownHostsSource, type SshProfile, type SshSocketFactory, type SshSocketFactoryContext, type StatOptions, type SyncConflictPolicy, type SyncDeletePolicy, type SyncDirection, type SyncEndpointInput, TimeoutError, type TlsProfile, type TlsSecretSource, type TransferAttempt, type TransferAttemptError, type TransferBandwidthLimit, type TransferByteRange, TransferClient, type TransferClientOptions, type TransferDataChunk, type TransferDataSource, type TransferEndpoint, TransferEngine, type TransferEngineExecuteOptions, type TransferEngineOptions, TransferError, type TransferExecutionContext, type TransferExecutionResult, type TransferExecutor, type TransferJob, type TransferOperation, type TransferPlan, type TransferPlanAction, type TransferPlanInput, type TransferPlanStep, type TransferPlanSummary, type TransferProgressEvent, type TransferProvider, TransferQueue, type TransferQueueExecutorResolver, type TransferQueueItem, type TransferQueueItemStatus, type TransferQueueOptions, type TransferQueueRunOptions, type TransferQueueSummary, type TransferReceipt, type TransferResult, type TransferResultInput, type TransferRetryDecisionInput, type TransferRetryPolicy, type TransferSession, type TransferTimeoutPolicy, type TransferVerificationResult, UnsupportedFeatureError, type UploadFileOptions, type ValueSecretSource, VerificationError, type WalkRemoteTreeOptions, type WinScpSession, ZeroTransfer, type ZeroTransferCapabilities, ZeroTransferError, type ZeroTransferErrorDetails, type ZeroTransferLogger, type ZeroTransferOptions, assertSafeFtpArgument, basenameRemotePath, buildRemoteBreadcrumbs, compareRemoteManifests, copyBetween, createAtomicDeployPlan, createBandwidthThrottle, createLocalProviderFactory, createMemoryProviderFactory, createMemoryS3MultipartResumeStore, createOAuthTokenSecretSource, createProgressEvent, createProviderTransferExecutor, createRemoteBrowser, createRemoteManifest, createS3ProviderFactory, createSyncPlan, createTransferClient, createTransferJobsFromPlan, createTransferPlan, createTransferResult, diffRemoteTrees, downloadFile, emitLog, errorFromFtpReply, filterRemoteEntries, importFileZillaSites, importOpenSshConfig, importWinScpSessions, isClassicProviderId, isSensitiveKey, joinRemotePath, matchKnownHosts, matchKnownHostsEntry, noopLogger, normalizeRemotePath, parentRemotePath, parseKnownHosts, parseOpenSshConfig, parseRemoteManifest, redactCommand, redactConnectionProfile, redactObject, redactSecretSource, redactValue, resolveConnectionProfileSecrets, resolveOpenSshHost, resolveProviderId, resolveSecret, runConnectionDiagnostics, serializeRemoteManifest, sortRemoteEntries, summarizeClientDiagnostics, summarizeTransferPlan, throttleByteIterable, uploadFile, validateConnectionProfile, walkRemoteTree };
3381
+ export { AbortError, type AtomicDeployActivateOperation, type AtomicDeployActivateStep, type AtomicDeployPlan, type AtomicDeployPruneStep, type AtomicDeployStrategy, type AuthenticationCapability, AuthenticationError, AuthorizationError, type BandwidthSleep, type BandwidthThrottle, type BandwidthThrottleOptions, type Base64EnvSecretSource, type BuiltInProviderId, CLASSIC_PROVIDER_IDS, type CapabilitySet, type ChecksumCapability, type ClassicProviderId, type ClientDiagnostics, type CompareRemoteManifestsOptions, ConfigurationError, type ConnectionDiagnosticTimings, type ConnectionDiagnosticsResult, ConnectionError, type ConnectionPoolOptions, type ConnectionProfile, type CopyBetweenOptions, type CreateAtomicDeployPlanOptions, type CreateRemoteBrowserOptions, type CreateRemoteManifestOptions, type CreateSyncPlanOptions, type DiffRemoteTreesOptions, type DownloadFileOptions, type EnvSecretSource, type FileSecretSource, type FileSystemS3MultipartResumeStoreOptions, type FileZillaSite, type FriendlyTransferOptions, type FtpReplyErrorInput, type ImportFileZillaSitesResult, type ImportOpenSshConfigOptions, type ImportOpenSshConfigResult, type ImportWinScpSessionsResult, type KnownHostsEntry, type KnownHostsMarker, type ListOptions, type LocalProviderOptions, type LogLevel, type LogRecord, type LogRecordInput, type LoggerMethod, type MemoryProviderEntry, type MemoryProviderOptions, type MetadataCapability, type MkdirOptions, type OAuthAccessToken, type OAuthRefreshCallback, type OAuthTokenSecretSourceOptions, type OpenSshConfigEntry, ParseError, PathAlreadyExistsError, PathNotFoundError, PermissionDeniedError, type PooledTransferClient, type ProgressEventInput, ProtocolError, type AuthenticationCapability as ProviderAuthenticationCapability, type CapabilitySet as ProviderCapabilities, type ChecksumCapability as ProviderChecksumCapability, type ProviderFactory, type ProviderId, type MetadataCapability as ProviderMetadataCapability, ProviderRegistry, type ProviderSelection, type ProviderTransferEndpointRole, type ProviderTransferExecutorOptions, type ProviderTransferOperations, type ProviderTransferReadRequest, type ProviderTransferReadResult, type ProviderTransferRequest, type ProviderTransferSessionResolver, type ProviderTransferSessionResolverInput, type ProviderTransferWriteRequest, type ProviderTransferWriteResult, REDACTED, REMOTE_MANIFEST_FORMAT_VERSION, type RemoteBreadcrumb, type RemoteBrowser, type RemoteBrowserFilter, type RemoteBrowserSnapshot, type RemoteEntry, type RemoteEntrySortKey, type RemoteEntrySortOrder, type RemoteEntryType, type RemoteFileAdapter, type RemoteFileEndpoint, type RemoteFileSystem, type RemoteManifest, type RemoteManifestEntry, type RemotePermissions, type RemoteProtocol, type RemoteStat, type RemoteTreeDiff, type RemoteTreeDiffEntry, type RemoteTreeDiffReason, type RemoteTreeDiffStatus, type RemoteTreeDiffSummary, type RemoteTreeEntry, type RemoteTreeFilter, type RemoveOptions, type RenameOptions, type ResolveSecretOptions, type ResolvedConnectionProfile, type ResolvedOpenSshHost, type ResolvedSshProfile, type ResolvedTlsProfile, type RmdirOptions, type RunConnectionDiagnosticsOptions, type S3MultipartCheckpoint, type S3MultipartOptions, type S3MultipartPart, type S3MultipartResumeKey, type S3MultipartResumeStore, type S3ProviderOptions, type SecretProvider, type SecretSource, type SecretValue, type SpecializedErrorDetails, type SshAgentSource, type SshAlgorithms, type SshKeyboardInteractiveChallenge, type SshKeyboardInteractiveHandler, type SshKeyboardInteractivePrompt, type SshKnownHostsSource, type SshProfile, type SshSocketFactory, type SshSocketFactoryContext, type StatOptions, type SyncConflictPolicy, type SyncDeletePolicy, type SyncDirection, type SyncEndpointInput, TimeoutError, type TlsProfile, type TlsSecretSource, type TransferAttempt, type TransferAttemptError, type TransferBandwidthLimit, type TransferByteRange, TransferClient, type TransferClientOptions, type TransferDataChunk, type TransferDataSource, type TransferEndpoint, TransferEngine, type TransferEngineExecuteOptions, type TransferEngineOptions, TransferError, type TransferExecutionContext, type TransferExecutionResult, type TransferExecutor, type TransferJob, type TransferOperation, type TransferPlan, type TransferPlanAction, type TransferPlanInput, type TransferPlanStep, type TransferPlanSummary, type TransferProgressEvent, type TransferProvider, TransferQueue, type TransferQueueExecutorResolver, type TransferQueueItem, type TransferQueueItemStatus, type TransferQueueOptions, type TransferQueueRunOptions, type TransferQueueSummary, type TransferReceipt, type TransferResult, type TransferResultInput, type TransferRetryDecisionInput, type TransferRetryPolicy, type TransferSession, type TransferTimeoutPolicy, type TransferVerificationResult, UnsupportedFeatureError, type UploadFileOptions, type ValueSecretSource, VerificationError, type WalkRemoteTreeOptions, type WinScpSession, ZeroTransfer, type ZeroTransferCapabilities, ZeroTransferError, type ZeroTransferErrorDetails, type ZeroTransferLogger, type ZeroTransferOptions, assertSafeFtpArgument, basenameRemotePath, buildRemoteBreadcrumbs, compareRemoteManifests, copyBetween, createAtomicDeployPlan, createBandwidthThrottle, createFileSystemS3MultipartResumeStore, createLocalProviderFactory, createMemoryProviderFactory, createMemoryS3MultipartResumeStore, createOAuthTokenSecretSource, createPooledTransferClient, createProgressEvent, createProviderTransferExecutor, createRemoteBrowser, createRemoteManifest, createS3ProviderFactory, createSyncPlan, createTransferClient, createTransferJobsFromPlan, createTransferPlan, createTransferResult, diffRemoteTrees, downloadFile, emitLog, errorFromFtpReply, filterRemoteEntries, importFileZillaSites, importOpenSshConfig, importWinScpSessions, isClassicProviderId, isSensitiveKey, joinRemotePath, matchKnownHosts, matchKnownHostsEntry, noopLogger, normalizeRemotePath, parentRemotePath, parseKnownHosts, parseOpenSshConfig, parseRemoteManifest, redactCommand, redactConnectionProfile, redactObject, redactSecretSource, redactValue, resolveConnectionProfileSecrets, resolveOpenSshHost, resolveProviderId, resolveSecret, runConnectionDiagnostics, serializeRemoteManifest, sortRemoteEntries, summarizeClientDiagnostics, summarizeTransferPlan, throttleByteIterable, uploadFile, validateConnectionProfile, walkRemoteTree };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { SecureVersion, PeerCertificate } from 'node:tls';
3
3
  import { Readable } from 'node:stream';
4
- import { BaseAgent, Algorithms } from 'ssh2';
5
4
  import { Buffer } from 'node:buffer';
6
5
 
7
6
  /**
@@ -306,10 +305,25 @@ interface RemoteStat extends RemoteEntry {
306
305
  type TlsSecretSource = SecretSource | SecretSource[];
307
306
  /** Known-hosts material source accepted by SSH connection profiles. */
308
307
  type SshKnownHostsSource = SecretSource | SecretSource[];
308
+ /** Minimal SSH agent contract used by profile validation and SSH adapters. */
309
+ interface SshAgentLike {
310
+ /** Returns public identities exposed by the agent implementation. */
311
+ getIdentities: (...args: any[]) => unknown;
312
+ /** Signs payloads using a selected identity. */
313
+ sign: (...args: any[]) => unknown;
314
+ }
315
+ /** Ordered algorithm list mutation operations used by SSH adapters. */
316
+ interface SshAlgorithmMutations {
317
+ append?: string | readonly string[];
318
+ prepend?: string | readonly string[];
319
+ remove?: string | readonly string[];
320
+ }
321
+ /** Single SSH algorithm override value accepted by connection profiles. */
322
+ type SshAlgorithmOverride = readonly string[] | SshAlgorithmMutations;
309
323
  /** SSH agent source accepted by SFTP providers. */
310
- type SshAgentSource = string | BaseAgent;
324
+ type SshAgentSource = string | SshAgentLike;
311
325
  /** SSH transport algorithm overrides accepted by SFTP providers. */
312
- type SshAlgorithms = Algorithms;
326
+ type SshAlgorithms = Record<string, SshAlgorithmOverride | undefined>;
313
327
  /** Context passed to SSH socket factories before opening an SSH session. */
314
328
  interface SshSocketFactoryContext {
315
329
  /** Target SSH host from the resolved connection profile. */
@@ -327,7 +341,7 @@ interface SshSocketFactoryContext {
327
341
  * Use this hook for HTTP CONNECT, SOCKS, bastion, or custom tunnel integrations.
328
342
  *
329
343
  * @param context - Resolved SSH target information for the socket being opened.
330
- * @returns Preconnected readable stream, or a promise for one, passed to ssh2's `sock` option.
344
+ * @returns Preconnected readable stream, or a promise for one, passed to the SSH adapter socket option.
331
345
  */
332
346
  type SshSocketFactory = (context: SshSocketFactoryContext) => Readable | Promise<Readable>;
333
347
  /** Prompt metadata supplied by an SSH keyboard-interactive server challenge. */
@@ -1629,6 +1643,65 @@ interface RunConnectionDiagnosticsOptions {
1629
1643
  */
1630
1644
  declare function runConnectionDiagnostics(options: RunConnectionDiagnosticsOptions): Promise<ConnectionDiagnosticsResult>;
1631
1645
 
1646
+ /** Options for {@link createPooledTransferClient}. */
1647
+ interface ConnectionPoolOptions {
1648
+ /**
1649
+ * Maximum number of *idle* sessions retained per pool key.
1650
+ *
1651
+ * Active leases are not counted against this limit — the cap only applies
1652
+ * to sessions waiting in the pool. When more than `maxIdlePerKey` sessions
1653
+ * become idle simultaneously, the oldest ones are disconnected. Defaults
1654
+ * to `4`.
1655
+ */
1656
+ maxIdlePerKey?: number;
1657
+ /**
1658
+ * How long an idle session may sit unused before it is automatically
1659
+ * disconnected. Defaults to `60_000` ms. Set to `0` to disable the timer
1660
+ * (idle sessions persist until `drainPool()` is called).
1661
+ */
1662
+ idleTimeoutMs?: number;
1663
+ /**
1664
+ * Custom pool key derivation. Receives the resolved
1665
+ * {@link ConnectionProfile} (after TransferClient validation) and must
1666
+ * return a string. Sessions with matching keys are pooled together; never
1667
+ * include secrets in the key.
1668
+ *
1669
+ * The default derives the key from `provider`, `host`, `port`, and
1670
+ * `username`.
1671
+ */
1672
+ keyOf?: (profile: ConnectionProfile) => string;
1673
+ }
1674
+ /**
1675
+ * Pool-aware {@link TransferClient} returned by
1676
+ * {@link createPooledTransferClient}.
1677
+ */
1678
+ interface PooledTransferClient {
1679
+ /** Opens (or leases) a pooled provider session. */
1680
+ connect(profile: ConnectionProfile): Promise<TransferSession>;
1681
+ /** Inspects the registered providers (delegated to the underlying client). */
1682
+ hasProvider(providerId: ProviderId): boolean;
1683
+ /** Returns the registered capability snapshots (delegated). */
1684
+ getCapabilities(): CapabilitySet[];
1685
+ /** Returns a specific capability snapshot (delegated). */
1686
+ getCapabilities(providerId: ProviderId): CapabilitySet;
1687
+ /**
1688
+ * Disconnects every idle session and prevents further pooling. After
1689
+ * `drainPool()` resolves, subsequent `connect()` calls still work but
1690
+ * always create fresh sessions (and never return them to the pool).
1691
+ */
1692
+ drainPool(): Promise<void>;
1693
+ /** Returns the number of idle sessions currently held in the pool. */
1694
+ poolSize(): number;
1695
+ }
1696
+ /**
1697
+ * Wraps a {@link TransferClient} with connection pooling.
1698
+ *
1699
+ * @param inner - Underlying client used to create real provider sessions.
1700
+ * @param options - Pool sizing, eviction, and key-derivation overrides.
1701
+ * @returns A {@link PooledTransferClient} that reuses idle sessions.
1702
+ */
1703
+ declare function createPooledTransferClient(inner: TransferClient, options?: ConnectionPoolOptions): PooledTransferClient;
1704
+
1632
1705
  /** Options used to create a local file-system provider factory. */
1633
1706
  interface LocalProviderOptions {
1634
1707
  /** Root directory exposed as `/`. When omitted, `profile.host` is treated as the root path. */
@@ -3180,7 +3253,14 @@ interface S3ProviderOptions {
3180
3253
  }
3181
3254
  /** Multipart upload tuning for the S3 provider. */
3182
3255
  interface S3MultipartOptions {
3183
- /** Enable multipart upload. Defaults to `false`. */
3256
+ /**
3257
+ * Enable multipart upload. **Defaults to `true`** so large objects stream
3258
+ * in fixed-size parts instead of being buffered in memory before a single
3259
+ * `PUT`. Payloads at or below {@link S3MultipartOptions.thresholdBytes}
3260
+ * still fall back to a single-shot `PUT` automatically. Set to `false` to
3261
+ * force the legacy single-shot behaviour (e.g. when targeting an
3262
+ * S3-compatible endpoint that does not support `CreateMultipartUpload`).
3263
+ */
3184
3264
  enabled?: boolean;
3185
3265
  /** Object size threshold in bytes above which multipart is used. Defaults to 8 MiB. */
3186
3266
  thresholdBytes?: number;
@@ -3226,6 +3306,41 @@ interface S3MultipartResumeStore {
3226
3306
  }
3227
3307
  /** Creates an in-memory {@link S3MultipartResumeStore}. */
3228
3308
  declare function createMemoryS3MultipartResumeStore(): S3MultipartResumeStore;
3309
+ /** Options for {@link createFileSystemS3MultipartResumeStore}. */
3310
+ interface FileSystemS3MultipartResumeStoreOptions {
3311
+ /**
3312
+ * Directory under which checkpoint JSON files are written. Created
3313
+ * recursively if it does not exist. Each upload occupies a single file
3314
+ * named after a SHA-256 hash of the resume key, so the directory is safe
3315
+ * to share across many concurrent uploads.
3316
+ */
3317
+ directory: string;
3318
+ }
3319
+ /**
3320
+ * File-system backed {@link S3MultipartResumeStore} that survives process
3321
+ * restarts. Each in-flight multipart upload is checkpointed to a single
3322
+ * JSON file in `options.directory` after every part. On retry the upload
3323
+ * reuses the stored `uploadId` and skips parts that S3 has already
3324
+ * accepted.
3325
+ *
3326
+ * The implementation writes atomically (`<file>.tmp` then `rename`) so a
3327
+ * crash mid-write cannot leave a corrupt checkpoint.
3328
+ *
3329
+ * @example
3330
+ * ```ts
3331
+ * import { createFileSystemS3MultipartResumeStore, createS3ProviderFactory }
3332
+ * from "@zero-transfer/sdk";
3333
+ *
3334
+ * const resumeStore = createFileSystemS3MultipartResumeStore({
3335
+ * directory: "./.zt-s3-resume",
3336
+ * });
3337
+ *
3338
+ * const factory = createS3ProviderFactory({
3339
+ * multipart: { enabled: true, resumeStore },
3340
+ * });
3341
+ * ```
3342
+ */
3343
+ declare function createFileSystemS3MultipartResumeStore(options: FileSystemS3MultipartResumeStoreOptions): S3MultipartResumeStore;
3229
3344
  /**
3230
3345
  * Creates an S3-compatible provider factory.
3231
3346
  *
@@ -3263,4 +3378,4 @@ declare function createMemoryS3MultipartResumeStore(): S3MultipartResumeStore;
3263
3378
  */
3264
3379
  declare function createS3ProviderFactory(options?: S3ProviderOptions): ProviderFactory;
3265
3380
 
3266
- export { AbortError, type AtomicDeployActivateOperation, type AtomicDeployActivateStep, type AtomicDeployPlan, type AtomicDeployPruneStep, type AtomicDeployStrategy, type AuthenticationCapability, AuthenticationError, AuthorizationError, type BandwidthSleep, type BandwidthThrottle, type BandwidthThrottleOptions, type Base64EnvSecretSource, type BuiltInProviderId, CLASSIC_PROVIDER_IDS, type CapabilitySet, type ChecksumCapability, type ClassicProviderId, type ClientDiagnostics, type CompareRemoteManifestsOptions, ConfigurationError, type ConnectionDiagnosticTimings, type ConnectionDiagnosticsResult, ConnectionError, type ConnectionProfile, type CopyBetweenOptions, type CreateAtomicDeployPlanOptions, type CreateRemoteBrowserOptions, type CreateRemoteManifestOptions, type CreateSyncPlanOptions, type DiffRemoteTreesOptions, type DownloadFileOptions, type EnvSecretSource, type FileSecretSource, type FileZillaSite, type FriendlyTransferOptions, type FtpReplyErrorInput, type ImportFileZillaSitesResult, type ImportOpenSshConfigOptions, type ImportOpenSshConfigResult, type ImportWinScpSessionsResult, type KnownHostsEntry, type KnownHostsMarker, type ListOptions, type LocalProviderOptions, type LogLevel, type LogRecord, type LogRecordInput, type LoggerMethod, type MemoryProviderEntry, type MemoryProviderOptions, type MetadataCapability, type MkdirOptions, type OAuthAccessToken, type OAuthRefreshCallback, type OAuthTokenSecretSourceOptions, type OpenSshConfigEntry, ParseError, PathAlreadyExistsError, PathNotFoundError, PermissionDeniedError, type ProgressEventInput, ProtocolError, type AuthenticationCapability as ProviderAuthenticationCapability, type CapabilitySet as ProviderCapabilities, type ChecksumCapability as ProviderChecksumCapability, type ProviderFactory, type ProviderId, type MetadataCapability as ProviderMetadataCapability, ProviderRegistry, type ProviderSelection, type ProviderTransferEndpointRole, type ProviderTransferExecutorOptions, type ProviderTransferOperations, type ProviderTransferReadRequest, type ProviderTransferReadResult, type ProviderTransferRequest, type ProviderTransferSessionResolver, type ProviderTransferSessionResolverInput, type ProviderTransferWriteRequest, type ProviderTransferWriteResult, REDACTED, REMOTE_MANIFEST_FORMAT_VERSION, type RemoteBreadcrumb, type RemoteBrowser, type RemoteBrowserFilter, type RemoteBrowserSnapshot, type RemoteEntry, type RemoteEntrySortKey, type RemoteEntrySortOrder, type RemoteEntryType, type RemoteFileAdapter, type RemoteFileEndpoint, type RemoteFileSystem, type RemoteManifest, type RemoteManifestEntry, type RemotePermissions, type RemoteProtocol, type RemoteStat, type RemoteTreeDiff, type RemoteTreeDiffEntry, type RemoteTreeDiffReason, type RemoteTreeDiffStatus, type RemoteTreeDiffSummary, type RemoteTreeEntry, type RemoteTreeFilter, type RemoveOptions, type RenameOptions, type ResolveSecretOptions, type ResolvedConnectionProfile, type ResolvedOpenSshHost, type ResolvedSshProfile, type ResolvedTlsProfile, type RmdirOptions, type RunConnectionDiagnosticsOptions, type S3MultipartCheckpoint, type S3MultipartOptions, type S3MultipartPart, type S3MultipartResumeKey, type S3MultipartResumeStore, type S3ProviderOptions, type SecretProvider, type SecretSource, type SecretValue, type SpecializedErrorDetails, type SshAgentSource, type SshAlgorithms, type SshKeyboardInteractiveChallenge, type SshKeyboardInteractiveHandler, type SshKeyboardInteractivePrompt, type SshKnownHostsSource, type SshProfile, type SshSocketFactory, type SshSocketFactoryContext, type StatOptions, type SyncConflictPolicy, type SyncDeletePolicy, type SyncDirection, type SyncEndpointInput, TimeoutError, type TlsProfile, type TlsSecretSource, type TransferAttempt, type TransferAttemptError, type TransferBandwidthLimit, type TransferByteRange, TransferClient, type TransferClientOptions, type TransferDataChunk, type TransferDataSource, type TransferEndpoint, TransferEngine, type TransferEngineExecuteOptions, type TransferEngineOptions, TransferError, type TransferExecutionContext, type TransferExecutionResult, type TransferExecutor, type TransferJob, type TransferOperation, type TransferPlan, type TransferPlanAction, type TransferPlanInput, type TransferPlanStep, type TransferPlanSummary, type TransferProgressEvent, type TransferProvider, TransferQueue, type TransferQueueExecutorResolver, type TransferQueueItem, type TransferQueueItemStatus, type TransferQueueOptions, type TransferQueueRunOptions, type TransferQueueSummary, type TransferReceipt, type TransferResult, type TransferResultInput, type TransferRetryDecisionInput, type TransferRetryPolicy, type TransferSession, type TransferTimeoutPolicy, type TransferVerificationResult, UnsupportedFeatureError, type UploadFileOptions, type ValueSecretSource, VerificationError, type WalkRemoteTreeOptions, type WinScpSession, ZeroTransfer, type ZeroTransferCapabilities, ZeroTransferError, type ZeroTransferErrorDetails, type ZeroTransferLogger, type ZeroTransferOptions, assertSafeFtpArgument, basenameRemotePath, buildRemoteBreadcrumbs, compareRemoteManifests, copyBetween, createAtomicDeployPlan, createBandwidthThrottle, createLocalProviderFactory, createMemoryProviderFactory, createMemoryS3MultipartResumeStore, createOAuthTokenSecretSource, createProgressEvent, createProviderTransferExecutor, createRemoteBrowser, createRemoteManifest, createS3ProviderFactory, createSyncPlan, createTransferClient, createTransferJobsFromPlan, createTransferPlan, createTransferResult, diffRemoteTrees, downloadFile, emitLog, errorFromFtpReply, filterRemoteEntries, importFileZillaSites, importOpenSshConfig, importWinScpSessions, isClassicProviderId, isSensitiveKey, joinRemotePath, matchKnownHosts, matchKnownHostsEntry, noopLogger, normalizeRemotePath, parentRemotePath, parseKnownHosts, parseOpenSshConfig, parseRemoteManifest, redactCommand, redactConnectionProfile, redactObject, redactSecretSource, redactValue, resolveConnectionProfileSecrets, resolveOpenSshHost, resolveProviderId, resolveSecret, runConnectionDiagnostics, serializeRemoteManifest, sortRemoteEntries, summarizeClientDiagnostics, summarizeTransferPlan, throttleByteIterable, uploadFile, validateConnectionProfile, walkRemoteTree };
3381
+ export { AbortError, type AtomicDeployActivateOperation, type AtomicDeployActivateStep, type AtomicDeployPlan, type AtomicDeployPruneStep, type AtomicDeployStrategy, type AuthenticationCapability, AuthenticationError, AuthorizationError, type BandwidthSleep, type BandwidthThrottle, type BandwidthThrottleOptions, type Base64EnvSecretSource, type BuiltInProviderId, CLASSIC_PROVIDER_IDS, type CapabilitySet, type ChecksumCapability, type ClassicProviderId, type ClientDiagnostics, type CompareRemoteManifestsOptions, ConfigurationError, type ConnectionDiagnosticTimings, type ConnectionDiagnosticsResult, ConnectionError, type ConnectionPoolOptions, type ConnectionProfile, type CopyBetweenOptions, type CreateAtomicDeployPlanOptions, type CreateRemoteBrowserOptions, type CreateRemoteManifestOptions, type CreateSyncPlanOptions, type DiffRemoteTreesOptions, type DownloadFileOptions, type EnvSecretSource, type FileSecretSource, type FileSystemS3MultipartResumeStoreOptions, type FileZillaSite, type FriendlyTransferOptions, type FtpReplyErrorInput, type ImportFileZillaSitesResult, type ImportOpenSshConfigOptions, type ImportOpenSshConfigResult, type ImportWinScpSessionsResult, type KnownHostsEntry, type KnownHostsMarker, type ListOptions, type LocalProviderOptions, type LogLevel, type LogRecord, type LogRecordInput, type LoggerMethod, type MemoryProviderEntry, type MemoryProviderOptions, type MetadataCapability, type MkdirOptions, type OAuthAccessToken, type OAuthRefreshCallback, type OAuthTokenSecretSourceOptions, type OpenSshConfigEntry, ParseError, PathAlreadyExistsError, PathNotFoundError, PermissionDeniedError, type PooledTransferClient, type ProgressEventInput, ProtocolError, type AuthenticationCapability as ProviderAuthenticationCapability, type CapabilitySet as ProviderCapabilities, type ChecksumCapability as ProviderChecksumCapability, type ProviderFactory, type ProviderId, type MetadataCapability as ProviderMetadataCapability, ProviderRegistry, type ProviderSelection, type ProviderTransferEndpointRole, type ProviderTransferExecutorOptions, type ProviderTransferOperations, type ProviderTransferReadRequest, type ProviderTransferReadResult, type ProviderTransferRequest, type ProviderTransferSessionResolver, type ProviderTransferSessionResolverInput, type ProviderTransferWriteRequest, type ProviderTransferWriteResult, REDACTED, REMOTE_MANIFEST_FORMAT_VERSION, type RemoteBreadcrumb, type RemoteBrowser, type RemoteBrowserFilter, type RemoteBrowserSnapshot, type RemoteEntry, type RemoteEntrySortKey, type RemoteEntrySortOrder, type RemoteEntryType, type RemoteFileAdapter, type RemoteFileEndpoint, type RemoteFileSystem, type RemoteManifest, type RemoteManifestEntry, type RemotePermissions, type RemoteProtocol, type RemoteStat, type RemoteTreeDiff, type RemoteTreeDiffEntry, type RemoteTreeDiffReason, type RemoteTreeDiffStatus, type RemoteTreeDiffSummary, type RemoteTreeEntry, type RemoteTreeFilter, type RemoveOptions, type RenameOptions, type ResolveSecretOptions, type ResolvedConnectionProfile, type ResolvedOpenSshHost, type ResolvedSshProfile, type ResolvedTlsProfile, type RmdirOptions, type RunConnectionDiagnosticsOptions, type S3MultipartCheckpoint, type S3MultipartOptions, type S3MultipartPart, type S3MultipartResumeKey, type S3MultipartResumeStore, type S3ProviderOptions, type SecretProvider, type SecretSource, type SecretValue, type SpecializedErrorDetails, type SshAgentSource, type SshAlgorithms, type SshKeyboardInteractiveChallenge, type SshKeyboardInteractiveHandler, type SshKeyboardInteractivePrompt, type SshKnownHostsSource, type SshProfile, type SshSocketFactory, type SshSocketFactoryContext, type StatOptions, type SyncConflictPolicy, type SyncDeletePolicy, type SyncDirection, type SyncEndpointInput, TimeoutError, type TlsProfile, type TlsSecretSource, type TransferAttempt, type TransferAttemptError, type TransferBandwidthLimit, type TransferByteRange, TransferClient, type TransferClientOptions, type TransferDataChunk, type TransferDataSource, type TransferEndpoint, TransferEngine, type TransferEngineExecuteOptions, type TransferEngineOptions, TransferError, type TransferExecutionContext, type TransferExecutionResult, type TransferExecutor, type TransferJob, type TransferOperation, type TransferPlan, type TransferPlanAction, type TransferPlanInput, type TransferPlanStep, type TransferPlanSummary, type TransferProgressEvent, type TransferProvider, TransferQueue, type TransferQueueExecutorResolver, type TransferQueueItem, type TransferQueueItemStatus, type TransferQueueOptions, type TransferQueueRunOptions, type TransferQueueSummary, type TransferReceipt, type TransferResult, type TransferResultInput, type TransferRetryDecisionInput, type TransferRetryPolicy, type TransferSession, type TransferTimeoutPolicy, type TransferVerificationResult, UnsupportedFeatureError, type UploadFileOptions, type ValueSecretSource, VerificationError, type WalkRemoteTreeOptions, type WinScpSession, ZeroTransfer, type ZeroTransferCapabilities, ZeroTransferError, type ZeroTransferErrorDetails, type ZeroTransferLogger, type ZeroTransferOptions, assertSafeFtpArgument, basenameRemotePath, buildRemoteBreadcrumbs, compareRemoteManifests, copyBetween, createAtomicDeployPlan, createBandwidthThrottle, createFileSystemS3MultipartResumeStore, createLocalProviderFactory, createMemoryProviderFactory, createMemoryS3MultipartResumeStore, createOAuthTokenSecretSource, createPooledTransferClient, createProgressEvent, createProviderTransferExecutor, createRemoteBrowser, createRemoteManifest, createS3ProviderFactory, createSyncPlan, createTransferClient, createTransferJobsFromPlan, createTransferPlan, createTransferResult, diffRemoteTrees, downloadFile, emitLog, errorFromFtpReply, filterRemoteEntries, importFileZillaSites, importOpenSshConfig, importWinScpSessions, isClassicProviderId, isSensitiveKey, joinRemotePath, matchKnownHosts, matchKnownHostsEntry, noopLogger, normalizeRemotePath, parentRemotePath, parseKnownHosts, parseOpenSshConfig, parseRemoteManifest, redactCommand, redactConnectionProfile, redactObject, redactSecretSource, redactValue, resolveConnectionProfileSecrets, resolveOpenSshHost, resolveProviderId, resolveSecret, runConnectionDiagnostics, serializeRemoteManifest, sortRemoteEntries, summarizeClientDiagnostics, summarizeTransferPlan, throttleByteIterable, uploadFile, validateConnectionProfile, walkRemoteTree };