dsh-remote-vs 0.29.0 → 0.31.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.
Files changed (58) hide show
  1. package/README.en.md +53 -20
  2. package/README.md +41 -19
  3. package/THIRD-PARTY-NOTICES.md +6 -6
  4. package/cordis.patch.yml +31 -76
  5. package/lib/client.js +319 -91
  6. package/lib/index.js +845 -129
  7. package/lib/p2-router-fs.js +15 -1
  8. package/lib/types/changes/recorder.d.ts +65 -10
  9. package/lib/types/changes/status.d.ts +48 -3
  10. package/lib/types/client/ConnectionsSection.d.ts +73 -0
  11. package/lib/types/client/WorkspacesView.d.ts +2 -0
  12. package/lib/types/client/api.d.ts +41 -2
  13. package/lib/types/client/composer.d.ts +8 -1
  14. package/lib/types/client/scm/actions.d.ts +25 -1
  15. package/lib/types/client/selection-popup.d.ts +1 -1
  16. package/lib/types/client/ui.d.ts +7 -4
  17. package/lib/types/p2/helper-rpc.d.ts +48 -0
  18. package/lib/types/p2/router-fs.d.ts +9 -1
  19. package/lib/types/p2/worlds.d.ts +51 -0
  20. package/lib/types/pool.d.ts +245 -10
  21. package/lib/types/protocol.d.ts +96 -0
  22. package/lib/{worlds-RG8K5eom.js → worlds-BdxLeKul.js} +134 -7
  23. package/package.json +46 -46
  24. package/src/changes/recorder.ts +151 -15
  25. package/src/changes/status.ts +59 -4
  26. package/src/client/ConnectionsSection.tsx +359 -0
  27. package/src/client/DirectoryFlow.tsx +8 -0
  28. package/src/client/EditorPane.tsx +5 -1
  29. package/src/client/HostsView.tsx +2 -0
  30. package/src/client/MonitorView.tsx +14 -0
  31. package/src/client/RemoteExplorer.tsx +11 -2
  32. package/src/client/RemoteRoot.tsx +1 -0
  33. package/src/client/SettingsHosts.tsx +1 -0
  34. package/src/client/WorkspaceWizard.tsx +1 -0
  35. package/src/client/WorkspacesView.tsx +21 -1
  36. package/src/client/api.ts +72 -4
  37. package/src/client/composer.ts +8 -1
  38. package/src/client/i18n.ts +50 -2
  39. package/src/client/scm/DiffView.tsx +5 -2
  40. package/src/client/scm/actions.ts +63 -12
  41. package/src/client/selection-popup.ts +1 -1
  42. package/src/client/ui.tsx +9 -7
  43. package/src/client/vsc/vsc.css +231 -3
  44. package/src/index.ts +31 -0
  45. package/src/p2/helper-rpc.ts +73 -5
  46. package/src/p2/router-fs.ts +29 -1
  47. package/src/p2/worlds.ts +116 -1
  48. package/src/pool.ts +736 -111
  49. package/src/protocol.ts +100 -0
  50. package/src/routes.ts +85 -13
  51. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.helper.json +20 -0
  52. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.tar.gz +4 -0
  53. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.tar.gz.sha256 +1 -0
  54. package/vendor/dsh-remote-helpers/pkg-sea-bare-import.patch +30 -0
  55. package/vendor/dsh-remote-helpers/ssh-helper-runtime-deps.patch +4 -3
  56. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.helper.json +0 -19
  57. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz +0 -4
  58. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz.sha256 +0 -1
@@ -1,7 +1,8 @@
1
+ import type { Duplex } from 'node:stream';
1
2
  import { type ClientChannel, type SFTPWrapper } from 'ssh2';
2
3
  import type { RemoteStore } from './store.ts';
3
4
  import { DeadlineError } from './timeouts.ts';
4
- import type { RemoteConnectionStatus, RemoteExecResult } from './protocol.ts';
5
+ import type { RemoteConnectionStatus, RemoteExecResult, RemoteHostPoolStats } from './protocol.ts';
5
6
  /**
6
7
  * The budget-out type lives in `timeouts.ts` (both halves need it); re-exported
7
8
  * here because existing callers and the browse gate import it from the pool.
@@ -27,11 +28,44 @@ export interface ExecOptions {
27
28
  * recurse into the machinery that dispatched them.
28
29
  */
