dsh-remote-vs 0.28.0 → 0.29.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,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 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;
@@ -272,6 +280,22 @@ export declare const api: {
272
280
  getViewSettings: () => Promise<RemoteViewSettings>;
273
281
  /** Flat patch: unknown keys are ignored, unusable values keep the stored one. */
274
282
  setViewSettings: (patch: Partial<RemoteViewSettings>) => Promise<RemoteViewSettings>;
283
+ /**
284
+ * The default egress every `mode: 'inherit'` host follows.
285
+ *
286
+ * Answers the DEFAULTS on a fresh profile (`direct`), and a Host too old to
287
+ * know the route answers 404 — callers treat that as "direct" and keep the
288
+ * per-host form working (see `proxySummary`).
289
+ */
290
+ getProxySettings: () => Promise<RemoteProxySettingsView>;
291
+ /**
292
+ * Patch the default egress.
293
+ *
294
+ * `target: null` clears the stored endpoint; omitting it keeps the stored one
295
+ * (so flipping to `direct` and back does not lose the address), and an empty
296
+ * password keeps the stored secret — the browser never sees it.
297
+ */
298
+ patchProxySettings: (patch: RemoteProxySettingsPatch) => Promise<RemoteProxySettingsView>;
275
299
  deployStatus: (alias: string) => Promise<{
276
300
  deploy: RemoteDeployState;
277
301
  helpers: HelperAvailability[];
@@ -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.
@@ -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;
@@ -63,6 +63,29 @@ export declare class RemotePool {
63
63
  * that refuses extra connections still gets a working terminal.
64
64
  */
65
65
  private readonly shellConns;
66
+ /**
67
+ * Dedicated connections for `ssh -L` port forwards (one per alias).
68
+ *
69
+ * The other half of the same argument: a forwarded channel carries arbitrary
70
+ * TCP (a database, an SSH tunnel, a whole browser page), so it is long-lived
71
+ * and can move a lot of data. Multiplexed onto the shared connection it would
72
+ * queue ahead of exec/SFTP channels (SSH has no per-channel priority), and a
73
+ * remote service that stalls would hold the window `git status` needs. A
74
+ * terminal already gets its own connection (`shellConns`); forward traffic gets
75
+ * its own for exactly the same reason.
76
+ *
77
+ * Cost: one extra handshake per alias that actually receives a forwarded
78
+ * connection, plus one held TCP connection while any of its forward channels is
79
+ * open (the 30-minute idle eviction applies once the last one closes).
80
+ * `forwardOut` falls back to the shared connection when this one cannot be
81
+ * established (e.g. the server refuses extra connections), so a forward never
82
+ * stops working because of it — it only loses the isolation.
83
+ */
84
+ private readonly forwardConns;
85
+ /** Aliases whose dedicated-forward downgrade was already logged (once per alias). */
86
+ private readonly forwardFallbackNoted;
87
+ /** alias -> timestamp until which the dedicated forward connection is skipped. */
88
+ private readonly forwardBlocked;
66
89
  /** TOFU fingerprints observed this process (alias -> sha256). */
67
90
  private readonly hostKeys;
68
91
  /** Per-alias `setsid --wait` capability, probed once (see supportsSetsid). */
@@ -94,6 +117,22 @@ export declare class RemotePool {
94
117
  * indicator's poll never creates a connection as a side effect.
95
118
  */
96
119
  status(): RemoteConnectionStatus[];
120
+ /**
121
+ * The egress of the alias' LIVE connection, whichever class owns it.
122
+ *
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.
126
+ */
127
+ private liveEgress;
128
+ /**
129
+ * The route the stored configuration resolves to, for an alias with NO live
130
+ * connection. Pure observation, and absorbed: a dangling jump chain or a
131
+ * half-configured proxy makes `resolveProxy` throw, and a status poll must
132
+ * answer "the stored route is broken, here is why" instead of failing — the
133
+ * chip still has to render, and a 500 would hide the reason it exists to show.
134
+ */
135
+ private configuredEgress;
97
136
  /** Record a successful dial or transport-level operation. */
98
137
  private markOk;
99
138
  /** Record a connection-level failure the status chip should show. */
@@ -164,7 +203,22 @@ export declare class RemotePool {
164
203
  * debug their network. Real transport failures still arrive through the
165
204
  * pooled connection's own close/error events.
166
205
  */
167
- forwardOut(alias: string, dstHost: string, dstPort: number, srcPort?: number): Promise<ClientChannel>;
206
+ forwardOut(alias: string, dstHost: string, dstPort: number, srcPort?: number, opts?: {
207
+ dedicated?: boolean;
208
+ }): Promise<{
209
+ channel: ClientChannel;
210
+ dedicated: boolean;
211
+ }>;
212
+ /**
213
+ * Is this alias's dedicated forward connection in its short cooldown?
214
+ *
215
+ * Expired entries are dropped eagerly so the map cannot grow per alias forever.
216
+ */
217
+ private forwardCoolingDown;
218
+ /** Park the dedicated connection for one alias and log the downgrade, once. */
219
+ private blockForward;
220
+ /** Log one alias's forward downgrade to the shared connection, once. */
221
+ private noteForwardFallback;
168
222
  /** Run one callback with a fresh SFTP session (closed afterwards). */
169
223
  withSftp<T>(alias: string, fn: (sftp: SFTPWrapper) => Promise<T>, opts?: SftpOptions): Promise<T>;
170
224
  /**
@@ -309,6 +363,23 @@ export declare class RemotePool {
309
363
  private acquire;
310
364
  /** `acquire` for the dedicated PTY connection map. */
311
365
  private acquireShell;
366
+ /**
367
+ * `acquire` for the dedicated port-forward connection map.
368
+ *
369
+ * `quiet`: a dedicated forward connection is an OPTIMIZATION. If the server
370
+ * refuses it (MaxStartups, `MaxSessions`, a per-source limit) the forward still
371
+ * works over the shared connection, so the shared link is healthy — painting
372
+ * the connection chip red here would send the user to debug a network that is
373
+ * fine (and `forwardOut` reports the rule's own error separately).
374
+ *
375
+ * The dial also gets its OWN short budget ({@link FORWARD_DEDICATED_BUDGET_MS}):
376
+ * a server that silently drops the extra connection would otherwise make every
377
+ * forward channel wait the full connect watchdog before falling back. The
378
+ * abandoned dial keeps running — if it eventually succeeds the connection is
379
+ * pooled and the next channel uses it; its failure is already handled inside
380
+ * `acquireIn`.
381
+ */
382
+ private acquireForward;
312
383
  private acquireIn;
313
384
  /** Evict ONE alias from ONE map (host removal drops both maps explicitly). */
314
385
  private evictFrom;
@@ -321,5 +392,28 @@ export declare class RemotePool {
321
392
  * overrides it.
322
393
  */
323
394
  private makeClient;
395
+ /**
396
+ * Open one SSH connection, through whatever route the store resolves.
397
+ *
398
+ * Three routes, and only the first is the pre-proxy code path:
399
+ * - `direct`: unchanged (`host` / `port` in the connect config);
400
+ * - `proxy`: the proxy module builds the tunnel and ssh2 rides the returned
401
+ * socket (`sock`), so `host`/`port` are deliberately omitted (ssh2 ignores
402
+ * them when `sock` is present);
403
+ * - `jump`: the tunnel is a `direct-tcpip` channel on the JUMP host's pooled
404
+ * connection, held for as long as the client lives. Its close/error handlers
405
+ * close that channel and give the hold back — a leak here would pin the jump
406
+ * host's connection forever.
407
+ *
408
+ * Every failure is a DIAL failure, so it keeps the existing `markError`
409
+ * semantics; only the message is layered, so the user can tell which hop broke:
410
+ * `proxy auth failed: …`, `proxy refused: …`, `jump host "x" failed: …`.
411
+ *
412
+ * `report` receives the route this dial ACTUALLY settled on, once and only on
413
+ * success — a caller that asked "did this go through the jump host?" must not
414
+ * be answered from a configuration that may have changed since. It is a
415
+ * callback rather than a wider return type so the seam keeps returning the
416
+ * `Client` the existing callers (and gates) hand around.
417
+ */
324
418
  private dial;
325
419
  }
@@ -31,6 +31,8 @@ export declare const REMOTE_API: {
31
31
  readonly routing: "/api/dsh-remote/routing";
32
32
  /** Client view preferences (auto-open the remote page + its width share). */
33
33
  readonly viewSettings: "/api/dsh-remote/view-settings";
34
+ /** Profile-wide proxy default (per-host overrides live on the host rows). */
35
+ readonly proxySettings: "/api/dsh-remote/proxy-settings";
34
36
  /** Current working directory of one live session (click resolution helper). */
35
37
  readonly sessionCwd: "/api/dsh-remote/session-cwd";
36
38
  /** What one live session changed on its remote host (the review panel). */
@@ -54,6 +56,70 @@ export declare const MAX_SELECTION_DOWNLOAD = 100;
54
56
  export declare function selectionDownloadName(count: number): string;
55
57
  /** Authentication flavors a host entry may carry (P0: direct only, no jump/agent). */
56
58
  export type RemoteAuthKind = 'key' | 'password';
59
+ /**
60
+ * How one host reaches the network.
61
+ *
62
+ * Two levels exist on purpose: a profile-wide default (`RemoteProxySettingsView`)
63
+ * and a per-host override. `inherit` is the default state of every existing
64
+ * host, and the default default is `direct`, so an upgrade changes nothing.
65
+ */
66
+ export type RemoteProxyMode = 'inherit' | 'direct' | 'proxy' | 'jump';
67
+ /** One stored proxy endpoint (secrets included: host-side only). */
68
+ export interface RemoteProxySetting {
69
+ kind: 'http' | 'socks5';
70
+ /** Proxy hostname or IP. */
71
+ host: string;
72
+ /** Proxy port. */
73
+ port: number;
74
+ /** Basic auth (http) / user+password (socks5). */
75
+ username?: string;
76
+ password?: string;
77
+ }
78
+ /** A host's proxy decision, as stored. */
79
+ export interface RemoteHostProxySetting {
80
+ mode: RemoteProxyMode;
81
+ /** The endpoint for `mode: 'proxy'`. */
82
+ proxy?: RemoteProxySetting;
83
+ /** The jump host for `mode: 'jump'` — an alias of another stored host. */
84
+ jump?: {
85
+ viaAlias: string;
86
+ };
87
+ }
88
+ /** Secret-free proxy endpoint for the browser. */
89
+ export interface RemoteProxyTargetView {
90
+ kind: 'http' | 'socks5';
91
+ host: string;
92
+ port: number;
93
+ username?: string;
94
+ /** True when a password is stored (never echoed back). */
95
+ hasPassword: boolean;
96
+ }
97
+ /** Secret-free proxy decision of one host. */
98
+ export interface RemoteHostProxyView {
99
+ mode: RemoteProxyMode;
100
+ target?: RemoteProxyTargetView;
101
+ /** Alias of the jump host, for `mode: 'jump'`. */
102
+ jumpVia?: string;
103
+ /**
104
+ * Why this setting cannot be used, when it cannot.
105
+ *
106
+ * A jump host that names itself, a chain longer than one hop, or a jump host
107
+ * that is itself reached through a jump is refused at dial time; saying so in
108
+ * the host's own row beats a generic "connection failed".
109
+ */
110
+ problem?: string;
111
+ }
112
+ /** Profile-wide proxy default (the "upper" of the two levels). */
113
+ export interface RemoteProxySettingsView {
114
+ defaultMode: 'direct' | 'proxy';
115
+ target?: RemoteProxyTargetView;
116
+ }
117
+ /** Patch shape for the profile-wide proxy default. */
118
+ export interface RemoteProxySettingsPatch {
119
+ defaultMode?: 'direct' | 'proxy';
120
+ /** `null` clears the stored endpoint; omitted keeps it. */
121
+ target?: RemoteProxySetting | null;
122
+ }
57
123
  /** One stored host entry (the $DSH_HOME/dsh-remote.json store shape). */
58
124
  export interface RemoteHostEntry {
59
125
  /** Stable, user-chosen identifier used by every operation. */
@@ -78,6 +144,8 @@ export interface RemoteHostEntry {
78
144
  description?: string;
79
145
  /** Free-form tags. */
80
146
  tags: string[];
147
+ /** How this host is reached (absent = `inherit`). */
148
+ proxy?: RemoteHostProxySetting;
81
149
  /** Last deploy pipeline outcome for this host. */
82
150
  deploy?: RemoteDeployState | undefined;
83
151
  createdAt: number;
@@ -96,6 +164,8 @@ export interface RemoteHostSummary {
96
164
  managedKey: boolean;
97
165
  description?: string;
98
166
  tags: string[];
167
+ /** Secret-free proxy decision; always present (mode `inherit` when unset). */
168
+ proxy: RemoteHostProxyView;
99
169
  deploy?: RemoteDeployState | undefined;
100
170
  createdAt: number;
101
171
  updatedAt: number;
@@ -172,6 +242,36 @@ export interface RemoteTimeouts {
172
242
  /** One SFTP file read (editor, diff sides, document preview). */
173
243
  readMs: number;
174
244
  }
245
+ /**
246
+ * Where one SSH connection ACTUALLY left this machine.
247
+ *
248
+ * The user's question ("did this really go through the jump host?") cannot be
249
+ * answered by the stored configuration: a host can be configured for a jump host
250
+ * while a connection established BEFORE that edit is still serving. So the pool
251
+ * reports the route of the connection it is holding, and the browser shows it on
252
+ * the connection chip.
253
+ *
254
+ * `detail` is the hop itself (the target `host:port`, the proxy `host:port`, or
255
+ * the jump host alias) and NOT a formatted sentence: the wording is UI copy and
256
+ * therefore belongs to the localized client.
257
+ */
258
+ export interface EgressInfo {
259
+ kind: 'direct' | 'proxy' | 'jump';
260
+ /** The hop: the target endpoint, the proxy endpoint, or the jump host alias. */
261
+ detail: string;
262
+ /** Jump route only: the alias of the host whose connection carries the tunnel. */
263
+ viaAlias?: string;
264
+ /** Proxy route only: whether this host or the profile default chose the proxy. */
265
+ source?: 'host' | 'default';
266
+ /** Proxy route only: the protocol, so the UI can name it (HTTP / SOCKS5). */
267
+ proxyKind?: 'http' | 'socks5';
268
+ /**
269
+ * Set only on a CONFIGURED route whose resolution failed (a jump host that is
270
+ * gone, a self-jump, a half-configured proxy): the reason, so the chip can say
271
+ * why the route cannot work instead of silently reading as healthy.
272
+ */
273
+ problem?: string;
274
+ }
175
275
  /**
176
276
  * Connection health for one host alias, as the Host's pool sees it.
177
277
  *
@@ -192,6 +292,18 @@ export interface RemoteConnectionStatus {
192
292
  errorAt?: number;
193
293
  /** Human-readable failure the client can show in the status chip. */
194
294
  error?: string;
295
+ /**
296
+ * The route the connection this pool HOLDS was actually opened through.
297
+ * Present only while such a connection exists: it is evidence about a live
298
+ * link, not about the current configuration.
299
+ */
300
+ egress?: EgressInfo;
301
+ /**
302
+ * The route the stored configuration resolves to, for an alias with no live
303
+ * connection (what the NEXT connection would use, and the honest answer while
304
+ * nothing is dialed). Carries `problem` when the configuration is unusable.
305
+ */
306
+ configured?: EgressInfo;
195
307
  }
196
308
  /** Remote OS probe outcome. */
197
309
  export interface RemoteProbe {
@@ -771,6 +883,16 @@ export interface RemoteForwardState {
771
883
  bytesOut: number;
772
884
  /** Last connect/bind failure, human-readable. */
773
885
  lastError?: string;
886
+ /**
887
+ * Which SSH connection the last successful channel used.
888
+ *
889
+ * `dedicated` = the host's own port-forward connection (the normal case);
890
+ * `shared` = the server refused the extra connection, so the channel rode the
891
+ * shared one (the forward still works, only the isolation is lost). Absent
892
+ * until a connection has succeeded at least once — older hosts omit it too, so
893
+ * a client must treat it as optional.
894
+ */
895
+ transport?: 'dedicated' | 'shared';
774
896
  startedAt: number;
775
897
  }
776
898
  /** One listening TCP socket on the remote host. */