dsh-remote-vs 0.11.1 → 0.13.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Download progress dock.
3
+ *
4
+ * Rendered through a PORTAL on `document.body`: the dock starts inside the
5
+ * sidebar's keep-alive slot, and a `position: fixed` descendant of a hidden
6
+ * ancestor disappears with it — which would take the progress bar (and the
7
+ * cancel button) of a running download along when the user switches rail views.
8
+ *
9
+ * The runner lives in `downloads.ts`, outside React, so an unmount of this
10
+ * component never interrupts a transfer; the dock only reads its snapshot.
11
+ */
12
+ import { type ReactNode } from 'react';
13
+ export declare function DownloadDock(props: {
14
+ t: (key: string) => string;
15
+ }): ReactNode;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Download one remote file or directory to the local machine.
3
+ *
4
+ * The Host streams the bytes over `REMOTE_API.download` (file) or
5
+ * `REMOTE_API.downloadDir` (one remote `tar -czf -` archive). When the browser
6
+ * offers the File System Access API the user picks the destination in a native
7
+ * "save as" dialog and the response body is written chunk by chunk into that
8
+ * file — streamed, never assembled into a Blob — which is also what feeds the
9
+ * progress meter. Without the API (Firefox, some Electron shells) the download
10
+ * falls back to an anchor click, i.e. the browser's configured download folder,
11
+ * with no progress to report.
12
+ *
13
+ * The runner (`downloads.ts`) preflights with `files` op=stat, so a vanished or
14
+ * unreadable path shows the Host's real error instead of an empty saved file.
15
+ */
16
+ /** What one download attempt ended as. */
17
+ export type DownloadOutcome = 'saved' | 'downloaded';
18
+ /** One progress sample: `total` is absent for a streamed archive (chunked). */
19
+ export interface DownloadProgress {
20
+ loaded: number;
21
+ total?: number;
22
+ }
23
+ /** Hooks the runner uses for the progress panel and its cancel button. */
24
+ export interface SaveOptions {
25
+ onProgress?: (progress: DownloadProgress) => void;
26
+ signal?: AbortSignal;
27
+ }
28
+ /** File name a remote POSIX path should be saved as. */
29
+ export declare function downloadFileName(path: string): string;
30
+ /**
31
+ * Same-origin URL of the streaming download route for one remote file.
32
+ *
33
+ * Deliberately RELATIVE, including on Desktop: the page origin there is
34
+ * `dsh-app://app` and the Electron shell proxies app-origin HTTP to its Host,
35
+ * so the click stays same-origin (the `download` attribute applies) and passes
36
+ * the route's loopback/same-origin fence. Naming the published loopback origin
37
+ * instead would make it a cross-site GET, which that fence rejects.
38
+ */
39
+ export declare function downloadUrl(alias: string, path: string): string;
40
+ /** Same-origin URL of the streaming directory-archive route. */
41
+ export declare function downloadDirUrl(alias: string, path: string): string;
42
+ /** Same-origin URL of the multi-selection archive route (one `path` per entry). */
43
+ export declare function downloadManyUrl(alias: string, paths: readonly string[]): string;
44
+ /**
45
+ * Hand one download to the browser (fallback when no save picker exists).
46
+ *
47
+ * The element is attached to the document on purpose: a detached anchor is
48
+ * ignored by some Chromium versions, and Desktop's shell hooks the download at
49
+ * the document level.
50
+ */
51
+ export declare function triggerDownload(href: string, fileName: string): void;
52
+ /**
53
+ * Save one streamed URL to a destination the user picks.
54
+ *
55
+ * The picker runs while the click's transient activation is still valid, so it
56
+ * must come before the network work. A picker that refuses the call (expired
57
+ * activation, policy) falls back to the browser download flow instead of
58
+ * failing the download outright.
59
+ *
60
+ * @returns `'saved'` for the picked destination, `'downloaded'` for the
61
+ * browser-default fallback.
62
+ */
63
+ export declare function saveRemoteUrl(href: string, fileName: string, options?: SaveOptions): Promise<DownloadOutcome>;
64
+ /** Save one remote file (fresh name from its POSIX basename). */
65
+ export declare function saveRemoteFile(alias: string, path: string, options?: SaveOptions): Promise<DownloadOutcome>;
66
+ /** Save one remote directory as a single `.tar.gz`. */
67
+ export declare function saveRemoteDir(alias: string, path: string, options?: SaveOptions): Promise<DownloadOutcome>;
68
+ /** Save several selected entries as one `.tar.gz` archive. */
69
+ export declare function saveRemoteMany(alias: string, paths: readonly string[], options?: SaveOptions): Promise<DownloadOutcome>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Download runner and its tiny observable store.
3
+ *
4
+ * The explorer/search menus start one download each; this module owns the
5
+ * stat preflight, the file-vs-directory choice, the cancel handle and the
6
+ * progress/status snapshot the dock renders. Kept outside React on purpose:
7
+ * the dock is portaled to `<body>` and may unmount with its sidebar tab, while
8
+ * a download already streaming must keep running to completion.
9
+ */
10
+ /** One download's lifecycle state. */
11
+ export type DownloadStatus = 'running' | 'done' | 'failed' | 'cancelled';
12
+ /** One task as the dock renders it. */
13
+ export interface DownloadTask {
14
+ id: string;
15
+ /** Basename of the remote path (or `selection-N` for a multi-selection). */
16
+ name: string;
17
+ /** Resolved from the stat preflight; `hint.directory` until then. */
18
+ directory: boolean;
19
+ /** Entries in a multi-selection archive; absent for a single path. */
20
+ selection?: number;
21
+ status: DownloadStatus;
22
+ loaded: number;
23
+ /** Absent for a streamed archive (chunked, size unknown). */
24
+ total?: number;
25
+ /** Failure text, or the note shown for the browser-default fallback. */
26
+ error?: string;
27
+ /** `browserDefault` means no save dialog existed and the file went to Downloads. */
28
+ via?: 'picker' | 'browserDefault';
29
+ startedAt: number;
30
+ finishedAt?: number;
31
+ }
32
+ /** Human byte size for the progress line. */
33
+ export declare function formatByteCount(bytes: number): string;
34
+ /** Store surface: `useSyncExternalStore(subscribe, getSnapshot, getSnapshot)`. */
35
+ export declare const downloadsStore: {
36
+ subscribe(listener: () => void): () => void;
37
+ getSnapshot(): readonly DownloadTask[];
38
+ };
39
+ /**
40
+ * Start one download (file or directory) and return its task id.
41
+ *
42
+ * The stat preflight runs here — not in the menus — so a deleted/unreadable
43
+ * remote path becomes a failed task with the Host's real message, and the
44
+ * file-vs-directory decision comes from the Host rather than a possibly stale
45
+ * tree row.
46
+ */
47
+ export declare function startDownload(alias: string, path: string, hint: {
48
+ name: string;
49
+ directory: boolean;
50
+ }): string;
51
+ /**
52
+ * Start one multi-selection download.
53
+ *
54
+ * The Host archives every selected entry into a single `.tar.gz`, so the user
55
+ * picks one destination instead of answering N save dialogs; mixed files and
56
+ * directories are fine (tar recurses). Entry validation happens Host-side
57
+ * before the archive starts, so no client preflight round trip is needed.
58
+ */
59
+ export declare function startSelectionDownload(alias: string, paths: readonly string[]): string;
60
+ /** Cancel one running download (the panel's stop button). */
61
+ export declare function cancelDownload(id: string): void;
62
+ /** Drop one task from the dock (finished tasks only in practice). */
63
+ export declare function dismissDownload(id: string): void;
@@ -11,7 +11,7 @@
11
11
  * them here keeps the check meaningful in both directions: every entry must
