dsh-remote-vs 0.28.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.
Files changed (46) hide show
  1. package/README.en.md +63 -7
  2. package/README.md +51 -7
  3. package/lib/client.js +393 -112
  4. package/lib/index.js +2271 -160
  5. package/lib/p2-router-fs.js +1 -1
  6. package/lib/types/changes/recorder.d.ts +65 -10
  7. package/lib/types/changes/status.d.ts +48 -3
  8. package/lib/types/client/ConnectionsSection.d.ts +73 -0
  9. package/lib/types/client/HostsView.d.ts +139 -2
  10. package/lib/types/client/api.d.ts +65 -2
  11. package/lib/types/client/connection.d.ts +28 -1
  12. package/lib/types/client/scm/actions.d.ts +25 -1
  13. package/lib/types/forward.d.ts +11 -1
  14. package/lib/types/p2/helper-rpc.d.ts +48 -0
  15. package/lib/types/p2/worlds.d.ts +28 -0
  16. package/lib/types/pool.d.ts +337 -8
  17. package/lib/types/protocol.d.ts +218 -0
  18. package/lib/types/proxy.d.ts +136 -0
  19. package/lib/types/store.d.ts +81 -1
  20. package/lib/types/tools.d.ts +3 -0
  21. package/lib/{worlds-RG8K5eom.js → worlds-CRRZMZhg.js} +85 -6
  22. package/package.json +1 -1
  23. package/src/changes/recorder.ts +151 -15
  24. package/src/changes/status.ts +59 -4
  25. package/src/client/ConnectionStatus.tsx +19 -5
  26. package/src/client/ConnectionsSection.tsx +359 -0
  27. package/src/client/HostsView.tsx +552 -11
  28. package/src/client/MonitorView.tsx +14 -0
  29. package/src/client/PortsView.tsx +16 -0
  30. package/src/client/SettingsHosts.tsx +132 -6
  31. package/src/client/api.ts +102 -4
  32. package/src/client/connection.ts +76 -2
  33. package/src/client/i18n.ts +152 -2
  34. package/src/client/scm/actions.ts +63 -12
  35. package/src/client/vsc/vsc.css +281 -0
  36. package/src/forward.ts +38 -2
  37. package/src/importers.ts +125 -13
  38. package/src/keygen.ts +8 -1
  39. package/src/p2/helper-rpc.ts +73 -5
  40. package/src/p2/worlds.ts +48 -0
  41. package/src/pool.ts +1120 -100
  42. package/src/protocol.ts +228 -0
  43. package/src/proxy.ts +673 -0
  44. package/src/routes.ts +139 -5
  45. package/src/store.ts +335 -0
  46. package/src/tools.ts +47 -2
@@ -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,10 +1,147 @@
1
1
  /**
2
2
  * Hosts view: list + add/edit form + test + key bootstrap + push + import.
3
+ *
4
+ * The form also owns the host's 「网络出口」 (egress: proxy / jump host) block.
5
+ * It is COLLAPSED by default, because most hosts go out directly and a wall of
6
+ * empty proxy fields reads as "you must fill this in"; the collapsed row still
7
+ * carries a read-only chip with the resulting route, so the answer to "how does
8
+ * this host get out" never needs a click. The profile-wide default that
9
+ * `跟随默认` resolves to lives in Settings (`SettingsHosts.tsx`).
3
10
  */
4
11
  import { type ReactNode } from 'react';
