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.
- package/README.en.md +50 -5
- package/README.md +42 -5
- package/lib/client.js +217 -112
- package/lib/index.js +1468 -51
- package/lib/types/client/HostsView.d.ts +139 -2
- package/lib/types/client/api.d.ts +25 -1
- package/lib/types/client/connection.d.ts +28 -1
- package/lib/types/forward.d.ts +11 -1
- package/lib/types/pool.d.ts +95 -1
- package/lib/types/protocol.d.ts +122 -0
- package/lib/types/proxy.d.ts +136 -0
- package/lib/types/store.d.ts +81 -1
- package/lib/types/tools.d.ts +3 -0
- package/package.json +1 -1
- package/src/client/ConnectionStatus.tsx +19 -5
- package/src/client/HostsView.tsx +552 -11
- package/src/client/PortsView.tsx +16 -0
- package/src/client/SettingsHosts.tsx +132 -6
- package/src/client/api.ts +30 -0
- package/src/client/connection.ts +76 -2
- package/src/client/i18n.ts +102 -0
- package/src/client/vsc/vsc.css +105 -0
- package/src/forward.ts +38 -2
- package/src/importers.ts +125 -13
- package/src/keygen.ts +8 -1
- package/src/pool.ts +422 -27
- package/src/protocol.ts +128 -0
- package/src/proxy.ts +673 -0
- package/src/routes.ts +73 -5
- package/src/store.ts +335 -0
- package/src/tools.ts +47 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound proxy support for SSH dials.
|
|
3
|
+
*
|
|
4
|
+
* Why this is not just `HTTP_PROXY`: ssh2 dials a raw TCP socket, and the
|
|
5
|
+
* harness's proxy plumbing (`@deepseek-ai/dsh-http-proxy`) only wraps `fetch`,
|
|
6
|
+
* so a host that can only be reached through a proxy needs the tunnel built
|
|
7
|
+
* here. Three flavours, in the order a user meets them:
|
|
8
|
+
*
|
|
9
|
+
* - `http` — `CONNECT host:port`, optional `Proxy-Authorization: Basic …`;
|
|
10
|
+
* - `socks5` — greeting / optional user+password sub-negotiation / CONNECT;
|
|
11
|
+
* - jump (`ProxyJump` / `ProxyCommand ssh -W`) — NOT dialled here: the pool
|
|
12
|
+
* opens a `direct-tcpip` channel on ANOTHER pooled connection and hands it
|
|
13
|
+
* to ssh2 as its socket. This module only parses those specs into a target.
|
|
14
|
+
*
|
|
15
|
+
* **Error taxonomy is the point.** "The proxy refused the tunnel" and "the
|
|
16
|
+
* target closed the port" and "your password is wrong" all fail the dial, and
|
|
17
|
+
* the user debugs the wrong thing if they all read "connection failed". Each
|
|
18
|
+
* failure therefore leaves as a `ProxyError` with a stable `reason` and one
|
|
19
|
+
* actionable sentence.
|
|
20
|
+
*
|
|
21
|
+
* **Bytes are never lost.** A proxy may send tunnel bytes in the same packet as
|
|
22
|
+
* its handshake reply; everything read past the handshake is pushed back onto
|
|
23
|
+
* the socket before it is handed to ssh2, or the SSH banner would be swallowed
|
|
24
|
+
* and the handshake would stall.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
import { type Socket } from 'node:net';
|
|
29
|
+
/** Proxy flavours this plugin dials itself. A jump host is not one of them. */
|
|
30
|
+
export type ProxyKind = 'http' | 'socks5';
|
|
31
|
+
/** One validated proxy endpoint (secrets included: host-side only). */
|
|
32
|
+
export interface ProxyConfig {
|
|
33
|
+
kind: ProxyKind;
|
|
34
|
+
/** Proxy hostname / IPv4 / IPv6 literal. */
|
|
35
|
+
host: string;
|
|
36
|
+
port: number;
|
|
37
|
+
/** Basic auth (http) or user/password sub-negotiation (socks5). */
|
|
38
|
+
username?: string;
|
|
39
|
+
password?: string;
|
|
40
|
+
}
|
|
41
|
+
/** A `ProxyJump` / `ProxyCommand ssh -W` hop, parsed but not yet resolved. */
|
|
42
|
+
export interface JumpTarget {
|
|
43
|
+
/** Login user named in the spec, when it had one. */
|
|
44
|
+
user?: string;
|
|
45
|
+
host: string;
|
|
46
|
+
port: number;
|
|
47
|
+
}
|
|
48
|
+
/** Every way a proxy dial can fail, as a stable value (not a message). */
|
|
49
|
+
export type ProxyFailure =
|
|
50
|
+
/** The proxy itself could not be reached (TCP refused/unreachable). */
|
|
51
|
+
'unreachable'
|
|
52
|
+
/** The proxy accepted TCP but never finished talking to us. */
|
|
53
|
+
| 'timeout'
|
|
54
|
+
/** The proxy demanded credentials we do not have, or rejected ours. */
|
|
55
|
+
| 'auth'
|
|
56
|
+
/** The proxy answered, and refused the tunnel (bad status / SOCKS reply). */
|
|
57
|
+
| 'refused'
|
|
58
|
+
/** The proxy answered with something that is not the protocol we speak. */
|
|
59
|
+
| 'protocol'
|
|
60
|
+
/** The destination is not a legal target (bad port, empty host). */
|
|
61
|
+
| 'target';
|
|
62
|
+
/** A proxy dial failure that knows which layer broke. */
|
|
63
|
+
export declare class ProxyError extends Error {
|
|
64
|
+
readonly reason: ProxyFailure;
|
|
65
|
+
/** Which proxy kind was attempted (absent for target validation). */
|
|
66
|
+
readonly kind?: ProxyKind | undefined;
|
|
67
|
+
constructor(reason: ProxyFailure, message: string,
|
|
68
|
+
/** Which proxy kind was attempted (absent for target validation). */
|
|
69
|
+
kind?: ProxyKind | undefined);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate one proxy endpoint.
|
|
73
|
+
*
|
|
74
|
+
* @param input - value as it arrived from the browser / store file.
|
|
75
|
+
* @returns the normalized config (empty credentials dropped).
|
|
76
|
+
* @throws {ProxyError} `target` when a field is unusable, with the field named.
|
|
77
|
+
*/
|
|
78
|
+
export declare function normalizeProxy(input: unknown): ProxyConfig;
|
|
79
|
+
/** True when a value looks like a proxy config at all (shape, not validity). */
|
|
80
|
+
export declare function looksLikeProxy(value: unknown): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Parse an OpenSSH `ProxyJump` value (`jump`, `user@jump:2222`, `a,b`).
|
|
83
|
+
*
|
|
84
|
+
* Only a single hop is supported: the pool builds the tunnel on one existing
|
|
85
|
+
* pooled connection, and a chain would need nested channels whose failure modes
|
|
86
|
+
* we cannot explain to the user yet. Multi-hop is therefore a named refusal
|
|
87
|
+
* rather than a silent half-feature.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseProxyJump(value: string): {
|
|
90
|
+
ok: true;
|
|
91
|
+
target: JumpTarget;
|
|
92
|
+
} | {
|
|
93
|
+
ok: false;
|
|
94
|
+
reason: string;
|
|
95
|
+
};
|
|
96
|
+
/** What a `ProxyCommand` line means to this plugin. */
|
|
97
|
+
export type ProxyCommandPlan = {
|
|
98
|
+
kind: 'proxy';
|
|
99
|
+
proxy: Omit<ProxyConfig, 'username' | 'password'>;
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'jump';
|
|
102
|
+
target: JumpTarget;
|
|
103
|
+
} | {
|
|
104
|
+
kind: 'unsupported';
|
|
105
|
+
reason: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Map the ProxyCommand forms users actually write onto a tunnel we can build.
|
|
109
|
+
*
|
|
110
|
+
* Recognised: `ssh … -W %h:%p [user@]host`, `nc -X connect -x host:port %h %p`
|
|
111
|
+
* (http), `nc -x host:port %h %p` (socks5), `ncat --proxy … --proxy-type …`.
|
|
112
|
+
* Everything else is refused by name — a ProxyCommand is a shell command, and
|
|
113
|
+
* running one from a browser-supplied config is not a feature this plugin
|
|
114
|
+
* offers.
|
|
115
|
+
*/
|
|
116
|
+
export declare function parseProxyCommand(command: string): ProxyCommandPlan;
|
|
117
|
+
/** How this module reaches a TCP socket (a seam for the gates). */
|
|
118
|
+
export type SocketFactory = (host: string, port: number) => Socket;
|
|
119
|
+
/** One tunnel request. */
|
|
120
|
+
export interface OpenProxyOptions {
|
|
121
|
+
/** Total budget for connect + handshake (default 8000 ms). */
|
|
122
|
+
timeoutMs?: number;
|
|
123
|
+
/** Test seam: replaces `net.createConnection`. */
|
|
124
|
+
connect?: SocketFactory;
|
|
125
|
+
}
|
|
126
|
+
/** Default budget: a proxy that cannot answer in this long is not worth waiting for. */
|
|
127
|
+
export declare const PROXY_TIMEOUT_MS = 8000;
|
|
128
|
+
/**
|
|
129
|
+
* Dial `host:port` through `proxy` and hand back the tunnelled socket.
|
|
130
|
+
*
|
|
131
|
+
* The caller owns the socket (ssh2 takes it as its transport). Everything read
|
|
132
|
+
* past the handshake is pushed back, so the SSH banner is not swallowed.
|
|
133
|
+
*
|
|
134
|
+
* @throws {ProxyError} when the proxy layer — not SSH — is what failed.
|
|
135
|
+
*/
|
|
136
|
+
export declare function openProxySocket(proxy: ProxyConfig, host: string, port: number, options?: OpenProxyOptions): Promise<Socket>;
|
package/lib/types/store.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ProxyConfig } from './proxy.ts';
|
|
2
|
+
import type { RemoteDeployState, RemoteHostEntry, RemoteHostProxySetting, RemoteProxySettingsPatch, RemoteProxySettingsView, RemoteHostSummary, RemoteWorkspaceBinding } from './protocol.ts';
|
|
2
3
|
/** Payload accepted by create/update (secrets included, host-side only). */
|
|
3
4
|
export interface HostPayload {
|
|
4
5
|
alias: string;
|
|
@@ -11,6 +12,8 @@ export interface HostPayload {
|
|
|
11
12
|
passphrase?: string;
|
|
12
13
|
password?: string;
|
|
13
14
|
};
|
|
15
|
+
/** How this host reaches the network; omitted = `inherit` (back-compat). */
|
|
16
|
+
proxy?: RemoteHostProxySetting;
|
|
14
17
|
description?: string;
|
|
15
18
|
tags?: string[];
|
|
16
19
|
}
|
|
@@ -19,6 +22,22 @@ export interface WorkspacePayload {
|
|
|
19
22
|
alias: string;
|
|
20
23
|
remotePath: string;
|
|
21
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The effective network route one dial must take (see `resolveProxy`).
|
|
27
|
+
*
|
|
28
|
+
* `source` is kept because "the profile default sent me through a proxy" and "this
|
|
29
|
+
* host says so" are different answers to the same question in `remote_hosts`.
|
|
30
|
+
*/
|
|
31
|
+
export type ResolvedProxy = {
|
|
32
|
+
kind: 'direct';
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'proxy';
|
|
35
|
+
proxy: ProxyConfig;
|
|
36
|
+
source: 'host' | 'default';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'jump';
|
|
39
|
+
viaAlias: string;
|
|
40
|
+
};
|
|
22
41
|
export declare class RemoteStore {
|
|
23
42
|
private readonly file;
|
|
24
43
|
private doc;
|
|
@@ -87,8 +106,69 @@ export declare class RemoteStore {
|
|
|
87
106
|
*/
|
|
88
107
|
remove(alias: string): boolean;
|
|
89
108
|
private normalize;
|
|
109
|
+
/**
|
|
110
|
+
* Validate one host's stored proxy decision.
|
|
111
|
+
*
|
|
112
|
+
* The rules are the ones the two-level model needs to stay explainable:
|
|
113
|
+
* - the mode is one of the four declared values;
|
|
114
|
+
* - `proxy` needs an endpoint, `jump` needs another EXISTING alias (a host
|
|
115
|
+
* cannot jump through itself, and a chain is impossible to resolve with one
|
|
116
|
+
* pooled hop);
|
|
117
|
+
* - fields that the chosen mode does not use are DROPPED rather than stored, so
|
|
118
|
+
* switching modes cannot leave a stale endpoint behind that a later reader
|
|
119
|
+
* would take for the active one.
|
|
120
|
+
*
|
|
121
|
+
* @returns the normalized setting, or undefined for `inherit` (stored as the
|
|
122
|
+
* field's absence, which is what older files have).
|
|
123
|
+
*/
|
|
124
|
+
private validateHostProxy;
|
|
125
|
+
/**
|
|
126
|
+
* Why a host's proxy decision cannot be used, when it cannot.
|
|
127
|
+
*
|
|
128
|
+
* Reads NEVER throw for this: a host that points at a deleted jump host must
|
|
129
|
+
* still be listed (with the reason on its row) instead of making the whole host
|
|
130
|
+
* list fail. The dial path asks {@link resolveProxy}, which does fail closed.
|
|
131
|
+
*/
|
|
132
|
+
private proxyProblem;
|
|
133
|
+
/** Secret-free view of one stored proxy endpoint. */
|
|
134
|
+
private targetView;
|
|
135
|
+
/** Secret-free view of one host's proxy decision (always present). */
|
|
136
|
+
private proxyView;
|
|
90
137
|
/** Secret-free projection for browser/agent surfaces. */
|
|
91
138
|
summarize(entry: RemoteHostEntry): RemoteHostSummary;
|
|
139
|
+
/** Secret-free view of the profile-wide proxy default (read-only). */
|
|
140
|
+
getDefaultProxy(): RemoteProxySettingsView;
|
|
141
|
+
/** View of the in-memory document (no reload: callers already reloaded). */
|
|
142
|
+
private defaultProxyView;
|
|
143
|
+
/**
|
|
144
|
+
* Patch the profile-wide proxy default.
|
|
145
|
+
*
|
|
146
|
+
* `target` semantics follow the host form: omitted keeps the stored endpoint,
|
|
147
|
+
* `null` clears it, an object replaces it — and an EMPTY PASSWORD keeps the
|
|
148
|
+
* stored one, because the browser never receives secrets back.
|
|
149
|
+
*/
|
|
150
|
+
patchDefaultProxy(patch: RemoteProxySettingsPatch): RemoteProxySettingsView;
|
|
151
|
+
/**
|
|
152
|
+
* Normalize a patched endpoint, keeping the stored password on an empty one.
|
|
153
|
+
*
|
|
154
|
+
* "Empty means keep" is only sound for the SAME endpoint: the browser never
|
|
155
|
+
* receives the secret back, so every PATCH of a proxied host arrives without
|
|
156
|
+
* one — but when kind/host/port/username changed, the stored password is a
|
|
157
|
+
* credential for a DIFFERENT server, and carrying it over would send the old
|
|
158
|
+
* secret to a new address (a 407 at best, a leaked credential at worst). A
|
|
159
|
+
* changed endpoint therefore drops it and the user re-enters it.
|
|
160
|
+
*/
|
|
161
|
+
private mergeProxyTarget;
|
|
162
|
+
/**
|
|
163
|
+
* Resolve one host's EFFECTIVE route, in the precedence the UI describes:
|
|
164
|
+
* the host's own decision, else the profile default, else direct.
|
|
165
|
+
*
|
|
166
|
+
* Unlike {@link summarize}, this FAILS CLOSED for an unusable jump: dialing
|
|
167
|
+
* through a deleted host (or a second jump) cannot work, and the caller must say
|
|
168
|
+
* why instead of silently connecting some other way.
|
|
169
|
+
*/
|
|
170
|
+
resolveProxy(alias: string): ResolvedProxy;
|
|
171
|
+
private requireStoredProxy;
|
|
92
172
|
setDeploy(alias: string, state: RemoteDeployState): void;
|
|
93
173
|
listWorkspaces(): RemoteWorkspaceBinding[];
|
|
94
174
|
createWorkspace(payload: WorkspacePayload): RemoteWorkspaceBinding;
|
package/lib/types/tools.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
7
7
|
import type { RemotePool } from './pool.ts';
|
|
8
8
|
import type { RemoteStore } from './store.ts';
|
|
9
|
+
import type { RemoteHostProxyView } from './protocol.ts';
|
|
9
10
|
/** Agent-facing host row (schema-strict projection of RemoteHostSummary). */
|
|
10
11
|
export interface AgentHostRow {
|
|
11
12
|
alias: string;
|
|
@@ -17,6 +18,8 @@ export interface AgentHostRow {
|
|
|
17
18
|
managedKey: boolean;
|
|
18
19
|
description?: string;
|
|
19
20
|
tags: string[];
|
|
21
|
+
/** Effective network route (secret-free), as the host list reports it. */
|
|
22
|
+
proxy: RemoteHostProxyView;
|
|
20
23
|
createdAt: number;
|
|
21
24
|
updatedAt: number;
|
|
22
25
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-vs",
|
|
3
3
|
"description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh",
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
AUTO_RETRY_MS,
|
|
20
20
|
connectionLabelKey,
|
|
21
21
|
consumeAutoRetry,
|
|
22
|
+
egressTitleLine,
|
|
22
23
|
markConnectionProbeOk,
|
|
23
24
|
useConnectionStatus,
|
|
24
25
|
type ConnectionView,
|
|
@@ -26,9 +27,18 @@ import {
|
|
|
26
27
|
import { useExplorer } from './store.tsx'
|
|
27
28
|
import { MiniSpinner } from './vsc/kit.tsx'
|
|
28
29
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Tooltip: alias, state, where the connection ACTUALLY goes (or would go), and
|
|
32
|
+
* the last failure (with its time) or last success.
|
|
33
|
+
*
|
|
34
|
+
* The egress line is the answer to "is this really going through the jump host?",
|
|
35
|
+
* which the settings panel cannot answer: it shows the SAVED decision, while a
|
|
36
|
+
* connection established before an edit keeps running on the old route until it
|
|
37
|
+
* is dropped.
|
|
38
|
+
*/
|
|
39
|
+
function titleOf(connection: ConnectionView, t: (key: string) => string, egress: string | undefined): string {
|
|
31
40
|
const parts = [`${connection.alias} · ${t(connectionLabelKey(connection.state))}`]
|
|
41
|
+
if (egress !== undefined) parts.push(egress)
|
|
32
42
|
if (connection.state === 'error') {
|
|
33
43
|
if (connection.errorAt !== undefined) {
|
|
34
44
|
parts.push(`${t('connection.errorAt')} ${new Date(connection.errorAt).toLocaleTimeString()}`)
|
|
@@ -107,11 +117,15 @@ export function ConnectionStatusChip(props: { compact?: boolean }): ReactNode {
|
|
|
107
117
|
if (alias === '' || connection === undefined) return null
|
|
108
118
|
const label = retrying ? t('connection.retrying') : t(connectionLabelKey(connection.state))
|
|
109
119
|
const className = `rvs-conn rvs-conn-${connection.state}${props.compact === true ? ' compact' : ''}${errored ? ' clickable' : ''}`
|
|
110
|
-
const
|
|
120
|
+
const egress = egressTitleLine(connection, t)
|
|
121
|
+
const title = titleOf(connection, t, egress)
|
|
122
|
+
// The tooltip is mouse-only, so the same line goes into the accessible name:
|
|
123
|
+
// a screen-reader user asks the same question the mouse user does.
|
|
124
|
+
const ariaLabel = egress === undefined ? label : `${label} · ${egress}`
|
|
111
125
|
if (!errored) {
|
|
112
126
|
// A healthy/idle read-out must not be a button whose click does nothing.
|
|
113
127
|
return (
|
|
114
|
-
<span className={className} title={title} role="status" aria-label={
|
|
128
|
+
<span className={className} title={title} role="status" aria-label={ariaLabel}>
|
|
115
129
|
<span className="rvs-conn-dot" aria-hidden="true" />
|
|
116
130
|
{props.compact !== true && <span className="rvs-conn-label">{label}</span>}
|
|
117
131
|
</span>
|
|
@@ -121,7 +135,7 @@ export function ConnectionStatusChip(props: { compact?: boolean }): ReactNode {
|
|
|
121
135
|
// dial can take the whole ready-timeout, and hiding the manual affordance for
|
|
122
136
|
// its duration is exactly when the user reaches for it.
|
|
123
137
|
return (
|
|
124
|
-
<button type="button" className={className} title={title} aria-label={
|
|
138
|
+
<button type="button" className={className} title={title} aria-label={ariaLabel} aria-busy={retrying} onClick={() => { void attempt() }}>
|
|
125
139
|
<span className="rvs-conn-dot" aria-hidden="true" />
|
|
126
140
|
{retrying && <MiniSpinner />}
|
|
127
141
|
{props.compact !== true && <span className="rvs-conn-label">{label}</span>}
|