12
12
  * exist in both dictionaries, and nothing else may be unreferenced.
13
13
  */
14
- export declare const DYNAMIC_KEYS: readonly ["common.loading", "editor.saving", "editor.unsaved", "editor.saved", "scm.hunkStaged", "scm.hunkUnstaged", "scm.hunkReverted", "history.details", "history.content", "history.diff"];
14
+ export declare const DYNAMIC_KEYS: readonly ["common.loading", "editor.saving", "editor.unsaved", "editor.saved", "scm.hunkStaged", "scm.hunkUnstaged", "scm.hunkReverted", "history.details", "history.content", "history.diff", "downloads.running", "downloads.indeterminate", "downloads.sizeUnknown"];
15
15
  export type Lang = 'zh' | 'en';
16
16
  export declare function detectLang(): Lang;
17
17
  export declare function makeT(lang: Lang): (key: string) => string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * In-flight directory-listing requests, shared by the explorer's hover prefetch
3
+ * and the reads that follow it.
4
+ *
5
+ * Two rules the tree depends on:
6
+ * - JOIN only a request that started at the SAME revision. A listing read after
7
+ * a write must never be answered by a request issued before it, or pre-write
8
+ * rows paint as if they were final (a hover prefetch starts, a write lands,
9
+ * the click follows and joins the request that predates the write).
10
+ * - PAINT in request order. If a newer request supersedes an older one for the
11
+ * same directory, the older answer may still arrive; it must not overwrite the
12
+ * one the caller asked for.
13
+ *
14
+ * The cache itself stays in the component: this module only owns "which listing
15
+ * requests are on the wire and which answer may be stored".
16
+ */
17
+ import type { RemoteFileEntry } from '../protocol.ts';
18
+ export declare class ListingRequests {
19
+ private readonly keyOf;
20
+ private readonly load;
21
+ private readonly store;
22
+ private readonly inFlight;
23
+ /** Newest request per key: only its answer may be stored. */
24
+ private readonly newest;
25
+ private sequence;
26
+ /**
27
+ * @param keyOf - cache key for one directory (host alias + absolute path).
28
+ * @param load - performs the listing.
29
+ * @param store - applies a listing whose request is still the newest for its
30
+ * key; the component writes it into the listing cache.
31
+ */
32
+ constructor(keyOf: (dir: string) => string, load: (dir: string) => Promise<RemoteFileEntry[]>, store: (key: string, entries: RemoteFileEntry[]) => void);
33
+ /**
34
+ * List one directory, or join the request a hover prefetch already started.
35
+ *
36
+ * @param dir - absolute remote directory.
37
+ * @param revision - the explorer revision this read is meant to reflect. A
38
+ * request issued at another revision is never joined.
39
+ * @param fresh - start a new request even when one is in flight (a
40
+ * revalidation after a write, where joining the older read would be wrong).
41
+ */
42
+ request(dir: string, revision: number, fresh?: boolean): Promise<RemoteFileEntry[]>;
43
+ /** Whether a listing for `dir` is on the wire. */
44
+ busy(dir: string): boolean;
45
+ }
@@ -43,6 +43,8 @@ export declare class RemotePool {
43
43
  private readonly setsidProbes;
44
44
  /** Per-alias channel slots and the queue waiting for one (see acquireSlot). */
45
45
  private readonly slots;
46
+ /** Per-alias BROWSE SFTP session (see withBrowseSftp). */
47
+ private readonly browsed;
46
48
  constructor(store: RemoteStore);
47
49
  /** Drop one pooled connection (call after host update/delete). */
48
50
  drop(alias: string): void;
@@ -73,14 +75,109 @@ export declare class RemotePool {
73
75
  execChannel(alias: string, command: string): Promise<ClientChannel>;
74
76
  /** Run one callback with a fresh SFTP session (closed afterwards). */
75
77
  withSftp<T>(alias: string, fn: (sftp: SFTPWrapper) => Promise<T>, opts?: SftpOptions): Promise<T>;
78
+ /**
79
+ * Run one bulk-transfer callback with a dedicated SFTP session, plus extra
80
+ * channel windows on demand (`addChannel`).
81
+ *
82
+ * Why extra channels: ssh2 (Channel.js `MAX_WINDOW`) and OpenSSH cap ONE SSH
83
+ * channel's window at 2 MiB, so a single channel can never hold 8 MiB of READs
84
+ * in flight however much concurrency the caller asks for; the rest queue
85
+ * client-side. Each extra session is another 2 MiB window. Measured against a
86
+ * real host (96 MiB file, 256 KiB chunks, same total concurrency):
87
+ * 1 channel 28.6 MiB/s, 2 channels 46.1, 4 channels 51.3 — two channels take
88
+ * most of the gain, four cost twice the channels for little more. Uploads
89
+ * showed no such gain (server-side write bound: 46.0 → 50.4 MiB/s), so only
90
+ * downloads spread out.
91
+ *
92
+ * `addChannel` is best-effort and late on purpose: a small download must not
93
+ * pay for a second channel, so the caller opens one only after it has the
94
+ * size. It never queues for a channel slot (a 30 s wait would stall a body that
95
+ * is already streaming) and a late call after the callback settled is a no-op.
96
+ * Every session opened here is closed, and every slot/hold released, when the
97
+ * callback settles — including a partially successful `addChannel`.
98
+ *
99
+ * There is no wall-clock deadline of its own: streaming is progress-bounded by
100
+ * the caller, and the caller also bounds the one-shot SFTP calls it makes
101
+ * around the stream (metadata phase, optional channel opens), because nothing
102
+ * there produces progress to watch.
103
+ */
104
+ withTransferSftp<T>(alias: string, fn: (sftp: SFTPWrapper, addChannel: () => Promise<SFTPWrapper | undefined>) => Promise<T>): Promise<T>;
105
+ /**
106
+ * Run one callback on this alias's long-lived BROWSE SFTP session.
107
+ *
108
+ * Why: every list/stat/read used to open its own SFTP session, which is a
109
+ * whole channel-open round trip BEFORE the operation's own round trip. A single
110
+ * folder open is one list plus a stat per entry the explorer probes, and the
111
+ * panel's revision refresh re-lists every open directory, so that open/close
112
+ * churn sat directly on the click-to-pixels path. The session is shared by
113
+ * every browse request for the alias; ssh2 multiplexes concurrent requests
114
+ * over one channel by packet id (the same request map fastGet/fastPut use).
115
+ *
116
+ * Only read-only browse operations use it (`RemoteFiles.list/stat/read`):
117
+ * writes, uploads and downloads keep their own short-lived session, so a
118
+ * mutation never inherits a channel that a previous request may have left in
119
+ * an odd state.
120
+ *
121
+ * The session holds one channel slot and one connection hold while it exists,
122
+ * which is what a per-request session took too, so peak channel usage against
123
+ * the server's MaxSessions does not change. The trade-off is that the slot
124
+ * stays PARKED for up to `BROWSE_IDLE_MS` after the last request: the extras a
125
+ * bulk transfer asks for use `tryAcquireSlot`, so they never wait on it.
126
+ */
127
+ withBrowseSftp<T>(alias: string, fn: (sftp: SFTPWrapper) => Promise<T>, opts?: SftpOptions): Promise<T>;
76
128
  /** Upload one local file to an absolute remote path (parallel fastPut). */
77
129
  putFile(alias: string, localPath: string, remotePath: string): Promise<void>;
130
+ /**
131
+ * Open one SFTP session under its own deadline.
132
+ *
133
+ * ssh2 has no channel-open timeout: a server that never answers leaves this
134
+ * promise pending forever, which pins the connection's hold count and blocks
135
+ * idle re-arming (the "SSH looks dead" symptom) while the HTTP request hangs.
136
+ */
137
+ private openSession;
138
+ /**
139
+ * Take the browse channel for one operation (open it on first use).
140
+ *
141
+ * The returned lease counts as one in-flight operation; the caller's `finally`
142
+ * calls touchBrowse(). An open failure takes neither a slot nor a hold, so a
143
+ * failed host does not leave the pool's accounting skewed.
144
+ */
145
+ private leaseBrowse;
146
+ /**
147
+ * Open the browse session: a channel slot + a connection hold + the SFTP
148
+ * session itself, all released together by evictBrowse().
149
+ */
150
+ private openBrowse;
151
+ /** One completed browse operation: idle-close the channel when it is unused. */
152
+ private touchBrowse;
153
+ /**
154
+ * Close the browse session and give its slot and hold back. Idempotent; every
155
+ * way the session can end (idle, open failure, channel close, connection drop)
156
+ * goes through here so the accounting cannot drift.
157
+ *
158
+ * `expected` ties the eviction to ONE session object: a timer or a channel
159
+ * `close` event that fires after the state was already replaced must not close
160
+ * its successor. Callers that end the connection (drop/dispose) omit it.
161
+ */
162
+ private evictBrowse;
163
+ private browseState;
78
164
  /**
79
165
  * Take one channel slot for `alias`, waiting FIFO when the limit is reached.
80
166
  * The wait is bounded: waiting forever behind a peer that never finishes is
81
167
  * worse than a readable error naming the cause and what to do about it.
82
168
  */
83
169
  private acquireSlot;
170
+ /**
171
+ * Take one channel slot only if one is free RIGHT NOW; never queue.
172
+ *
173
+ * Optional work (a bulk transfer's second channel) must not wait behind
174
+ * `CHANNEL_WAIT_MS` of other operations: a "best effort" extra channel that
175
+ * delays the body of an already-streaming download by 30 s is worse than the
176
+ * one channel the transfer would have used anyway. A queued waiter also blocks
177
+ * the attempt on purpose — it has been waiting longer, and stealing its slot
178
+ * would just move the wait.
179
+ */
180
+ private tryAcquireSlot;
84
181
  /** Give a slot back, handing it straight to the longest-waiting operation. */
85
182
  private releaseSlot;
86
183
  private slotState;
@@ -112,3 +209,12 @@ export declare class RemotePool {
112
209
  private acquire;
113
210
  private dial;
114
211
  }
212
+ /**
213
+ * An operation that ran out of its wall-clock budget.
214
+ *
215
+ * Tagged on purpose: callers have to tell "the remote never answered" from a real
216
+ * remote failure (a missing path must not cost the session), and matching on the
217
+ * message text would silently stop working the moment the template changed.
218
+ */
219
+ export declare class DeadlineError extends Error {
220
+ }
@@ -14,6 +14,12 @@ export declare const REMOTE_API: {
14
14
  readonly files: "/api/dsh-remote/files";
15
15
  /** Streaming binary upload: raw request body, host and path in the query. */
16
16
  readonly upload: "/api/dsh-remote/upload";
17
+ /** Streaming binary download: raw response body, host and path in the query. */
18
+ readonly download: "/api/dsh-remote/download";
19
+ /** Streaming directory download: a remote `tar -czf -` of the directory. */
20
+ readonly downloadDir: "/api/dsh-remote/download-dir";
21
+ /** Streaming multi-selection download: one remote tar of repeated `path` params. */
22
+ readonly downloadMany: "/api/dsh-remote/download-many";
17
23
  readonly workspaces: "/api/dsh-remote/workspaces";
18
24
  readonly deploy: "/api/dsh-remote/deploy";
19
25
  readonly importSshConfig: "/api/dsh-remote/import-ssh-config";
@@ -26,6 +32,14 @@ export declare const REMOTE_API: {
26
32
  /** What one live session changed on its remote host (the review panel). */
27
33
  readonly changes: "/api/dsh-remote/changes";
28
34
  };
35
+ /**
36
+ * Most entries one multi-selection download may archive. The selection rides in
37
+ * the request URL (one `path` param per entry), so this bounds both the archive
38
+ * and the request line; a larger selection should download its folder instead.
39
+ */
40
+ export declare const MAX_SELECTION_DOWNLOAD = 100;
41
+ /** Suggested/attachment file name for one multi-selection archive. */
42
+ export declare function selectionDownloadName(count: number): string;
29
43
  /** Authentication flavors a host entry may carry (P0: direct only, no jump/agent). */
30
44
  export type RemoteAuthKind = 'key' | 'password';
31
45
  /** One stored host entry (the $DSH_HOME/dsh-remote.json store shape). */
@@ -1,3 +1,4 @@
1
+ import type { ServerResponse } from 'node:http';
1
2
  import type { RemotePool } from './pool.ts';
2
3
  import type { RemoteFileEntry, RemoteRead } from './protocol.ts';
3
4
  /** Single-read cap (matches the fs-ssh 8 MiB window). */
@@ -13,8 +14,62 @@ export declare const READ_CAP: number;
13
14
  export declare const LIST_ENTRY_CAP = 20000;
14
15
  /** Largest single upload accepted (matches the client-side planner cap). */
15
16
  export declare const UPLOAD_MAX_BYTES: number;
17
+ /**
18
+ * How long one download stream may make no progress before it is failed.
19
+ *
20
+ * A download has no wall-clock budget for the same reason an upload does not: a
21
+ * big file on a slow link is healthy for minutes. What must never happen is a
22
+ * silently dead stream pinning the SFTP session (and its channel slot) forever,
23
+ * so progress is the bound — any chunk resets this clock.
24
+ */
25
+ export declare const DOWNLOAD_IDLE_MS = 60000;
26
+ /** Upload progress bound (no body bytes and no write acknowledgements). */
27
+ export declare const UPLOAD_IDLE_MS = 60000;
28
+ /**
29
+ * Parallel-transfer shape, shared by download and upload.
30
+ *
31
+ * A single `createReadStream`/`createWriteStream` keeps exactly ONE SFTP request
32
+ * in flight per round trip; measured against a real host that cost about 8x
33
+ * (4.4 MiB/s single stream vs 35.4 MiB/s for ssh2's pipelined fastGet on the
34
+ * same link). 256 KiB chunks with 32 in-flight requests (8 MiB of app-side
35
+ * buffers) are the same tuning ssh2's fastGet/fastPut use and bound the
36
+ * per-transfer memory; on top of that ssh2 holds up to one 2 MiB channel window
37
+ * per channel in flight, so a two-channel download peaks around 12 MiB.
38
+ */
39
+ export declare const TRANSFER_CHUNK_BYTES: number;
40
+ /** In-flight chunk window (also the per-transfer APP-side memory bound: 8 MiB). */
41
+ export declare const TRANSFER_CONCURRENCY = 32;
42
+ /**
43
+ * Channels a big download spreads its READ window over.
44
+ *
45
+ * ssh2 (Channel.js `MAX_WINDOW`) and OpenSSH cap ONE SSH channel's window at
46
+ * 2 MiB, so a single channel can never keep more than that many bytes of READs
47
+ * outstanding however large the requested concurrency is. Measured against a
48
+ * real host on a 96 MiB file with the same total concurrency (256 KiB chunks):
49
+ * 1 channel 28.6 MiB/s, 2 channels 46.1, 4 channels 51.3 — two channels take
50
+ * most of the gain at a quarter of the cost of four. Uploads showed no such
51
+ * gain (46.0 → 50.4 MiB/s: the server's write path is the bound), so uploads
52
+ * stay on one channel.
53
+ */
54
+ export declare const TRANSFER_SESSIONS = 2;
55
+ /**
56
+ * Below this size a second channel is not worth its channel-open round trip and
57
+ * channel slot: the file is only a handful of READ windows long, so the extra
58
+ * channel would mostly be opened and closed.
59
+ */
60
+ export declare const MULTI_CHANNEL_MIN_BYTES: number;
16
61
  /** Assert an absolute POSIX remote path and return its normalized form. */
17
62
  export declare function remotePath(path: string): string;
63
+ /**
64
+ * `Content-Disposition` for one attachment (RFC 6266 + RFC 5987).
65
+ *
66
+ * Receivers prefer `filename*` when both forms are present (RFC 6266 §4.3),
67
+ * which is why a non-ASCII remote name survives the round trip; the quoted
68
+ * ASCII copy is the fallback for clients that do not understand the extended
69
+ * form. Quotes and backslashes are stripped from that fallback so they cannot
70
+ * break the header.
71
+ */
72
+ export declare function attachmentHeader(fileName: string): string;
18
73
  export declare class RemoteFiles {
19
74
  private readonly pool;
20
75
  /**
@@ -57,6 +112,24 @@ export declare class RemoteFiles {
57
112
  upload(alias: string, file: string, source: NodeJS.ReadableStream, maxBytes?: number, overwrite?: boolean): Promise<{
58
113
  size: number;
59
114
  }>;
115
+ /**
116
+ * Stream one remote file into an HTTP response (download to the local machine).
117
+ *
118
+ * Streaming, not `read()`: `read()` caps at 8 MiB because it answers a JSON
119
+ * editor read, while a download is whatever the user pointed at — a log, a
120
+ * binary, an artifact. The file is opened through one SFTP handle before the
121
+ * headers are written: symlinks are followed (lstat's size is the link
122
+ * target's string length, not the file's), directories are refused, and the
123
+ * content length comes from the same handle the body is read through. The
124
+ * session has no wall-clock deadline (see `DOWNLOAD_IDLE_MS`); the caller's
125
+ * response close and stream errors are both handled, so a cancelled download
126
+ * never leaves the SFTP session or its channel slot pinned.
127
+ *
128
+ * @param alias - host alias.
129
+ * @param file - absolute remote source path.
130
+ * @param res - HTTP response to write the file into.
131
+ */
132
+ download(alias: string, file: string, res: ServerResponse): Promise<void>;
60
133
  mkdir(alias: string, dir: string): Promise<void>;
61
134
  remove(alias: string, target: string, recursive: boolean): Promise<void>;
62
135
  rename(alias: string, oldPath: string, newPath: string): Promise<void>;