5
- import type { RemoteHostSummary } from '../protocol.ts';
12
+ import type { RemoteHostProxySetting, RemoteHostProxyView, RemoteHostSummary, RemoteProxyMode, RemoteProxySetting, RemoteProxySettingsView } from '../protocol.ts';
13
+ import { type HostForm } from './api.ts';
14
+ /** The translator shape this plugin's views pass around. */
15
+ type TFn = (key: string) => string;
16
+ /** Everything the egress controls edit, as form strings. */
17
+ export interface ProxyFormState {
18
+ mode: RemoteProxyMode;
19
+ kind: 'http' | 'socks5';
20
+ host: string;
21
+ port: string;
22
+ username: string;
23
+ password: string;
24
+ viaAlias: string;
25
+ }
26
+ /** A blank draft: `跟随默认`, HTTP, no address (i.e. a fresh host). */
27
+ export declare function emptyProxyState(): ProxyFormState;
28
+ /**
29
+ * Seed the controls from a stored (secret-free) host view.
30
+ *
31
+ * The password box stays EMPTY on purpose: the Host never echoes it back, and
32
+ * `proxySettingOf` expresses "keep the stored one" by omitting the field, so an
33
+ * untouched box cannot overwrite a working credential with an empty string.
34
+ */
35
+ export declare function proxyStateOf(view: RemoteHostProxyView | undefined): ProxyFormState;
36
+ /** The profile default as a draft (it only knows `direct` / `proxy`). */
37
+ export declare function defaultProxyStateOf(view: RemoteProxySettingsView | undefined): ProxyFormState;
38
+ /**
39
+ * The endpoint half of a proxy decision.
40
+ *
41
+ * An empty password is OMITTED (not sent as `''`): that is the contract for
42
+ * "keep the stored secret", and it is the only reason the browser never has to
43
+ * see the password at all.
44
+ */
45
+ export declare function proxyTargetOf(state: ProxyFormState): RemoteProxySetting;
46
+ /**
47
+ * The `proxy` field for one save, or `undefined` when it must be left out.
48
+ *
49
+ * `undefined` is the BACKWARD-COMPATIBLE answer: an old Host ignores the field,
50
+ * and on create an absent value simply inherits the profile default. An UPDATE
51
+ * that switches back to `跟随默认` is the one case an explicit
52
+ * `{ mode: 'inherit' }` has to be sent, or the stored proxy would never clear.
53
+ */
54
+ export declare function proxySettingOf(state: ProxyFormState): RemoteHostProxySetting | undefined;
55
+ /**
56
+ * What stops a save: an unusable proxy endpoint, or no jump host picked.
57
+ *
58
+ * `jumpChoices` is the list of aliases the save can legally name (every stored
59
+ * host except the one being edited). A stored jump host that has since been
60
+ * deleted is NOT saveable — the Host refuses a `viaAlias` it does not know — so
61
+ * the form has to say that in the user's language instead of forwarding a raw
62
+ * `unknown host alias` rejection for a field nobody touched.
63
+ */
64
+ export declare function proxyFormProblem(state: ProxyFormState, jumpChoices?: string[]): 'target' | 'jump' | 'jumpGone' | undefined;
65
+ /**
66
+ * One line saying where traffic goes — the collapsed chip's text.
67
+ *
68
+ * `跟随默认` is resolved against the profile default when it is known: the whole
69
+ * point of showing the chip while collapsed is that "follow the default" alone
70
+ * does not tell the user whether that means direct or a proxy. An unknown
71
+ * default (a Host without the route, or a failed read) degrades to the bare
72
+ * phrase rather than guessing "direct".
73
+ */
74
+ export declare function proxySummary(t: TFn, state: ProxyFormState, fallback: RemoteProxySettingsView | undefined): string;
75
+ /** One rendered chip: its word, its hover text, and whether it is a problem. */
76
+ export interface ProxyChipModel {
77
+ mode: RemoteProxyMode;
78
+ label: string;
79
+ title: string;
80
+ problem: boolean;
81
+ }
82
+ /**
83
+ * The host ROW's chip: which way this host leaves the machine.
84
+ *
85
+ * Deliberately shorter than the form's summary (`代理`, not `经 HTTP 代理 h:p`) —
86
+ * a list row has one line of room and the full route is the `title`. A refused
87
+ * setting keeps its chip text and switches to the error colour, because the row
88
+ * still has to say what was configured; `problem` explains why it cannot work.
89
+ *
90
+ * `fallback` is the profile-wide default, so a `跟随默认` row resolves to what it
91
+ * actually does (the form's chip already does) — without it the row would say
92
+ * "follow default" while the same host's form says "follow default (via …)". An
93
+ * unknown default degrades to the bare phrase rather than guessing "direct".
94
+ */
95
+ export declare function proxyChipOf(t: TFn, view: RemoteHostProxyView, fallback?: RemoteProxySettingsView): ProxyChipModel;
96
+ /** Read-only route chip (secondary outline, never a status colour). */
97
+ export declare function ProxyChip(props: {
98
+ chip: ProxyChipModel;
99
+ }): ReactNode;
100
+ /**
101
+ * Collapsible section header: a real `<button>` with `aria-expanded`.
102
+ *
103
+ * A `<details>` element was refused on purpose: its summary marker cannot be
104
+ * restyled without vendor pseudo-elements and it gives no place for the chip.
105
+ * A native button keeps Enter/Space, focus and the announced state for free.
106
+ */
107
+ export declare function ProxySectionHeader(props: {
108
+ open: boolean;
109
+ label: string;
110
+ expandLabel: string;
111
+ collapseLabel: string;
112
+ chip: ProxyChipModel;
113
+ controls: string;
114
+ onToggle: () => void;
115
+ }): ReactNode;
116
+ /**
117
+ * The endpoint controls, shared by the per-host form and the profile default.
118
+ *
119
+ * Password semantics are identical in both places: `storedPassword` only
120
+ * switches the placeholder, and an empty box is omitted from the payload.
121
+ */
122
+ export declare function ProxyFields(props: {
123
+ t: TFn;
124
+ state: ProxyFormState;
125
+ onChange: (next: ProxyFormState) => void;
126
+ storedPassword: boolean;
127
+ disabled?: boolean;
128
+ }): ReactNode;
129
+ export declare function HostFormView(props: {
130
+ t: TFn;
131
+ initial?: RemoteHostSummary;
132
+ busy: boolean;
133
+ /** Every stored host: the jump-host list (minus the one being edited). */
134
+ hosts: RemoteHostSummary[];
135
+ /** The profile-wide default, so `跟随默认` can be spelled out while collapsed. */
136
+ proxyDefault?: RemoteProxySettingsView;
137
+ onSave: (form: HostForm) => void;
138
+ onCancel: () => void;
139
+ }): ReactNode;
6
140
  export declare function HostsView(props: {
7
- t: (k: string) => string;
141
+ t: TFn;
8
142
  hosts: RemoteHostSummary[];
143
+ /** Profile-wide egress default, so `跟随默认` chips can be resolved. */
144
+ proxyDefault?: RemoteProxySettingsView;
9
145
  onChanged: () => void;
10
146
  }): ReactNode;