29
30
  bare?: boolean;
31
+ /**
32
+ * Which channel budget this command spends. Omitted means the shared exec
33
+ * budget — every caller that predates the split keeps that behaviour.
34
+ *
35
+ * `'network'` is for `git fetch/pull/push/sync`: those can hold a channel for
36
+ * the whole network timeout (20 minutes by default), so they get
37
+ * {@link NET_CHANNEL_LIMIT} slots of their own instead of eating the exec slots
38
+ * the rest of the app (status polls, monitor, agent tools) depends on.
39
+ *
40
+ * `'git'` is for GIT COMMANDS — the repository reads (`git status/diff/log`, the
41
+ * session ledger's scans) AND the local writes the SCM panel runs (`commit`,
42
+ * `stage`, `discard`, branch verbs, `merge`): a big tree's `git status` is
43
+ * allowed 300 s, so these get {@link GIT_CHANNEL_LIMIT} slots — otherwise one
44
+ * slow command parks an exec slot for minutes and the monitor/process panel/
45
+ * agent tools queue behind it.
46
+ */
47
+ lane?: 'exec' | 'network' | 'git';
30
48
  }
31
49
  export interface ShellOptions {
32
50
  cols?: number;
33
51
  rows?: number;
34
52
  }
53
+ /**
54
+ * The transport one configured route hands to an ssh2 dial (see `openRoutedSocket`).
55
+ *
56
+ * `sock` is absent for a direct route, where ssh2 dials the target itself. When it
57
+ * IS present ssh2 must be given `{ sock }` and NOT `host`/`port`: supplying both
58
+ * lets ssh2 choose between "dial this host myself" and "ride the tunnel", and the
59
+ * choice is an implementation detail, not a feature.
60
+ *
61
+ * `release` is idempotent and is the OWNER's to call — a proxy socket has to be
62
+ * destroyed and a jump-host tunnel has to close its channel and give the jump
63
+ * host's hold back, or the next dial finds a pinned connection.
64
+ */
65
+ export interface RoutedDial {
66
+ sock?: Duplex;
67
+ release: () => void;
68
+ }
35
69
  export interface SftpOptions {
36
70
  /**
37
71
  * Wall-clock cap for the callback body. `0` disables it for an operation that
@@ -82,6 +116,38 @@ export declare class RemotePool {
82
116
  * stops working because of it — it only loses the isolation.
83
117
  */
84
118
  private readonly forwardConns;
119
+ /**
120
+ * Dedicated connections for FILE operations (one per alias).
121
+ *
122
+ * The third instance of the same argument. Browse/read/write/upload/download
123
+ * used to ride the shared connection, which meant a `git status` burst or a
124
+ * long exec could sit in front of a directory refresh (SSH offers no
125
+ * per-channel priority), AND that the shared link's channel budget was shared
126
+ * with file I/O: a few in-flight git/search commands and the explorer could not
127
+ * open a channel at all. A file operation is exactly the traffic a user is
128
+ * watching (a folder must open, a save must land), so it gets its own
129
+ * connection and its own channel budget (`sftpSlots`).
130
+ *
131
+ * Cost: one extra handshake per alias that touches files, plus one held TCP
132
+ * connection while any of its channels is open (the 30-minute idle eviction
133
+ * applies once the last one ends). `acquireSftp` falls back to the
134
+ * shared connection when this one cannot be established — a host that refuses
135
+ * extra connections still serves files, it only loses the isolation.
136
+ */
137
+ private readonly sftpConns;
138
+ /** Aliases whose dedicated-SFTP downgrade was already logged (once per alias). */
139
+ private readonly sftpFallbackNoted;
140
+ /** alias -> timestamp until which the dedicated SFTP connection is skipped. */
141
+ private readonly sftpBlocked;
142
+ /**
143
+ * Aliases whose file operations are DOWNGRADED right now (sticky until a
144
+ * dedicated connection succeeds again or the host is edited).
145
+ *
146
+ * Purely diagnostic: `stats()` reports it so the monitor page can say "these
147
+ * files are riding the shared connection" instead of leaving the user to
148
+ * wonder why a browse refresh still queues behind git.
149
+ */
150
+ private readonly sftpFallback;
85
151
  /** Aliases whose dedicated-forward downgrade was already logged (once per alias). */
86
152
  private readonly forwardFallbackNoted;
87
153
  /** alias -> timestamp until which the dedicated forward connection is skipped. */
@@ -90,8 +156,35 @@ export declare class RemotePool {
90
156
  private readonly hostKeys;
91
157
  /** Per-alias `setsid --wait` capability, probed once (see supportsSetsid). */
92
158
  private readonly setsidProbes;
93
- /** Per-alias channel slots and the queue waiting for one (see acquireSlot). */
159
+ /**
160
+ * Channel slots of the SHARED connection (see acquireSlot), and of the
161
+ * dedicated SFTP connection.
162
+ *
163
+ * Two tables because the budget is per connection (`MaxSessions` counts
164
+ * channels on one link): a fallback SFTP operation counts against the shared
165
+ * table — the connection it really rides — and never against both.
166
+ */
94
167
  private readonly slots;
168
+ private readonly sftpSlots;
169
+ /**
170
+ * Channel budget of the NETWORK verbs (see {@link NET_CHANNEL_LIMIT}).
171
+ *
172
+ * A third table on the SHARED connection: unlike the SFTP lane this is not about
173
+ * isolating bytes, it is about isolating TIME. A `git push` holds its channel
174
+ * for minutes, and the failure mode it caused — a full exec table, so every
175
+ * status refresh answered "host is busy" after 30 s — came from the two kinds
176
+ * sharing one ceiling.
177
+ */
178
+ private readonly netSlots;
179
+ /**
180
+ * Channel budget of the GIT COMMANDS (see {@link GIT_CHANNEL_LIMIT}).
181
+ *
182
+ * A fourth table on the SHARED connection, for the same reason as the network
183
+ * one — hold TIME, not traffic: a `git status` on a big tree may run for
184
+ * minutes, and a git command must not be the reason a monitor sample or an agent
185
+ * tool waits.
186
+ */
187
+ private readonly gitSlots;
95
188
  /** Per-alias BROWSE SFTP session (see withBrowseSftp). */
96
189
  private readonly browsed;
97
190
  /** Per-alias connection health for the browser's status chip (see status). */
@@ -117,12 +210,27 @@ export declare class RemotePool {
117
210
  * indicator's poll never creates a connection as a side effect.
118
211
  */
119
212
  status(): RemoteConnectionStatus[];
213
+ /**
214
+ * Live pool shape per host: connections, channels, and channel-budget
215
+ * occupancy (see `RemoteHostPoolStats`).
216
+ *
217
+ * Same contract as `status()`: read-only and dial-free, so the monitor's poll
218
+ * reports what the pool already knows instead of creating work. Answers every
219
+ * alias the store knows PLUS every alias the pool holds something for — a host
220
+ * removed from the store still has a connection for a moment, and a page that
221
+ * shows connections must not hide exactly those.
222
+ */
223
+ stats(): RemoteHostPoolStats[];
224
+ /** One lane of one host: dialed or not, its open channels, its pinned rounds. */
225
+ private laneOf;
226
+ /** One channel budget, as reported (a budget nobody touched is empty, not absent). */
227
+ private slotsOf;
120
228
  /**
121
229
  * The egress of the alias' LIVE connection, whichever class owns it.
122
230
  *
123
- * All three classes open through the same resolved route, so the first one
124
- * that is up answers for the alias; the shared connection is preferred because
125
- * it is the one exec/browse (the surface the chip describes) rides.
231
+ * All four classes open through the same resolved route, so the first one that
232
+ * is up answers for the alias; the shared connection is preferred because it is
233
+ * the one exec/browse (the surface the chip describes) rides.
126
234
  */
127
235
  private liveEgress;
128
236
  /**
@@ -178,13 +286,31 @@ export declare class RemotePool {
178
286
  * of queueing. The pool's own housekeeping (`bare`: the setsid probe and the
179
287
  * group kill) is exempt — a kill that waits behind user traffic would be a
180
288
  * worse bug than the one it fixes.
289
+ *
290
+ * `opts.lane` picks the budget: network verbs (`git fetch/pull/push/sync`) have
291
+ * their own small one, so a 20-minute push cannot starve the exec slots.
292
+ * Acquisition and release read the SAME table — a mismatch would leak a slot on
293
+ * one budget and double-count on the other.
181
294
  */
182
295
  exec(alias: string, command: string, opts?: ExecOptions): Promise<RemoteExecResult>;
296
+ /** The channel budget an exec spends, by lane (see `ExecOptions.lane`). */
297
+ private execBudget;
183
298
  /** The exec body, run while the caller already holds a channel slot. */
184
299
  private runExec;
185
300
  /** Open an interactive PTY shell. The caller owns the channel lifecycle. */
186
301
  shell(alias: string, opts?: ShellOptions): Promise<ClientChannel>;
187
- /** Open one exec channel. The caller owns the channel lifecycle. */
302
+ /**
303
+ * Open one exec channel. The caller owns the channel lifecycle.
304
+ *
305
+ * This channel spends an EXEC SLOT (same budget as `runExec`): it is a real
306
+ * `conn.exec` session on the shared connection, so `MaxSessions` counts it
307
+ * whether the pool does or not. The subprocess runtime opens these for every
308
+ * command it runs (`p2/ssh-proc.ts`) and can have several in flight, which used
309
+ * to be the one way to push the shared connection past its ceiling: sshd then
310
+ * refuses the extra channel HARD — no retry, and the operation fails looking
311
+ * like a broken host. A slot makes the surplus WAIT instead: bounded queue, then
312
+ * a readable "busy" message naming the cause.
313
+ */
188
314
  execChannel(alias: string, command: string): Promise<ClientChannel>;
189
315
  /**
190
316
  * Open one direct-tcpip channel to a TCP target reachable FROM the remote
@@ -285,6 +411,9 @@ export declare class RemotePool {
285
411
  * place that can still see the session, and a late one would otherwise leak a
286
412
  * server-side channel that no slot or hold accounts for (the caller has long
287
413
  * returned its own and moved on).
414
+ *
415
+ * `alias`/`map` name the connection the session rides, so the channel it holds
416
+ * is counted on the right lane (see `countChannel`).
288
417
  */
289
418
  private openSession;
290
419
  /**
@@ -298,6 +427,10 @@ export declare class RemotePool {
298
427
  /**
299
428
  * Open the browse session: a channel slot + a connection hold + the SFTP
300
429
  * session itself, all released together by evictBrowse().
430
+ *
431
+ * The lane is chosen HERE, once per session, and recorded on the state: the
432
+ * eviction path must give the slot and the hold back to the connection that
433
+ * actually served the session (dedicated SFTP, or the shared fallback).
301
434
  */
302
435
  private openBrowse;
303
436
  /** One completed browse operation: idle-close the channel when it is unused. */
@@ -314,11 +447,25 @@ export declare class RemotePool {
314
447
  private evictBrowse;
315
448
  private browseState;
316
449
  /**
317
- * Take one channel slot for `alias`, waiting FIFO when the limit is reached.
318
- * The wait is bounded: waiting forever behind a peer that never finishes is
319
- * worse than a readable error naming the cause and what to do about it.
450
+ * Take one channel slot for `alias` on the budget `slots` names, waiting FIFO
451
+ * when the limit is reached. The wait is bounded: waiting forever behind a peer
452
+ * that never finishes is worse than a readable error naming the cause.
453
+ *
454
+ * `slots` defaults to the SHARED connection's exec budget — the table every
455
+ * caller meant before the lanes existed; dedicated-lane callers pass theirs.
320
456
  */
321
457
  private acquireSlot;
458
+ /**
459
+ * The ceiling and the wording of one budget.
460
+ *
461
+ * The TABLE is the budget's identity: a caller that hands in a table gets that
462
+ * budget's own ceiling AND its own nouns, so a full network lane says "2
463
+ * network operations already hold channels" and a full git lane says "2 git
464
+ * commands already hold channels" instead of borrowing the exec sentence — a
465
+ * user reading "5 operations" about a two-slot lane would go looking for
466
+ * operations that do not exist. A new budget is described here, once.
467
+ */
468
+ private budgetOf;
322
469
  /**
323
470
  * Take one channel slot only if one is free RIGHT NOW; never queue.
324
471
  *
@@ -330,7 +477,7 @@ export declare class RemotePool {
330
477
  * would just move the wait.
331
478
  */
332
479
  private tryAcquireSlot;
333
- /** Give a slot back, handing it straight to the longest-waiting operation. */
480
+ /** Give a slot back to its budget, handing it straight to the longest waiter. */
334
481
  private releaseSlot;
335
482
  private slotState;
336
483
  /**
@@ -359,6 +506,23 @@ export declare class RemotePool {
359
506
  private hold;
360
507
  private holdIn;
361
508
  private release;
509
+ /**
510
+ * Count one SSH channel that is now open on a pooled connection, and give the
511
+ * number back when the channel closes.
512
+ *
513
+ * `held` is NOT this number (see `Pooled.channels`): a jump tunnel pins the
514
+ * jump host twice for its single channel, and `stats()` reports both, so the
515
+ * monitor page never prints a hold count as a channel count. The close listener
516
+ * mutates the entry OBJECT it was registered on, so a channel that outlives its
517
+ * entry cannot decrement the counter of a successor entry.
518
+ *
519
+ * The entry is looked up when the channel is COUNTED, so a session that answers
520
+ * pathologically late (after `drop()` and a fresh dial) is charged to the
521
+ * successor entry and given back when it closes. Accepted: the window needs a
522
+ * reply that outlives a host edit, the number is diagnostic, and the pair is
523
+ * still symmetric (one increment, one decrement).
524
+ */
525
+ private countChannel;
362
526
  private releaseIn;
363
527
  private acquire;
364
528
  /** `acquire` for the dedicated PTY connection map. */
@@ -380,6 +544,40 @@ export declare class RemotePool {
380
544
  * `acquireIn`.
381
545
  */
382
546
  private acquireForward;
547
+ /**
548
+ * Take the connection a FILE operation should ride: the dedicated SFTP one,
549
+ * else the shared one (recorded as the fallback).
550
+ *
551
+ * Same three-part shape as the PTY/forward precedents, for the same reasons:
552
+ *
553
+ * 1. `quiet` on the dial — a dedicated connection is an optional isolation, so
554
+ * the server refusing it (MaxStartups, a per-user limit) says nothing about
555
+ * the shared link and must not paint the connection chip red.
556
+ * 2. A short own budget ({@link SFTP_DEDICATED_BUDGET_MS}) — browsing is one
557
+ * request per folder, so waiting out the 45 s connect watchdog before falling
558
+ * back would freeze the explorer. The abandoned dial keeps running: if it
559
+ * eventually succeeds the connection is pooled and the next request uses it.
560
+ * 3. A cooldown ({@link SFTP_DEDICATED_BLOCK_MS}) — without it every browse
561
+ * request would pay that budget again. A success or `drop()` clears it.
562
+ *
563
+ * The shared fallback's own dial failure is NOT quiet (it is a real link
564
+ * failure and `acquire` reports it as one).
565
+ */
566
+ private acquireSftp;
567
+ /** The pooled map behind a lane: the dedicated SFTP connection, or the shared one. */
568
+ private laneConns;
569
+ /** The channel budget behind a lane: each connection has its own `MaxSessions`. */
570
+ private laneSlots;
571
+ /**
572
+ * Is this alias's dedicated SFTP connection in its short cooldown?
573
+ *
574
+ * Expired entries are dropped eagerly so the map cannot grow per alias forever.
575
+ */
576
+ private sftpCoolingDown;
577
+ /** Park the dedicated SFTP connection for one alias and log the downgrade, once. */
578
+ private blockSftp;
579
+ /** Log one alias's file-operation downgrade to the shared connection, once. */
580
+ private noteSftpFallback;
383
581
  private acquireIn;
384
582
  /** Evict ONE alias from ONE map (host removal drops both maps explicitly). */
385
583
  private evictFrom;
@@ -392,6 +590,43 @@ export declare class RemotePool {
392
590
  * overrides it.
393
591
  */
394
592
  private makeClient;
593
+ /**
594
+ * Open the transport `alias`'s configured route requires, WITHOUT dialing SSH.
595
+ *
596
+ * This is the part of {@link dial} that turns a `ResolvedProxy` decision into a
597
+ * socket: nothing for a direct route, a tunnel socket for a proxy, and a
598
+ * `direct-tcpip` channel riding the jump host's pooled connection for a jump.
599
+ * Extracted so a SECOND ssh2 dialer — p2's helper transport, which owns its own
600
+ * `Client` — takes exactly the same route instead of a bare direct connection
601
+ * (otherwise a host reachable only through a proxy or jump host answers exec and
602
+ * SFTP but fails every file/Git fast path).
603
+ *
604
+ * `route` may be passed in when the caller has already resolved it and needs the
605
+ * decision for its own purposes (`dial` reports the egress it settled on): the
606
+ * default resolves it from the store.
607
+ *
608
+ * The returned `release` is IDEMPOTENT and belongs to the caller: it tears down
609
+ * the tunnel (destroys the proxy socket / closes the channel and gives the jump
610
+ * host's hold back). It must be called exactly once by whoever owns the socket —
611
+ * on failure, on close, and on dispose. A direct route has nothing to release,
612
+ * so it gets a no-op.
613
+ */
614
+ private openRoute;
615
+ /**
616
+ * The routed transport for `alias`, for a caller that dials its OWN ssh2 client.
617
+ *
618
+ * Same decision, same error layering (`proxy auth failed: …`, `jump host "x"
619
+ * failed: …`), same socket as a pooled connection would ride — p2's helper
620
+ * transport uses this so "reachable only through the jump host" stops meaning
621
+ * "exec works, files do not".
622
+ *
623
+ * **The caller owns the result**: when `sock` is set, ssh2 must be given `{ sock }`
624
+ * and NOT `host`/`port` (both together let ssh2 choose between dialing the target
625
+ * itself and riding the tunnel). `release` must be called exactly once — on
626
+ * failure, on the connection's close, and on dispose — or the jump host's hold
627
+ * leaks and the proxy socket stays open.
628
+ */
629
+ openRoutedSocket(alias: string): Promise<RoutedDial>;
395
630
  /**
396
631
  * Open one SSH connection, through whatever route the store resolves.
397
632
  *
@@ -33,6 +33,8 @@ export declare const REMOTE_API: {
33
33
  readonly viewSettings: "/api/dsh-remote/view-settings";
34
34
  /** Profile-wide proxy default (per-host overrides live on the host rows). */
35
35
  readonly proxySettings: "/api/dsh-remote/proxy-settings";
36
+ /** Live SSH pool shape per host: connections, channels, slot occupancy. */
37
+ readonly connections: "/api/dsh-remote/connections";
36
38
  /** Current working directory of one live session (click resolution helper). */
37
39
  readonly sessionCwd: "/api/dsh-remote/session-cwd";
38
40
  /** What one live session changed on its remote host (the review panel). */
@@ -305,6 +307,100 @@ export interface RemoteConnectionStatus {
305
307
  */
306
308
  configured?: EgressInfo;
307
309
  }
310
+ /** One pool connection kind: whether it is dialed, and how many channels ride it. */
311
+ export interface RemotePoolLane {
312
+ /**
313
+ * The connection is fully dialed. A dial still in flight is NOT open (the pool
314
+ * creates its bookkeeping entry before the Client exists), and every lane is
315
+ * always present: a kind that is not dialed reports `false` here with zero
316
+ * channels and zero rounds, so "not in use" is a value, not a missing field.
317
+ */
318
+ open: boolean;
319
+ /** Channels currently open on this connection (exec sessions, SFTP sessions, PTY, tunnels). */
320
+ channels: number;
321
+ /** Rounds currently pinned to it (an operation in flight keeps the connection alive). */
322
+ held: number;
323
+ }
324
+ /** Channel-slot occupancy of one budget: what is running and what is waiting behind it. */
325
+ export interface RemotePoolSlots {
326
+ /** Operations holding a channel right now. */
327
+ active: number;
328
+ /** Operations queued for one (they fail after a bounded wait). */
329
+ queued: number;
330
+ /** How many may run at once. */
331
+ limit: number;
332
+ }
333
+ /**
334
+ * Live SSH pool shape of one host.
335
+ *
336
+ * Read-only diagnostics for the monitor page: "why is this slow" is usually one
337
+ * of three answers — too few connections (everything shares one TCP), the channel
338
+ * budget is full, or a queue has built up behind a stalled operation. Each is a
339
+ * number here, so the page can show the answer instead of a hunch.
340
+ */
341
+ export interface RemoteHostPoolStats {
342
+ alias: string;
343
+ /** The four connection classes the pool can hold for one host. */
344
+ connections: {
345
+ /** Everything that is not isolated: exec, git, monitor, helper, agent tools. */
346
+ shared: RemotePoolLane;
347
+ /** Interactive terminals (their own connection). */
348
+ pty: RemotePoolLane;
349
+ /** Local port forwards (their own connection). */
350
+ forward: RemotePoolLane;
351
+ /** File operations: browse, read, write, upload, download (their own connection). */
352
+ sftp: RemotePoolLane;
353
+ /**
354
+ * The SSH helper (p2 transport: the file/Git fast path).
355
+ *
356
+ * Optional because the helper dials from `p2/worlds.ts`, not from the pool: a
357
+ * Host that cannot report it (or has no helper deployed) omits the key rather
358
+ * than claiming "closed". When present, `channels` is the helper's own session
359
+ * and `held` counts the RPC calls in flight — a helper that is saturated shows
360
+ * up here instead of looking like an idle connection.
361
+ */
362
+ helper?: RemotePoolLane;
363
+ };
364
+ /** Channel budget of the shared connection (exec sessions, plus SFTP that fell back). */
365
+ slots: RemotePoolSlots;
366
+ /** Channel budget of the dedicated SFTP connection (absent while it is not used). */
367
+ sftpSlots?: RemotePoolSlots;
368
+ /**
369
+ * Channel budget of the NETWORK-verb lane (git fetch/pull/push/sync).
370
+ *
371
+ * These verbs can hold a channel for the whole network timeout (20 minutes by
372
+ * default), so they get their own small budget instead of eating the shared
373
+ * exec slots. Absent while no network verb is running and none is queued.
374
+ */
375
+ netSlots?: RemotePoolSlots;
376
+ /**
377
+ * Channel budget of the GIT-COMMAND lane (git status / diff / log, the session
378
+ * ledger's own scans, and the SCM panel's local writes such as commit / stage).
379
+ *
380
+ * A repository-wide `git status` is the longest single command the plugin runs
381
+ * outside the network verbs (300 s by default, 30 min at the ceiling) and it
382
+ * shares the connection with monitoring, the process panel and agent tools. Its
383
+ * own budget keeps a slow command from spending the exec slots those poll on.
384
+ * Absent while no git command is running and none is queued.
385
+ */
386
+ gitSlots?: RemotePoolSlots;
387
+ /** Route the shared connection was opened through, when it is open. */
388
+ egress?: EgressInfo;
389
+ /**
390
+ * File operations are riding the SHARED connection right now, because the host
391
+ * refused one of its own.
392
+ *
393
+ * Sticky until a dedicated connection succeeds again or the host is edited. It
394
+ * is diagnostic, not an error: the files still work, they just lost the
395
+ * isolation (and a browse refresh can queue behind exec again), which is
396
+ * exactly the thing a user staring at the monitor page cannot see otherwise.
397
+ */
398
+ sftpFallback?: boolean;
399
+ }
400
+ /** Response of {@link REMOTE_API.connections}. */
401
+ export interface RemotePoolStatsResult {
402
+ hosts: RemoteHostPoolStats[];
403
+ }
308
404
  /** Remote OS probe outcome. */
309
405
  export interface RemoteProbe {
310
406
  alias: string;