dsh-remote-vs 0.29.0 → 0.30.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.
@@ -1,4 +1,4 @@
1
- import { S as aliasRoot, r as isWindowsAbsolute } from "./worlds-RG8K5eom.js";
1
+ import { S as aliasRoot, r as isWindowsAbsolute } from "./worlds-CRRZMZhg.js";
2
2
  import { FileSystem, FsError } from "@deepseek-ai/dsh-fs";
3
3
  //#region src/p2/router-fs.ts
4
4
  /**
@@ -32,6 +32,18 @@
32
32
  import type { RemoteChangesDiff, RemoteChangesSummary, RemoteTimeouts } from '../protocol.ts';
33
33
  import type { RemotePool } from '../pool.ts';
34
34
  import type { RemoteWorlds } from '../p2/worlds.ts';
35
+ /**
36
+ * How many collapsed directories one untracked scan will expand.
37
+ *
38
+ * The fast walk (`--directory`) answers in one command no matter how many
39
+ * untracked directories there are; expanding each one is another `git ls-files`
40
+ * on the SAME shared connection, so the count has to be bounded. Twenty is the
41
+ * budget that keeps a normal monorepo complete (a session creates a handful of
42
+ * directories) while a checkout full of un-ignored build output stops early and
43
+ * says so (`truncated`), instead of turning one background scan into hundreds of
44
+ * exec channels.
45
+ */
46
+ export declare const UNTRACKED_EXPAND_DIRS = 20;
35
47
  /** The two facts a turn boundary needs from a Session, kept cordis-free. */