147
+ export {};
@@ -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 RemoteHostSummary, type RemoteListenPortsResult, type RemoteProcessKillResult, type RemoteProcessesResult, type RemotePluginMeta, type RemoteProbe, 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
  /**
@@ -134,6 +134,14 @@ export interface HostForm {
134
134
  };
135
135
  description?: string;
136
136
  tags?: string[];
137
+ /**
138
+ * How this host reaches the network (see `RemoteHostProxySetting`).
139
+ *
140
+ * Absent means "no opinion": a create then keeps the profile default, and an
141
+ * update keeps whatever the host already had — which is what makes the field
142
+ * backward compatible with a Host that never heard of it.
143
+ */
144
+ proxy?: RemoteHostProxySetting;
137
145
  }
138
146
  export interface PushReportView {
139
147
  alias: string;
@@ -153,6 +161,18 @@ export declare function remoteWriteSequence(): number;
153
161
  * stash invalidate the quick-open index at all.
154
162
  */
155
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';
156
176
  export declare const api: {
157
177
  getHosts: () => Promise<RemoteHostSummary[]>;
158
178
  createHost: (payload: HostForm) => Promise<RemoteHostSummary>;
@@ -203,8 +223,15 @@ export declare const api: {
203
223
  * One remote command (`/exec`), foreground unless `opts.background` asks for
204
224
  * the git channel. Reads the SCM panel builds stay foreground; the
205
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.
206
233
  */
207
- 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>;
208
235
  /**
209
236
  * Streaming exec: the network verbs' live log.
210
237
  *
@@ -212,10 +239,20 @@ export declare const api: {
212
239
  * command runs, and the promise settles on the `exit` frame. An aborted
213
240
  * `signal` cancels the remote process group on the host side (the route acts
214
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.
215
249
  */
216
250
  execStream: (alias: string, command: string, timeoutMs: number, handlers: {
217
251
  onData?: (stream: "out" | "err", text: string) => void;
218
252
  signal?: AbortSignal;
253
+ lane?: ExecLane;
254
+ /** @deprecated use `lane: 'network'` */
255
+ network?: boolean;
219
256
  }) => Promise<RemoteExecResult>;
220
257
  getWorkspaces: () => Promise<{
221
258
  workspaces: RemoteWorkspaceBinding[];
@@ -272,6 +309,22 @@ export declare const api: {
272
309
  getViewSettings: () => Promise<RemoteViewSettings>;
273
310
  /** Flat patch: unknown keys are ignored, unusable values keep the stored one. */
274
311
  setViewSettings: (patch: Partial<RemoteViewSettings>) => Promise<RemoteViewSettings>;
312
+ /**
313
+ * The default egress every `mode: 'inherit'` host follows.
314
+ *
315
+ * Answers the DEFAULTS on a fresh profile (`direct`), and a Host too old to
316
+ * know the route answers 404 — callers treat that as "direct" and keep the
317
+ * per-host form working (see `proxySummary`).
318
+ */
319
+ getProxySettings: () => Promise<RemoteProxySettingsView>;
320
+ /**
321
+ * Patch the default egress.
322
+ *
323
+ * `target: null` clears the stored endpoint; omitting it keeps the stored one
324
+ * (so flipping to `direct` and back does not lose the address), and an empty
325
+ * password keeps the stored secret — the browser never sees it.
326
+ */
327
+ patchProxySettings: (patch: RemoteProxySettingsPatch) => Promise<RemoteProxySettingsView>;
275
328
  deployStatus: (alias: string) => Promise<{
276
329
  deploy: RemoteDeployState;
277
330
  helpers: HelperAvailability[];
@@ -323,6 +376,16 @@ export declare const api: {
323
376
  * between the panel's host list and this call is a normal 404.
324
377
  */
325
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>;
326
389
  git: {
327
390
  status(alias: string, path: string): Promise<GitStatus>;
328
391
  log(alias: string, path: string, max: number, branch?: string): Promise<GitCommit[]>;
@@ -1,4 +1,4 @@
1
- import type { RemoteConnectionStatus } from '../protocol.ts';
1
+ import type { EgressInfo, RemoteConnectionStatus } from '../protocol.ts';
2
2
  export type ConnectionState = 'ok' | 'error' | 'idle';
3
3
  /** Automatic-retry cadence for an errored link (one dial per tick). */
4
4
  export declare const AUTO_RETRY_MS = 30000;
@@ -29,6 +29,26 @@ export declare function consumeAutoRetry(state: ConnectionState, attempts: numbe
29
29
  * broken link.
30
30
  */
31
31
  export declare function connectionLabelKey(state: ConnectionState): string;
32
+ /**
33
+ * One route, as the localized sentence fragment the chip prints.
34
+ *
35
+ * Pure and exported so the jsdom gate can pin the copy without a browser and the
36
+ * three route kinds cannot drift into three different wordings. The Host sends
37
+ * the hop (`host:port` / the jump alias), never a sentence: the wording is UI
38
+ * copy and has to exist in both languages.
39
+ */
40
+ export declare function describeEgress(egress: EgressInfo, t: (key: string) => string): string;
41
+ /**
42
+ * The tooltip line that answers "did this really go through the jump host?".
43
+ *
44
+ * The ACTUAL egress of the live connection wins. With nothing dialed the
45
+ * CONFIGURED route is shown and LABELLED as such, so a configuration can never
46
+ * be read as evidence about a connection — that distinction is the whole point
47
+ * (a host edited to use a jump host keeps serving on its old direct link until
48
+ * the old connection is dropped). A configured route that cannot be used says
49
+ * why instead of reading healthy.
50
+ */
51
+ export declare function egressTitleLine(connection: Pick<ConnectionView, 'egress' | 'configured'>, t: (key: string) => string): string | undefined;
32
52
  /** What the UI renders for one alias. */
33
53
  export interface ConnectionView {
34
54
  alias: string;
@@ -41,6 +61,13 @@ export interface ConnectionView {
41
61
  okAt?: number;
42
62
  /** A pooled SSH connection is open right now (diagnostic detail only). */
43
63
  open: boolean;
64
+ /**
65
+ * The route the LIVE connection was opened through. Evidence, not intention:
66
+ * it is what the Host's pool reports for the connection it is holding.
67
+ */
68
+ egress?: EgressInfo;
69
+ /** The route the stored configuration resolves to (no live connection). */
70
+ configured?: EgressInfo;
44
71
  /**
45
72
  * Client time of the last locally noted failure. A poll that still reports
46
73
  * the older success must not clear an error the page just saw.
@@ -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:
@@ -11,7 +11,17 @@ export declare const FORWARD_MAX_CONNECTIONS = 32;
11
11
  * the manager never reaches into the pool beyond one call.
12
12
  */
13
13
  export interface ForwardPoolLike {
14
- forwardOut(alias: string, dstHost: string, dstPort: number, srcPort?: number): Promise<ClientChannel>;
14
+ /**
15
+ * Open one direct-tcpip channel. `opts.dedicated` asks for the host's dedicated
16
+ * forward connection; the answer carries which connection was actually used, so
17
+ * the rule can SAY "shared" after a fallback instead of pretending.
18
+ */
19
+ forwardOut(alias: string, dstHost: string, dstPort: number, srcPort?: number, opts?: {
20
+ dedicated?: boolean;
21
+ }): Promise<{
22
+ channel: ClientChannel;
23
+ dedicated: boolean;
24
+ }>;
15
25
  }
16
26
  export interface ForwardManagerDeps {
17
27
  pool: ForwardPoolLike;