dsh-remote-go 0.3.0 → 0.3.2
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.md +1 -0
- package/dist/client.js +1348 -2095
- package/dist/src/admission.js +3 -28
- package/dist/src/api.js +37 -99
- package/dist/src/atomic-json.js +32 -66
- package/dist/src/bootstrap.js +17 -27
- package/dist/src/connect/attach.js +3 -25
- package/dist/src/connect/bootstrap.js +2 -8
- package/dist/src/connect/failures.js +3 -18
- package/dist/src/connect/guards.js +13 -8
- package/dist/src/connect/launch.js +11 -21
- package/dist/src/connect/links.js +11 -27
- package/dist/src/connect/ownership.js +33 -114
- package/dist/src/connect/pipeline.js +62 -159
- package/dist/src/connect/reattach.js +26 -44
- package/dist/src/connect/registry.js +0 -1
- package/dist/src/connect/repair.js +8 -37
- package/dist/src/connect/restart.js +36 -97
- package/dist/src/connect/stop.js +16 -50
- package/dist/src/connect/transport.js +10 -18
- package/dist/src/connect/verify.js +3 -12
- package/dist/src/connect/watchdog.js +6 -38
- package/dist/src/connect-log.js +16 -41
- package/dist/src/connect-progress.js +13 -45
- package/dist/src/constants.js +18 -43
- package/dist/src/context.js +13 -32
- package/dist/src/diagnostics.js +56 -25
- package/dist/src/download-jobs.js +11 -20
- package/dist/src/errors.js +175 -190
- package/dist/src/events.js +20 -84
- package/dist/src/host-lifecycle.js +69 -177
- package/dist/src/host-registry.js +27 -78
- package/dist/src/host-runtime.js +0 -9
- package/dist/src/host-view.js +6 -29
- package/dist/src/index.js +15 -35
- package/dist/src/kernel-adapter.js +34 -80
- package/dist/src/key-files.js +10 -23
- package/dist/src/known-hosts.js +13 -34
- package/dist/src/layout.js +3 -20
- package/dist/src/local-download.js +94 -163
- package/dist/src/local-ssh.js +12 -19
- package/dist/src/local-version.js +35 -49
- package/dist/src/node/download.js +1 -4
- package/dist/src/node-runtime.js +19 -38
- package/dist/src/probe.js +6 -7
- package/dist/src/prompts.js +56 -128
- package/dist/src/proxy/cookies.js +26 -60
- package/dist/src/proxy/headers.js +30 -125
- package/dist/src/proxy/http.js +33 -41
- package/dist/src/proxy/index.js +20 -34
- package/dist/src/proxy/limits.js +4 -6
- package/dist/src/proxy/routes.js +10 -17
- package/dist/src/proxy/upgrade.js +27 -42
- package/dist/src/redact.js +14 -33
- package/dist/src/remote-files.js +9 -21
- package/dist/src/remote-path.js +21 -62
- package/dist/src/remote-proc.js +35 -103
- package/dist/src/remote-web/registry.js +10 -50
- package/dist/src/remote-web/resolve.js +23 -104
- package/dist/src/remote-web/start.js +27 -64
- package/dist/src/remote-web/stop.js +6 -25
- package/dist/src/request-trust.js +15 -32
- package/dist/src/runtime/dispatch.js +33 -143
- package/dist/src/runtime/effects.js +7 -17
- package/dist/src/runtime/events.js +1 -1
- package/dist/src/runtime/fsm.js +11 -61
- package/dist/src/runtime/rules.js +121 -199
- package/dist/src/secrets.js +15 -38
- package/dist/src/service.js +22 -128
- package/dist/src/settings.js +41 -42
- package/dist/src/ssh-config.js +22 -41
- package/dist/src/ssh-failures.js +23 -74
- package/dist/src/ssh-sftp.js +47 -86
- package/dist/src/ssh.js +99 -179
- package/dist/src/store.js +31 -48
- package/dist/src/tool-shared.js +17 -52
- package/dist/src/tools-exec-policy.js +33 -79
- package/dist/src/tools-exec.js +87 -151
- package/dist/src/tools-report.js +100 -167
- package/dist/src/tools.js +59 -133
- package/dist/src/tunnel.js +9 -27
- package/dist/src/util.js +19 -56
- package/dist/src/version.js +6 -12
- package/dist/src/watchdog-bus.js +0 -8
- package/dist/src/watchdog.js +7 -47
- package/package.json +3 -3
package/dist/src/watchdog.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* It used to live inside `host-lifecycle.ts` and reach its one-shot actions back through `ctx`
|
|
6
|
-
* (`requestReattach`/`repairTunnel`). Those reverse callbacks are gone: a confirmed or recovered
|
|
7
|
-
* episode is published on `ctx.bus`, and `connect/watchdog.ts` — the bus's only subscriber — runs
|
|
8
|
-
* the action. The dependency arrow therefore points one way only: this module never imports
|
|
9
|
-
* `connect/*`, so the modules that dispatch `arm(heartbeat)` do not create a cycle.
|
|
10
|
-
*
|
|
11
|
-
* The two timer *primitives* (`stopRemoteHeartbeat`/`cancelRemoteCheck`) stay in
|
|
12
|
-
* `host-lifecycle.ts`, the owner of the runtime's timer block; the policy that fills them lives
|
|
13
|
-
* here.
|
|
14
|
-
*/
|
|
1
|
+
/** The liveness watchdog: the heartbeat probe, the episode it opens when the remote UI stops answering, and the two
|
|
2
|
+
* action requests it turns into bus events. It never imports `connect/*`: an episode is published on `ctx.bus`, and
|
|
3
|
+
* `connect/watchdog.ts` — its only subscriber — runs the action. The timer primitives stay in `host-lifecycle.ts`. */
|
|
15
4
|
import { REMOTE_EPISODE_COOLDOWN_MS, REMOTE_HEARTBEAT_DEFAULT_SEC, REMOTE_HEARTBEAT_MAX_SEC, REMOTE_HEARTBEAT_MIN_SEC, REMOTE_UNREACHABLE_FAILURES, } from './constants.js';
|
|
16
5
|
import { cancelRemoteCheck, stopRemoteHeartbeat } from './host-lifecycle.js';
|
|
17
6
|
import { isUiUp } from './remote-proc.js';
|
|
18
|
-
/** Milliseconds between liveness probes, from settings (default 30s, disabled allowed). */
|
|
19
7
|
export function remoteHeartbeatIntervalSec(ctx) {
|
|
20
|
-
const
|
|
21
|
-
const seconds = Number(raw?.intervalSec);
|
|
8
|
+
const seconds = Number(ctx.settings()?.remoteHeartbeat?.intervalSec);
|
|
22
9
|
if (!Number.isFinite(seconds))
|
|
23
10
|
return REMOTE_HEARTBEAT_DEFAULT_SEC;
|
|
24
11
|
return Math.min(REMOTE_HEARTBEAT_MAX_SEC, Math.max(REMOTE_HEARTBEAT_MIN_SEC, Math.round(seconds)));
|
|
25
12
|
}
|
|
26
|
-
/** Start the light liveness probe for a host that just became connected. */
|
|
27
13
|
export function startRemoteHeartbeat(ctx, runtime) {
|
|
28
14
|
stopRemoteHeartbeat(runtime);
|
|
29
15
|
const enabled = ctx.settings()?.remoteHeartbeat?.enabled !== false;
|
|
@@ -38,7 +24,6 @@ export function startRemoteHeartbeat(ctx, runtime) {
|
|
|
38
24
|
runtime.heartbeatTimer.unref?.();
|
|
39
25
|
ctx.progress.log(runtime, 'debug', `remote heartbeat: probing every ${intervalSec}s`);
|
|
40
26
|
}
|
|
41
|
-
/** A host is watchable only while it is really up and no one-shot action owns the link. */
|
|
42
27
|
export function watchable(ctx, runtime) {
|
|
43
28
|
return (ctx.state.disposed !== true &&
|
|
44
29
|
runtime.desired === 'connected' &&
|
|
@@ -47,16 +32,12 @@ export function watchable(ctx, runtime) {
|
|
|
47
32
|
runtime.ssh?.connected === true &&
|
|
48
33
|
runtime.tunnel !== null);
|
|
49
34
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Open a liveness episode at most once. Transient reports (a proxy/tunnel failure) are
|
|
52
|
-
* coalesced: after a confirmed-healthy episode the same kind of report is ignored for a
|
|
53
|
-
* cooldown window, so a flapping tunnel cannot emit suspected/recovered on every request.
|
|
54
|
-
* Returns whether a new episode was opened.
|
|
55
|
-
*/
|
|
56
35
|
function beginRemoteEpisode(ctx, runtime, source) {
|
|
57
36
|
if (runtime.remoteEpisode === true)
|
|
58
37
|
return false;
|
|
59
38
|
const transient = source === 'proxy' || source === 'tunnel';
|
|
39
|
+
// A flapping tunnel must not emit suspected/recovered on every request: after a confirmed-healthy
|
|
40
|
+
// episode the same kind of transient report is ignored for the cooldown window.
|
|
60
41
|
if (transient && Date.now() < (Number(runtime.episodeCooldownUntil) || 0)) {
|
|
61
42
|
ctx.progress.log(runtime, 'debug', `remote-unreachable reported again (${source}); episode cooldown, ignoring`);
|
|
62
43
|
return false;
|
|
@@ -67,12 +48,6 @@ function beginRemoteEpisode(ctx, runtime, source) {
|
|
|
67
48
|
ctx.onRemoteUnreachable?.(runtime, { phase: 'suspected', source });
|
|
68
49
|
return true;
|
|
69
50
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Reset the failure streak and close the episode. The recovery *action* (probe the local
|
|
72
|
-
* listener, rebuild it when needed, announce the episode) belongs to the bus subscriber:
|
|
73
|
-
* `connect/watchdog.ts` runs it and publishes `recovered` once the link is usable again, which is
|
|
74
|
-
* the same point in the sequence the old inline code announced it at.
|
|
75
|
-
*/
|
|
76
51
|
function clearRemoteEpisode(ctx, runtime, source) {
|
|
77
52
|
const wasOpen = runtime.remoteEpisode === true;
|
|
78
53
|
const transient = runtime.episodeSource === 'proxy' || runtime.episodeSource === 'tunnel';
|
|
@@ -94,11 +69,6 @@ function scheduleRemoteCheck(ctx, runtime, source, delayMs) {
|
|
|
94
69
|
}, delayMs);
|
|
95
70
|
runtime.remoteCheckTimer.unref?.();
|
|
96
71
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Probe the connected host once and feed the consecutive-failure counter. One
|
|
99
|
-
* failed request is not a restart: the counter has to reach
|
|
100
|
-
* {@link REMOTE_UNREACHABLE_FAILURES} before a re-attach is requested.
|
|
101
|
-
*/
|
|
102
72
|
async function checkRemoteNow(ctx, runtime, source) {
|
|
103
73
|
if (!watchable(ctx, runtime) || typeof ctx.deps.remoteStatus !== 'function')
|
|
104
74
|
return;
|
|
@@ -112,7 +82,6 @@ async function checkRemoteNow(ctx, runtime, source) {
|
|
|
112
82
|
// swallow-ok: an unreachable probe is a failed probe, handled by the same counter
|
|
113
83
|
status = null;
|
|
114
84
|
}
|
|
115
|
-
// The transport may have gone away while the probe was in flight; the close handler owns that.
|
|
116
85
|
if (!watchable(ctx, runtime) || runtime.ssh !== ssh)
|
|
117
86
|
return;
|
|
118
87
|
if (isUiUp(status)) {
|
|
@@ -127,15 +96,10 @@ async function checkRemoteNow(ctx, runtime, source) {
|
|
|
127
96
|
return;
|
|
128
97
|
}
|
|
129
98
|
ctx.progress.log(runtime, 'warn', `remote-unreachable: ${runtime.remoteFailures} consecutive probes failed (${source}); re-attaching`);
|
|
130
|
-
ctx.onRemoteUnreachable?.(runtime, {
|
|
131
|
-
phase: 'confirmed',
|
|
132
|
-
source,
|
|
133
|
-
failures: runtime.remoteFailures,
|
|
134
|
-
});
|
|
99
|
+
ctx.onRemoteUnreachable?.(runtime, { phase: 'confirmed', source, failures: runtime.remoteFailures });
|
|
135
100
|
cancelRemoteCheck(runtime);
|
|
136
101
|
ctx.bus.publish({ kind: 'confirmed', hostId: runtime.id, reason: `probe-failed-${runtime.remoteFailures}`, source });
|
|
137
102
|
}
|
|
138
|
-
/** One scheduled heartbeat tick. */
|
|
139
103
|
export async function remoteHeartbeatTick(ctx, runtime) {
|
|
140
104
|
if (!watchable(ctx, runtime))
|
|
141
105
|
return;
|
|
@@ -143,10 +107,6 @@ export async function remoteHeartbeatTick(ctx, runtime) {
|
|
|
143
107
|
return;
|
|
144
108
|
await checkRemoteNow(ctx, runtime, 'heartbeat');
|
|
145
109
|
}
|
|
146
|
-
/**
|
|
147
|
-
* A proxy or tunnel failure was observed: report the episode once and confirm it
|
|
148
|
-
* with probes instead of treating one failed request as a remote restart.
|
|
149
|
-
*/
|
|
150
110
|
export function noteRemoteUnreachable(ctx, runtime, source) {
|
|
151
111
|
if (!watchable(ctx, runtime))
|
|
152
112
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-go",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "DSH 插件:在本地 DSH 里通过 SSH 使用远端 DSH(主机条切换、整窗接管、连接进度与日志、重启/关闭远端、远端文件下载、给本地 AI 会话的主机清单 / 体检报告 / 受控远端命令,三者默认隐藏按需解锁;插件自带 Node + npx,数据留在远端 ~/.dsh) | DSH plugin: use a remote DSH over SSH inside your local DSH (host switcher, full-window UI, connect progress and log, remote restart/stop, remote file downloads, and a host list / diagnosis report / guarded remote command for local AI sessions — hidden until the session unlocks them; plugin-managed Node + npx, data stays in the remote ~/.dsh)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/node": "^
|
|
68
|
+
"@types/node": "^26.6.6",
|
|
69
69
|
"@types/react": "^19.3.0",
|
|
70
70
|
"esbuild": "0.28.2",
|
|
71
71
|
"js-yaml": "^5.5.0",
|
|
72
72
|
"prettier": "^3.10.1",
|
|
73
|
-
"puppeteer-core": "^25.
|
|
73
|
+
"puppeteer-core": "^25.18.1",
|
|
74
74
|
"react": "^19.3.1",
|
|
75
75
|
"react-dom": "^19.3.1",
|
|
76
76
|
"ssh2": "1.17.0",
|