36
48
  export interface LedgerTarget {
37
49
  sessionId: string;
@@ -343,8 +355,36 @@ export declare class SessionChanges {
343
355
  * runs twice at once, and only runs again after {@link untrackedCadence}. A
344
356
  * repository that cannot answer inside {@link untrackedBudget} is written off
345
357
  * for the session (`untrackedGivenUp`) rather than retried every turn.
358
+ *
359
+ * Two phases since the scan learned `--directory`: one fast walk that collapses
360
+ * untracked directories (`build/` instead of 3000 paths) and then a BOUNDED
361
+ * expansion of the collapsed entries, because the panel's contract is a list of
362
+ * FILES. A walk that already answered with files expands nothing at all.
346
363
  */
347
364
  private kickUntracked;
365
+ /**
366
+ * Turn the fast walk's collapsed directories back into files, within bounds.
367
+ *
368
+ * Bounded THREE ways, because every expansion is another `git ls-files` on the
369
+ * same shared connection and the scan runs in the background where nobody is
370
+ * watching:
371
+ *
372
+ * - at most {@link UNTRACKED_EXPAND_DIRS} directories, sorted first so the
373
+ * choice is deterministic (a rescan of an unchanged tree expands the same
374
+ * ones, and the gate can pin exactly which);
375
+ * - the same file cap the panel lists (`maxFiles`, 500 by default), so one
376
+ * huge directory cannot push the list past what is displayable;
377
+ * - the fast walk's own deadline: when it runs out the phase stops.
378
+ *
379
+ * Hitting any of them — or an expansion that fails — marks the result
380
+ * `truncated` instead of returning a short list silently. A failed expansion is
381
+ * NOT `untrackedGivenUp`: the fast walk answered, so new-file detection still
382
+ * works; only part of it is missing.
383
+ *
384
+ * @returns the file entries (walk files + expanded ones) and whether the list
385
+ * is incomplete.
386
+ */
387
+ private expandUntracked;
348
388
  /**
349
389
  * How long before the untracked scan may run again.
350
390
  *
@@ -380,22 +420,37 @@ export declare class SessionChanges {
380
420
  private withWatchdog;
381
421
  /** Read a batch of files, capped per file and in total. */
382
422
  private readPaths;
383
- /** Run one command on the host, normalizing failure into a reason string. */
423
+ /**
424
+ * Run one command on the host, normalizing failure into a reason string.
425
+ *
426
+ * Every command this ledger issues is a git command (a repository read: `git
427
+ * status`, the untracked walk, its expansion, the file-content reads — the
428
+ * recorder never mutates). So they all spend the host's git-command budget
429
+ * (`lane: 'git'`) instead of a shared exec slot: these scans run in the HOST
430
+ * process while the user is working, and a 300-second `git status` must not be
431
+ * the reason a monitor sample, the process panel or an agent tool answers
432
+ * "host is busy".
433
+ */
384
434
  private run;
385
435
  /** Turn a failed scan into something a user can act on. */
386
436
  private reasonOf;
387
437
  /** One exec's budget: the git setting, clamped so a hung host cannot pile up work. */
388
438
  private execBudget;
389
- /** The untracked scan gets its own, more generous budget. */
390
439
  /**
391
- * The untracked scan gets its own, much more generous budget.
392
- *
393
- * Three minutes is a deliberate choice for a monorepo: the walk is proportional
394
- * to the whole checkout, not to the session, and the reference AOSP tree has
395
- * been measured past a minute cold. Waiting is acceptable here because the
396
- * scan runs in the background and the tracked changes are already on screen;
397
- * giving up early is not, because the files a session creates with a shell
398
- * command are visible ONLY through this scan.
440
+ * The untracked scan gets its own, more generous budget — one minute.
441
+ *
442
+ * The walk is proportional to the whole checkout, not to the session, so it
443
+ * cannot use the ordinary git budget. It used to be three minutes; that ceiling
444
+ * was set before the scan learned `--directory`, when a monorepo's answer really
445
+ * could take that long. Now the fast walk collapses whole directories, so a
446
+ * minute is already several times the useful wait, and every second past it is
447
+ * spent holding an exec channel on the SHARED connection while the tree is
448
+ * still being walked for nothing. Past a minute the honest answer is "this host
449
+ * cannot enumerate new files quickly enough" — `untrackedFailure` says so and the
450
+ * panel offers a retry, which is the same contract as before, just cut shorter.
451
+ *
452
+ * The floor (10s) is untouched: a small repository must never be cut off by a
453
+ * tiny configured `gitMs`.
399
454
  */
400
455
  private untrackedBudget;
401
456
  /**
@@ -143,19 +143,64 @@ export declare function excludeDirNames(dirs: readonly string[] | undefined): st
143
143
  /**
144
144
  * New files git is not tracking yet (the ones a session usually creates).
145
145
  *
146
+ * `--directory` is the load-bearing flag. Without it git descends into every
147
+ * untracked directory and prints one path per FILE: measured on the reference
148
+ * monorepo that is 11.25s warm, and on a cold AOSP checkout past a minute. With
149
+ * it, an untracked directory is reported ONCE as `dir/` (trailing slash) and git
150
+ * stops descending — a build tree or an un-ignored dependency tree costs one
151
+ * record instead of thousands of `stat`s. The scan still has to walk the tracked
152
+ * part of the tree, but the expensive half is exactly the part that is skipped.
153
+ *
154
+ * The semantic cost is that the answer now names directories; the caller expands
155
+ * the ones it still wants files for with {@link untrackedExpandCommand}, within
156
+ * bounds of its own (see `UNTRACKED_EXPAND_DIRS` in `recorder.ts`). A file that
157
+ * git reports directly is already the final answer.
158
+ *
146
159
  * The exclusions are pushed down as pathspecs (`:(exclude)out`) rather than
147
160
  * filtered after the fact, so those paths never cross the wire and never enter
148
161
  * the 500-row cap. Measured on a tree with 3000 build outputs + 300 sources:
149
162
  * 3300 records / 61.5 KB unfiltered versus 300 records / 6.8 KB with two
150
- * exclusions — the walk itself costs the same either way (git still descends
151
- * those directories), so the win is wire bytes, parse time and the read budget,
152
- * not scan latency.
163
+ * exclusions.
153
164
  *
154
165
  * @param root - remote absolute POSIX directory (the session cwd).
155
166
  * @param excludeDirs - directory names to leave out (see {@link excludeDirNames}).
156
167
  * @returns a `sh` script printing NUL-separated paths.
157
168
  */
158
169
  export declare function untrackedCommand(root: string, excludeDirs?: readonly string[]): string;
170
+ /**
171
+ * Whether a `--directory` record names a collapsed DIRECTORY.
172
+ *
173
+ * git marks one with a trailing slash; a record without it is a file, which is
174
+ * already the final answer and must not be expanded again.
175
+ */
176
+ export declare function isUntrackedDirectoryPath(path: string): boolean;
177
+ /**
178
+ * List the files inside EVERY directory a {@link untrackedCommand} walk
179
+ * collapsed, in ONE command.
180
+ *
181
+ * Same walk, same exclusions, minus `--directory`: the caller gets file paths
182
+ * again. One command for all of them on purpose — git also collapses directories
183
+ * that hold nothing but IGNORED files (`build/` full of gitignored output) and
184
+ * empty ones, so a per-directory loop would spend a whole round trip (and one of
185
+ * the expansion slots) proving that such a directory has no visible file inside.
186
+ * Batched, an empty directory costs nothing and cannot push a real one out of
187
+ * the slot budget.
188
+ *
189
+ * Every directory comes from git's own output, but each still crosses a shell, so
190
+ * each goes through {@link shq} — a directory named `it's a 目录` is one quoted
191
+ * argument, never a second command or a flag.
192
+ *
193
+ * The trailing slash the fast walk adds is dropped: the pathspec names the
194
+ * directory either way, and a bare path keeps this builder from ever emitting
195
+ * `-- ''` (which would mean "the whole repository").
196
+ *
197
+ * @param root - remote absolute POSIX directory (the session cwd).
198
+ * @param dirs - collapsed directories from {@link untrackedCommand}, with or
199
+ * without their trailing slashes.
200
+ * @param excludeDirs - the same exclusions the fast walk used (nested build
201
+ * output inside a collapsed directory must stay out too).
202
+ */
203
+ export declare function untrackedExpandCommand(root: string, dirs: readonly string[], excludeDirs?: readonly string[]): string;
159
204
  /**
160
205
  * Parse `git status --porcelain -z -uno` output.
161
206
  *
@@ -0,0 +1,73 @@
1
+ /**
2
+ * SSH connection-pool section shown on the monitor page, right under the
3
+ * process table.
4
+ *
5
+ * The pool is where "why is this slow" has an actual answer: one shared TCP
6
+ * connection per host carries exec/git/monitor traffic, terminals and port
7
+ * forwards dial their own, file operations ride a third, and each lane has a
8
+ * channel budget. When a budget is full the work QUEUES — and that is invisible
9
+ * from the file tree, where a slow listing just looks like a slow remote. So
10
+ * the page prints the four lanes, their channel counts, the slot occupancy and
11
+ * the route the shared connection took.
12
+ *
13
+ * Cost rules, the same ones the process section above follows:
14
+ * - collapsed by default; a collapsed section issues ZERO requests, because a
15
+ * closed diagnostic panel must not become the plugin's traffic source;
16
+ * - sampling happens only while the section is EXPANDED, the monitor panel is
17
+ * the visible view AND the page is in the foreground. There is no second
18
+ * throttle: the panel's own interval (and its pause control) is the cadence.
19
+ *
20
+ * Degradation: a Host that predates the route answers 404. That is not an error
21
+ * — the section keeps its header and prints ONE muted line saying so, instead of
22
+ * an error banner or an empty pool that would read as "nothing is connected".
23
+ * After it has said that it stops asking: the answer cannot change without an
24
+ * upgrade and a page reload.
25
+ */
26
+ import { type ReactNode } from 'react';
27
+ import type { RemoteHostPoolStats, RemoteHostSummary } from '../protocol.ts';
28
+ /** Fallback cadence when the panel has no interval of its own. */
29
+ export declare const POOL_POLL_MS = 5000;
30
+ /**
31
+ * Rounds waiting for a channel on ANY budget of one host.
32
+ *
33
+ * All three budgets are queues the user can be stuck behind, so the badge, the
34
+ * summary and the "a queue sorts first" rank count them together; which budget
35
+ * is full is the per-line detail below the lanes.
36
+ */
37
+ export declare function queuedOf(host: RemoteHostPoolStats): number;
38
+ /**
39
+ * Channels riding that host's lanes (the header summary's "N connections").
40
+ *
41
+ * The helper counts too: it is its own SSH connection with one channel, and a
42
+ * summary that said "0 connections" while a helper session was up would be the
43
+ * one number on the page that lies. Its lane is absent when the Host cannot
44
+ * report it, and then it contributes nothing.
45
+ */
46
+ export declare function channelsOf(host: RemoteHostPoolStats): number;
47
+ /**
48
+ * Host order: the CURRENT host first, then a queue, then alias.
49
+ *
50
+ * The current host is the one the workspace is bound to, so its numbers are the
51
+ * answer to "why is what I am doing slow" — it belongs at the top even when it
52
+ * has nothing queued. Everything below keeps the rules this list was built on:
53
+ * a queued host outranks an idle one, and the rest is alias order.
54
+ *
55
+ * The host with work waiting behind a full budget is the one the user is
56
+ * looking for, so "has a queue" is the only promotion. The rank is a BOOLEAN on
57
+ * purpose: ranking by the queue DEPTH made rows swap places between polls (a
58
+ * host draining from 3 queued to 1 slid under a host at 2 — the same two hosts,
59
+ * a different order, nothing the user could have come to read). Everything else
60
+ * keeps a fixed order; the number itself is on the row's badge and in the
61
+ * summary. Aliases compare by code unit, not `localeCompare`: the order must
62
+ * not depend on the browser's locale.
63
+ */
64
+ export declare function sortPoolHosts(hosts: readonly RemoteHostPoolStats[], currentAlias?: string): RemoteHostPoolStats[];
65
+ export declare function ConnectionsSection(props: {
66
+ t: (key: string) => string;
67
+ hosts: RemoteHostSummary[];
68
+ visible: boolean;
69
+ paused: boolean;
70
+ intervalMs: number;
71
+ /** Alias of the host this workspace is bound to (sorted first). */
72
+ currentAlias?: string;
73
+ }): ReactNode;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Typed fetch wrapper over the /api/dsh-remote JSON API (full P0 surface).
3
3
  */
4
- import { type GitBranch, type GitCommit, type GitShow, type GitStatus, type HelperAvailability, type ImportReport, type RemoteChangesDiff, type RemoteChangesSummary, type RemoteConnectionStatus, type RemoteDeployState, type RemoteExecResult, type RemoteFileEntry, type RemoteForwardRequest, type RemoteForwardState, type RemoteHostProxySetting, type RemoteHostSummary, type RemoteListenPortsResult, type RemoteProcessKillResult, type RemoteProcessesResult, type RemotePluginMeta, type RemoteProbe, type RemoteProxySettingsPatch, type RemoteProxySettingsView, type RemoteRead, type RemoteRoutingStatus, type RemoteTimeouts, type RemoteViewSettings, type RemoteWorkspaceBinding, type RemoteWriteConflict, type RemoteWriteResult } from '../protocol.ts';
4
+ import { type GitBranch, type GitCommit, type GitShow, type GitStatus, type HelperAvailability, type ImportReport, type RemoteChangesDiff, type RemoteChangesSummary, type RemoteConnectionStatus, type RemoteDeployState, type RemoteExecResult, type RemoteFileEntry, type RemoteForwardRequest, type RemoteForwardState, type RemoteHostProxySetting, type RemoteHostSummary, type RemoteListenPortsResult, type RemoteProcessKillResult, type RemoteProcessesResult, type RemotePluginMeta, type RemotePoolStatsResult, type RemoteProbe, type RemoteProxySettingsPatch, type RemoteProxySettingsView, type RemoteRead, type RemoteRoutingStatus, type RemoteTimeouts, type RemoteViewSettings, type RemoteWorkspaceBinding, type RemoteWriteConflict, type RemoteWriteResult } from '../protocol.ts';
5
5
  export declare class RemoteApiError extends Error {
6
6
  readonly status: number;
7
7
  /**
@@ -161,6 +161,18 @@ export declare function remoteWriteSequence(): number;
161
161
  * stash invalidate the quick-open index at all.
162
162
  */
163
163
  export declare function execChangesWorktree(command: string): boolean;
164
+ /**
165
+ * Which HOST channel budget a command spends (see `api.exec`).
166
+ *
167
+ * The host keeps three budgets on the shared connection: the default exec one,
168
+ * `network` for `git fetch/pull/push/sync` (they can hold a channel for the whole
169
+ * 20-minute network timeout) and `git` for git commands — the reads
170
+ * (`git status/diff/log` and the ledger's scans, 300 s by default) and the local
171
+ * writes (commit / stage / discard / branch verbs). Both of those used to park an
172
+ * exec slot for minutes, which is what starved the monitor, the process panel and
173
+ * the agent tools.
174
+ */
175
+ export type ExecLane = 'exec' | 'network' | 'git';
164
176
  export declare const api: {
165
177
  getHosts: () => Promise<RemoteHostSummary[]>;
166
178
  createHost: (payload: HostForm) => Promise<RemoteHostSummary>;
@@ -211,8 +223,15 @@ export declare const api: {
211
223
  * One remote command (`/exec`), foreground unless `opts.background` asks for
212
224
  * the git channel. Reads the SCM panel builds stay foreground; the
213
225
  * repository-wide walks pass `{ background: true }` (see `scm/actions.ts`).
226
+ *
227
+ * `lane` picks the HOST's channel budget, and it is a separate argument on
228
+ * purpose: `opts` is scheduling (request gate, abort) and never reaches the
229
+ * body, while this one is a body field the pool reads. `'network'` is for
230
+ * `git fetch/pull/push/sync` only — those can hold a channel for 20 minutes and
231
+ * must not spend the slots every other command waits on. Omitted means the
232
+ * shared exec budget, i.e. what all existing callers get.
214
233
  */
215
- exec: (alias: string, command: string, timeoutMs?: number, opts?: RequestOptions) => Promise<RemoteExecResult>;
234
+ exec: (alias: string, command: string, timeoutMs?: number, opts?: RequestOptions, lane?: ExecLane) => Promise<RemoteExecResult>;
216
235
  /**
217
236
  * Streaming exec: the network verbs' live log.
218
237
  *
@@ -220,10 +239,20 @@ export declare const api: {
220
239
  * command runs, and the promise settles on the `exit` frame. An aborted
221
240
  * `signal` cancels the remote process group on the host side (the route acts
222
241
  * on the closed response), so a cancel button can actually stop a push.
242
+ *
243
+ * `lane` marks the HOST budget exactly like `api.exec`'s fifth argument
244
+ * (`'network'` for fetch/pull/push, `'git'` for git commands). It is a body
245
+ * field, kept in this handlers bag because that bag IS the options object this
246
+ * call already has (a fifth positional would read as `timeoutMs`). The older
247
+ * `network: true` spelling is still accepted and means `lane: 'network'`, so a
248
+ * caller written before the third budget keeps working.
223
249
  */
224
250
  execStream: (alias: string, command: string, timeoutMs: number, handlers: {
225
251
  onData?: (stream: "out" | "err", text: string) => void;
226
252
  signal?: AbortSignal;
253
+ lane?: ExecLane;
254
+ /** @deprecated use `lane: 'network'` */
255
+ network?: boolean;
227
256
  }) => Promise<RemoteExecResult>;
228
257
  getWorkspaces: () => Promise<{
229
258
  workspaces: RemoteWorkspaceBinding[];
@@ -347,6 +376,16 @@ export declare const api: {
347
376
  * between the panel's host list and this call is a normal 404.
348
377
  */
349
378
  hostMetrics: (alias: string, refresh?: boolean) => Promise<import("../protocol.ts").RemoteHostMetrics>;
379
+ /**
380
+ * Live SSH pool shape of every host (connections, channels, slot occupancy).
381
+ *
382
+ * A purely LOCAL read of the Host's own pool — no remote command rides it, so
383
+ * the monitor page can poll it while a section is open without spending a
384
+ * channel. `undefined` means the Host does not know the route (404, an older
385
+ * plugin): the caller degrades quietly instead of painting an error, the same
386
+ * rule `proc.hostTooOld` follows for the process panel.
387
+ */
388
+ getPoolStats: () => Promise<RemotePoolStatsResult | undefined>;
350
389
  git: {
351
390
  status(alias: string, path: string): Promise<GitStatus>;
352
391
  log(alias: string, path: string, max: number, branch?: string): Promise<GitCommit[]>;
@@ -10,6 +10,7 @@
10
10
  import { REMOTE_API } from '../../protocol.ts';
11
11
  import type { GitBranch, GitCommit, GitCommitFile, GitRemote, GitStash, GitStatusDetail, RemoteExecResult, RemoteRead } from '../../protocol.ts';
12
12
  import { type BlameLine, type FileHistoryCommit } from '../blame-model.ts';
13
+ import { type ExecLane } from '../api.ts';
13
14
  import { type PushTarget } from '../exec-output.ts';
14
15
  /** Error carrying a message already fit for the UI. */
15
16
  export declare class GitOpError extends Error {
@@ -34,6 +35,23 @@ export declare function joinRemote(dir: string, rel: string): string;
34
35
  export interface RunOptions {
35
36
  background?: boolean;
36
37
  signal?: AbortSignal;
38
+ /**
39
+ * Which HOST channel budget this command spends.
40
+ *
41
+ * The default for everything in this file is `'git'` — the git-command budget,
42
+ * where a big tree's `git status` is allowed 300 s and a git command used to
43
+ * park one of the shared exec slots for that whole time. It covers the local
44
+ * writes too (`commit`, `stage`, `discard`, branch verbs): they are git commands
45
+ * with a git timeout, and they must not compete with the monitor and the agent
46
+ * tools for the exec slots either. `'network'` is for the fetch/pull/push family,
47
+ * whose budget is even longer (20 minutes). Omitted means "the default above",
48
+ * and only a command that is NOT a git command may ask for `'exec'` — there is
49
+ * none in this module today.
50
+ *
51
+ * Deliberately NOT part of {@link RequestOptions}: that bag drives the local
52
+ * request gate and the fetch, while this is a body field the host's pool reads.
53
+ */
54
+ lane?: ExecLane;
37
55
  }
38
56
  /** The repository that encloses a workspace directory (undefined when none). */
39
57
  export declare function resolveRepoRoot(alias: string, workspaceRoot: string): Promise<string | undefined>;
@@ -202,7 +220,13 @@ export declare function applyHunk(alias: string, root: string, patch: string, mo
202
220
  export declare function commitAll(alias: string, root: string, message: string, amend?: boolean): Promise<string>;
203
221
  /** Last commit message (drives the amend flow). */
204
222
  export declare function lastCommitMessage(alias: string, root: string): Promise<string>;
205
- /** fetch / pull / push / sync. */
223
+ /**
224
+ * fetch / pull / push / sync.
225
+ *
226
+ * Every branch here is a NETWORK verb (`{ lane: 'network' }`): each one can hold a
227
+ * channel for `networkBudgetMs`, so it spends the host's small network budget
228
+ * rather than the repository-read one the rest of this module uses.
229
+ */
206
230
  export declare function syncRepo(alias: string, root: string, kind: 'fetch' | 'pull' | 'push' | 'sync'): Promise<string>;
207
231
  /**
208
232
  * Push to an explicit remote with an explicit refspec (Gerrit review flow:
@@ -1,5 +1,13 @@
1
+ /**
2
+ * Helper RPC over an ssh2 exec channel: the Windows-native transport for the
3
+ * official helper wire protocol. Speaks stdio RPC (SshRpcPeer + official
4
+ * schemas) to the deployed `dsh-ssh-helper` binary — no OpenSSH CLI, no POSIX
5
+ * gates. One connection per host alias; heartbeats keep the helper lease alive.
6
+ */
7
+ import { Client } from 'ssh2';
1
8
  import { z } from 'zod';
2
9
  import type { RemoteHostEntry } from '../protocol.ts';
10
+ import type { RoutedDial } from '../pool.ts';
3
11
  export interface RpcDialOpts {
4
12
  entry: RemoteHostEntry;
5
13
  /** Absolute remote path of the helper executable. */
@@ -9,6 +17,26 @@ export interface RpcDialOpts {
9
17
  /** Remote default workspace for the hello handshake. */
10
18
  workspace: string;
11
19
  leaseMs?: number;
20
+ /**
21
+ * The HOST's routed transport for this alias (proxy tunnel / jump-host channel),
22
+ * optional so a caller without a pool still dials directly.
23
+ *
24
+ * Without it this transport is a BARE direct connection: a host reachable only
25
+ * through a proxy or jump host would answer exec/SFTP (the pool honours the
26
+ * route) and fail every file/Git fast path — the "some features work, some do
27
+ * not" report. The pool supplies it via `openRoutedSocket`; the returned
28
+ * `release` is called here (once) on failure, close, reconnect and dispose.
29
+ */
30
+ openSocket?: () => Promise<RoutedDial>;
31
+ /**
32
+ * The ssh2 client factory.
33
+ *
34
+ * A seam, not a preference — the same one `RemotePool.makeClient` has: the only
35
+ * way a self-check can observe what this transport hands ssh2 (`{sock}` with no
36
+ * `host`/`port` for a routed dial, the reverse for a direct one) without a real
37
+ * server. Production never overrides it.
38
+ */
39
+ makeClient?: () => Client;
12
40
  }
13
41
  export interface RpcHello {
14
42
  protocol: number;
@@ -63,6 +91,17 @@ export declare class RpcConnection {
63
91
  * grow host memory.
64
92
  */
65
93
  private stderrTail;
94
+ /**
95
+ * Teardown of the ROUTED transport this attempt rides (proxy socket / jump-host
96
+ * tunnel), or undefined for a direct dial.
97
+ *
98
+ * It lives on the instance because the release has to outlive the handshake: the
99
+ * tunnel must stay open exactly as long as the SSH connection rides it, so the
100
+ * call belongs in `teardownTransport` (dispose, reconnect, failed open) rather
101
+ * than in the dial promise. The pool's release is idempotent, so calling it from
102
+ * a failure path AND from the teardown is safe.
103
+ */
104
+ private releaseRoute;
66
105
  /** Per-connection in-flight cap; see MAX_IN_FLIGHT. */
67
106
  private readonly gate;
68
107
  constructor(opts: RpcDialOpts);
@@ -70,6 +109,15 @@ export declare class RpcConnection {
70
109
  get alive(): boolean;
71
110
  /** Whatever the helper last wrote to stderr — empty when it said nothing. */
72
111
  get diagnostics(): string;
112
+ /**
113
+ * How many helper calls are in flight right now.
114
+ *
115
+ * Read-only diagnostics for the monitor: the helper caps itself at its own
116
+ * gate, so a saturated helper shows up as a number here instead of looking
117
+ * like an idle connection. It is NOT a queue — a call waits inside the gate
118
+ * before it counts, so this number never exceeds the gate's ceiling.
119
+ */
120
+ get inFlight(): number;
73
121
  get ready(): Promise<RpcHello>;
74
122
  /** Send one helper operation (mirrors SshConnection.request for fs-ssh). */
75
123
  request<T>(method: string, params: unknown, schema: z.ZodType<T>, signal?: AbortSignal): Promise<T>;
@@ -36,6 +36,17 @@ export declare class RemoteWorlds {
36
36
  private readonly ctx;
37
37
  private readonly deps;
38
38
  private readonly rpcs;
39
+ /**
40
+ * Aliases whose helper connection is still being dialed.
41
+ *
42
+ * `rpcs` holds the PROMISE, so a caller that awaits it waits for the whole
43
+ * dial (up to `CONNECT_READY_TIMEOUT_MS`, 45 s through a proxy or a jump host).
44
+ * The monitor polls `helperLane` every few seconds and must never inherit that
45
+ * wait — the route is read-only and would report the previous sample for the
46
+ * whole dial, or hold the client's single-flight guard. A name in this set is
47
+ * therefore "cannot say yet", which the client already renders as no row.
48
+ */
49
+ private readonly dialingRpc;
39
50
  private readonly fsViews;
40
51
  private readonly fsReady;
41
52
  private readonly procs;
@@ -162,6 +173,23 @@ export declare class RemoteWorlds {
162
173
  sweepSpillRoot(alias: string, home: string, ttlDays: number): Promise<void>;
163
174
  /** Remove one session's spill directory when it is older than the TTL (best effort). */
164
175
  sweepSpillDir(alias: string, dir: string, ttlDays: number): Promise<void>;
176
+ /**
177
+ * The helper connection of one alias, for the monitor's fifth lane.
178
+ *
179
+ * The helper dials its OWN SSH connection (see `RpcConnection`), so the pool
180
+ * cannot report it — this is the only place that knows. Read-only by
181
+ * contract: it awaits a record that already exists and never starts a dial, a
182
+ * deploy or a reconnect, because the monitor polls this every few seconds and
183
+ * a diagnostic must not be able to bring a helper up (or keep a dead one
184
+ * alive). `undefined` means "cannot say": no record, a record still dialing, or
185
+ * a record the router is about to replace — the client then omits the row
186
+ * rather than claiming the helper is closed.
187
+ */
188
+ helperLane(alias: string): Promise<{
189
+ open: boolean;
190
+ channels: number;
191
+ held: number;
192
+ } | undefined>;
165
193
  /** Drop one host's RPC + fs view + proc runtime (call after host update/delete). */
166
194
  dropHost(alias: string): Promise<void>;
167
195
  dispose(): Promise<void>;