dsh-remote-vs 0.18.0 → 0.19.1
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 +12 -2
- package/README.md +10 -2
- package/lib/client.js +1075 -9
- package/lib/index.js +381 -4
- package/lib/types/client/MonitorView.d.ts +33 -0
- package/lib/types/client/api.d.ts +8 -0
- package/lib/types/client/metrics-model.d.ts +84 -0
- package/lib/types/client/store.d.ts +1 -1
- package/lib/types/metrics.d.ts +116 -0
- package/lib/types/monitor.d.ts +57 -0
- package/lib/types/protocol.d.ts +54 -0
- package/package.json +36 -36
- package/src/client/MonitorView.tsx +636 -0
- package/src/client/RemoteRoot.tsx +9 -2
- package/src/client/api.ts +16 -0
- package/src/client/i18n.ts +84 -0
- package/src/client/metrics-model.ts +242 -0
- package/src/client/store.tsx +2 -2
- package/src/client/vsc/vsc.css +464 -0
- package/src/metrics.ts +300 -0
- package/src/monitor.ts +203 -0
- package/src/protocol.ts +58 -1
- package/src/routes.ts +47 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One bounded POSIX probe for the host monitor panel, and its pure parser.
|
|
3
|
+
*
|
|
4
|
+
* Why a shell one-liner instead of the helper or Python on the remote:
|
|
5
|
+
* - the plugin targets bare POSIX hosts (the doctor probe already works this
|
|
6
|
+
* way); requiring `python3`/`psutil` would make the panel dead on a stock
|
|
7
|
+
* router or NAS;
|
|
8
|
+
* - one `exec` over the pooled SSH channel needs no helper deploy and no
|
|
9
|
+
* version handshake, so the panel also works on a host the deploy pipeline
|
|
10
|
+
* never touched.
|
|
11
|
+
*
|
|
12
|
+
* Every fact is a marker line (`@@RVS-MET key detail`), so a banner printed by
|
|
13
|
+
* a login shell or a stray line of a command can never be mistaken for a
|
|
14
|
+
* measurement. A metric the host cannot answer is `null` (rendered as unknown),
|
|
15
|
+
* never zero: a VM without a thermal zone has no temperature, it does not have
|
|
16
|
+
* 0 °C.
|
|
17
|
+
*
|
|
18
|
+
* CPU% and the network rate are DELTAS over the previous sample: the caller
|
|
19
|
+
* keeps the counters (`cpuPercent` / `netRateBps` below). The first sample is
|
|
20
|
+
* honestly unknown instead of a made-up number.
|
|
21
|
+
*
|
|
22
|
+
* Linux is the supported source (`/proc`). A host that is not Linux simply
|
|
23
|
+
* answers `unknown`, which the UI renders as "unknown", not as an empty host.
|
|
24
|
+
*/
|
|
25
|
+
/** Prefix of every control line the probe prints (also the "did it answer" proof). */
|
|
26
|
+
export declare const METRICS_MARK = "@@RVS-MET";
|
|
27
|
+
/**
|
|
28
|
+
* Budget for the whole probe.
|
|
29
|
+
*
|
|
30
|
+
* A handful of `/proc` reads over one channel: if the host itself is stuck (a
|
|
31
|
+
* hung mount, a thief of a process, a network blip) the route must answer with
|
|
32
|
+
* the exec deadline instead of holding the monitor's poll forever.
|
|
33
|
+
*/
|
|
34
|
+
export declare const METRICS_TIMEOUT_MS = 8000;
|
|
35
|
+
/** CPU timers from `/proc/stat` (jiffies). */
|
|
36
|
+
export interface CpuCounters {
|
|
37
|
+
/** user + nice + system + idle + iowait + irq + softirq + steal. */
|
|
38
|
+
total: number;
|
|
39
|
+
/** idle + iowait. */
|
|
40
|
+
idle: number;
|
|
41
|
+
}
|
|
42
|
+
/** Cumulative network byte counters from `/proc/net/dev` (loopback excluded). */
|
|
43
|
+
export interface NetCounters {
|
|
44
|
+
rx: number;
|
|
45
|
+
tx: number;
|
|
46
|
+
}
|
|
47
|
+
/** What the probe process itself reported, for honest unknown/error wording. */
|
|
48
|
+
export interface MetricsParseOptions {
|
|
49
|
+
exitCode: number | null;
|
|
50
|
+
timedOut?: boolean;
|
|
51
|
+
/** Connection error message when the command never ran. */
|
|
52
|
+
error?: string | undefined;
|
|
53
|
+
stderr?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The probe's answer.
|
|
57
|
+
*
|
|
58
|
+
* `state: 'unknown'` means the command ran but the data cannot be trusted (it
|
|
59
|
+
* timed out, the channel died before an exit status, or the markers are
|
|
60
|
+
* missing). A transport failure is classified by the caller (`HostMonitor`),
|
|
61
|
+
* not here.
|
|
62
|
+
*/
|
|
63
|
+
export interface ParsedMetrics {
|
|
64
|
+
state: 'ok' | 'unknown';
|
|
65
|
+
reason?: string;
|
|
66
|
+
kernel: string | null;
|
|
67
|
+
cpuCores: number | null;
|
|
68
|
+
cpuModel: string | null;
|
|
69
|
+
ip: string | null;
|
|
70
|
+
uptimeSeconds: number | null;
|
|
71
|
+
load: [number, number, number] | null;
|
|
72
|
+
cpu: CpuCounters | null;
|
|
73
|
+
memTotalBytes: number | null;
|
|
74
|
+
memUsedBytes: number | null;
|
|
75
|
+
diskTotalBytes: number | null;
|
|
76
|
+
diskUsedBytes: number | null;
|
|
77
|
+
temperatureC: number | null;
|
|
78
|
+
net: NetCounters | null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The remote probe line.
|
|
82
|
+
*
|
|
83
|
+
* `printf` never interpolates the input; every value comes from a fixed local
|
|
84
|
+
* command. `2>/dev/null` is only used where the missing tool/file is itself a
|
|
85
|
+
* normal answer (`/proc` on a non-Linux host); the parser then sees an empty
|
|
86
|
+
* value and reports it as unknown rather than as a zero.
|
|
87
|
+
*/
|
|
88
|
+
export declare function metricsCommand(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Parse the probe's stdout.
|
|
91
|
+
*
|
|
92
|
+
* Exit-code/timed-out/transport outcomes are answered BEFORE the markers so a
|
|
93
|
+
* half-written probe can never be reported as a complete sample.
|
|
94
|
+
*/
|
|
95
|
+
export declare function parseMetrics(stdout: string, options: MetricsParseOptions): ParsedMetrics;
|
|
96
|
+
/**
|
|
97
|
+
* CPU busy percentage between two counter samples.
|
|
98
|
+
*
|
|
99
|
+
* Null when a counter is missing, the sum did not advance, or the counters
|
|
100
|
+
* went backwards (a reboot between the two samples): all three mean "unknown",
|
|
101
|
+
* not "0%".
|
|
102
|
+
*/
|
|
103
|
+
export declare function cpuPercent(previous: CpuCounters | null | undefined, next: CpuCounters | null | undefined): number | null;
|
|
104
|
+
/**
|
|
105
|
+
* Network bytes-per-second between two counter samples.
|
|
106
|
+
*
|
|
107
|
+
* Null when either counter is missing, the interval is not positive, or a
|
|
108
|
+
* counter went backwards (a reboot): a rate computed from a reset counter is
|
|
109
|
+
* noise, and showing it as a huge spike would be worse than "unknown".
|
|
110
|
+
*/
|
|
111
|
+
export declare function netRateBps(previous: NetCounters | null | undefined, next: NetCounters | null | undefined, elapsedMs: number | null | undefined): {
|
|
112
|
+
rx: number;
|
|
113
|
+
tx: number;
|
|
114
|
+
} | null;
|
|
115
|
+
/** Bytes as a percentage of a total; null when either side is unknown. */
|
|
116
|
+
export declare function usedPercent(used: number | null, total: number | null): number | null;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HostMonitor: the Host-side cache/sampler behind the monitor panel.
|
|
3
|
+
*
|
|
4
|
+
* One `pool.exec` per alias per sample (a handful of `/proc` reads; see
|
|
5
|
+
* `metrics.ts`). The panel polls while it is visible, but three things can ask
|
|
6
|
+
* within the same second (several browser tabs, a manual refresh, the first
|
|
7
|
+
* paint after a rail switch), so the sampler:
|
|
8
|
+
*
|
|
9
|
+
* - reuses a sample younger than `freshMs` (default 3 s, below the panel's 5 s
|
|
10
|
+
* poll) — a refresh storm costs one channel, not one per request;
|
|
11
|
+
* - joins an in-flight sample instead of opening a second channel for the same
|
|
12
|
+
* alias (the pool's own slot budget would otherwise queue them for up to 30 s);
|
|
13
|
+
* - keeps the previous counters so CPU% and the network rate are deltas over
|
|
14
|
+
* real elapsed time. The first sample has counters but no previous sample:
|
|
15
|
+
* those two values are null (unknown), never zero.
|
|
16
|
+
*
|
|
17
|
+
* `forget(alias)` is called from the two places a host's identity changes
|
|
18
|
+
* (host DELETE and host edit): a cached sample carries the old connection's
|
|
19
|
+
* counters, and using it after a re-dial would print a bogus rate.
|
|
20
|
+
*/
|
|
21
|
+
import type { RemoteExecResult, RemoteHostMetrics } from './protocol.ts';
|
|
22
|
+
/** The slice of `RemotePool` the sampler needs (fake in gates, real at runtime). */
|
|
23
|
+
export interface MetricsExecutor {
|
|
24
|
+
exec(alias: string, command: string, opts?: {
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}): Promise<RemoteExecResult>;
|
|
27
|
+
}
|
|
28
|
+
export interface HostMonitorOptions {
|
|
29
|
+
/** Injectable clock (gates drive time without sleeping). */
|
|
30
|
+
now?: () => number;
|
|
31
|
+
/** Snapshot reuse window. Deliberately below the panel's 5 s poll. */
|
|
32
|
+
freshMs?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Default reuse window: below the panel poll, above a refresh storm. */
|
|
35
|
+
export declare const DEFAULT_FRESH_MS = 3000;
|
|
36
|
+
/** Every field null: an honest "we did not get an answer". */
|
|
37
|
+
export declare function emptyMetrics(alias: string, state: 'unknown' | 'error', reason: string, sampledAt: number): RemoteHostMetrics;
|
|
38
|
+
export declare class HostMonitor {
|
|
39
|
+
private readonly pool;
|
|
40
|
+
private readonly now;
|
|
41
|
+
private readonly freshMs;
|
|
42
|
+
private readonly cache;
|
|
43
|
+
private readonly inflight;
|
|
44
|
+
/**
|
|
45
|
+
* Bumped by `forget`. A probe that started before a host edit/delete must not
|
|
46
|
+
* write its answer into the cache afterwards — the counters belong to the old
|
|
47
|
+
* connection, and a re-created host with the same alias would briefly read a
|
|
48
|
+
* stale sample.
|
|
49
|
+
*/
|
|
50
|
+
private readonly generations;
|
|
51
|
+
constructor(pool: MetricsExecutor, options?: HostMonitorOptions);
|
|
52
|
+
/** One sample for one alias; `force` bypasses the reuse window (manual refresh). */
|
|
53
|
+
sample(alias: string, force?: boolean): Promise<RemoteHostMetrics>;
|
|
54
|
+
/** Drop everything known about one alias (host edited or deleted). */
|
|
55
|
+
forget(alias: string): void;
|
|
56
|
+
private probe;
|
|
57
|
+
}
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare const REMOTE_API: {
|
|
|
37
37
|
readonly forwards: "/api/dsh-remote/forwards";
|
|
38
38
|
/** Remote listening TCP sockets for the port panel (one bounded probe). */
|
|
39
39
|
readonly listenPorts: "/api/dsh-remote/listen-ports";
|
|
40
|
+
/** Live system metrics for the monitor panel (one bounded probe per host). */
|
|
41
|
+
readonly metrics: "/api/dsh-remote/metrics";
|
|
40
42
|
};
|
|
41
43
|
/**
|
|
42
44
|
* Most entries one multi-selection download may archive. The selection rides in
|
|
@@ -622,3 +624,55 @@ export interface RemoteListenPortsResult {
|
|
|
622
624
|
/** Why the probe could not be used, when it could not. */
|
|
623
625
|
error?: string;
|
|
624
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* How one host metrics sample ended.
|
|
629
|
+
*
|
|
630
|
+
* `ok` = the probe answered and at least one metric was readable; `unknown` =
|
|
631
|
+
* the command ran but could not be trusted (timeout, missing markers, a host
|
|
632
|
+
* that is not Linux); `error` = the command never produced a usable answer
|
|
633
|
+
* (transport failure). `null` fields inside an `ok` sample mean "this host does
|
|
634
|
+
* not expose that metric" — the UI must render them as unknown, never as zero.
|
|
635
|
+
*/
|
|
636
|
+
export type RemoteMetricsState = 'ok' | 'unknown' | 'error';
|
|
637
|
+
/**
|
|
638
|
+
* One host's live system metrics, sampled by the Host over the existing SSH
|
|
639
|
+
* channel (a single bounded POSIX probe; no helper and no Python on the remote).
|
|
640
|
+
*
|
|
641
|
+
* `cpuPercent`, `netRxBps` and `netTxBps` are deltas over the previous sample:
|
|
642
|
+
* the first sample has them null on purpose (a made-up 0% would be a lie). The
|
|
643
|
+
* Host caches a sample for a few seconds, so a poll storm costs one channel.
|
|
644
|
+
*/
|
|
645
|
+
export interface RemoteHostMetrics {
|
|
646
|
+
alias: string;
|
|
647
|
+
state: RemoteMetricsState;
|
|
648
|
+
/** Why the state is not `ok`; never empty then. */
|
|
649
|
+
reason?: string;
|
|
650
|
+
/** Host clock when the sample was taken (epoch ms). */
|
|
651
|
+
sampledAt: number;
|
|
652
|
+
/** `uname -srm` (`Linux 6.1.0 x86_64`), or null when unreadable. */
|
|
653
|
+
kernel: string | null;
|
|
654
|
+
cpuCores: number | null;
|
|
655
|
+
cpuModel: string | null;
|
|
656
|
+
ip: string | null;
|
|
657
|
+
uptimeSeconds: number | null;
|
|
658
|
+
load1: number | null;
|
|
659
|
+
load5: number | null;
|
|
660
|
+
load15: number | null;
|
|
661
|
+
/** Busy CPU over the previous sample, 0–100. */
|
|
662
|
+
cpuPercent: number | null;
|
|
663
|
+
memUsedBytes: number | null;
|
|
664
|
+
memTotalBytes: number | null;
|
|
665
|
+
memPercent: number | null;
|
|
666
|
+
diskUsedBytes: number | null;
|
|
667
|
+
diskTotalBytes: number | null;
|
|
668
|
+
diskPercent: number | null;
|
|
669
|
+
/** The first thermal zone in °C when the host exposes one (many VMs do not). */
|
|
670
|
+
temperatureC: number | null;
|
|
671
|
+
/** Receive/transmit bytes per second since the previous sample. */
|
|
672
|
+
netRxBps: number | null;
|
|
673
|
+
netTxBps: number | null;
|
|
674
|
+
}
|
|
675
|
+
/** The monitor route's answer (`alias` omitted = every configured host). */
|
|
676
|
+
export interface RemoteMetricsResult {
|
|
677
|
+
hosts: RemoteHostMetrics[];
|
|
678
|
+
}
|
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.19.1",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@codemirror/view": "^6.43.14",
|
|
123
123
|
"@deepseek-ai/dsh-fs-ssh": "0.2.1-rc.2",
|
|
124
124
|
"@deepseek-ai/dsh-ssh": "0.2.1-rc.2",
|
|
125
|
-
"@deepseek-ai/schemastery": "3.
|
|
125
|
+
"@deepseek-ai/schemastery": "3.19.0",
|
|
126
126
|
"@lezer/highlight": "1.2.3",
|
|
127
127
|
"@xterm/addon-fit": "^0.11.0",
|
|
128
128
|
"@xterm/xterm": "^6.0.0",
|
|
@@ -130,44 +130,44 @@
|
|
|
130
130
|
"zod": "4.4.3"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|
|
133
|
-
"@deepseek-ai/cordis": "^4.0
|
|
134
|
-
"@deepseek-ai/dsh-agent-preset": "^0.2.2-
|
|
135
|
-
"@deepseek-ai/dsh-bash-local": "^0.2.2-
|
|
136
|
-
"@deepseek-ai/dsh-file-reference": "^0.2.2-
|
|
137
|
-
"@deepseek-ai/dsh-fs": "^0.2.2-
|
|
138
|
-
"@deepseek-ai/dsh-shell": "^0.2.2-
|
|
139
|
-
"@deepseek-ai/dsh-spill": "^0.2.2-
|
|
140
|
-
"@deepseek-ai/dsh-subprocess": "^0.2.2-
|
|
141
|
-
"@deepseek-ai/dsh-tools": "^0.2.2-
|
|
133
|
+
"@deepseek-ai/cordis": "^4.1.0",
|
|
134
|
+
"@deepseek-ai/dsh-agent-preset": "^0.2.2-rc.1",
|
|
135
|
+
"@deepseek-ai/dsh-bash-local": "^0.2.2-rc.1",
|
|
136
|
+
"@deepseek-ai/dsh-file-reference": "^0.2.2-rc.1",
|
|
137
|
+
"@deepseek-ai/dsh-fs": "^0.2.2-rc.1",
|
|
138
|
+
"@deepseek-ai/dsh-shell": "^0.2.2-rc.1",
|
|
139
|
+
"@deepseek-ai/dsh-spill": "^0.2.2-rc.1",
|
|
140
|
+
"@deepseek-ai/dsh-subprocess": "^0.2.2-rc.1",
|
|
141
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
|
|
142
142
|
"react": "^18.2.0",
|
|
143
143
|
"react-dom": "^18.2.0"
|
|
144
144
|
},
|
|
145
145
|
"devDependencies": {
|
|
146
|
-
"@deepseek-ai/cordis": "^4.0
|
|
147
|
-
"@deepseek-ai/dsh-agent": "0.2.2-
|
|
148
|
-
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-
|
|
149
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.2-
|
|
150
|
-
"@deepseek-ai/dsh-bash-local": "0.2.2-
|
|
151
|
-
"@deepseek-ai/dsh-client-locale": "0.2.2-
|
|
152
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-
|
|
153
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-
|
|
154
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-
|
|
155
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-
|
|
156
|
-
"@deepseek-ai/dsh-client-ui-workspace": "0.2.2-
|
|
157
|
-
"@deepseek-ai/dsh-file-reference": "0.2.2-
|
|
158
|
-
"@deepseek-ai/dsh-fs": "0.2.2-
|
|
159
|
-
"@deepseek-ai/dsh-host-directory-picker": "0.2.2-
|
|
160
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.2-
|
|
161
|
-
"@deepseek-ai/dsh-llm": "0.2.2-
|
|
162
|
-
"@deepseek-ai/dsh-sandbox": "0.2.2-
|
|
163
|
-
"@deepseek-ai/dsh-session": "0.2.2-
|
|
164
|
-
"@deepseek-ai/dsh-shell": "0.2.2-
|
|
165
|
-
"@deepseek-ai/dsh-spill": "0.2.2-
|
|
166
|
-
"@deepseek-ai/dsh-subprocess": "0.2.2-
|
|
167
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.2-
|
|
168
|
-
"@deepseek-ai/dsh-tools": "0.2.2-
|
|
169
|
-
"@deepseek-ai/dsh-working-directory": "0.2.2-
|
|
170
|
-
"@deepseek-ai/dsh-workspace": "0.2.2-
|
|
146
|
+
"@deepseek-ai/cordis": "^4.1.0",
|
|
147
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.1",
|
|
148
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.1",
|
|
149
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.1",
|
|
150
|
+
"@deepseek-ai/dsh-bash-local": "0.2.2-rc.1",
|
|
151
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.1",
|
|
152
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.1",
|
|
153
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.1",
|
|
154
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.1",
|
|
155
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
|
|
156
|
+
"@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.1",
|
|
157
|
+
"@deepseek-ai/dsh-file-reference": "0.2.2-rc.1",
|
|
158
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.1",
|
|
159
|
+
"@deepseek-ai/dsh-host-directory-picker": "0.2.2-rc.1",
|
|
160
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.1",
|
|
161
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.1",
|
|
162
|
+
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.1",
|
|
163
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.1",
|
|
164
|
+
"@deepseek-ai/dsh-shell": "0.2.2-rc.1",
|
|
165
|
+
"@deepseek-ai/dsh-spill": "0.2.2-rc.1",
|
|
166
|
+
"@deepseek-ai/dsh-subprocess": "0.2.2-rc.1",
|
|
167
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
|
|
168
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
|
|
169
|
+
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.1",
|
|
170
|
+
"@deepseek-ai/dsh-workspace": "0.2.2-rc.1",
|
|
171
171
|
"@types/node": "^22.20.0",
|
|
172
172
|
"@types/react": "~18.3.1",
|
|
173
173
|
"@types/react-dom": "^18.3.5",
|