dsh-ssh-hub 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +271 -2
- package/cordis.patch.yml +16 -0
- package/icon.svg +3 -0
- package/lib/client.js +13975 -0
- package/lib/index.js +6908 -0
- package/lib/types/activity/history.d.ts +50 -0
- package/lib/types/alerting/notify.d.ts +89 -0
- package/lib/types/alerting/prompt-summary.d.ts +28 -0
- package/lib/types/alerting/rules.d.ts +135 -0
- package/lib/types/alerting/tools.d.ts +30 -0
- package/lib/types/audit/audit-log.d.ts +84 -0
- package/lib/types/audit/recorder.d.ts +50 -0
- package/lib/types/client/api.d.ts +222 -0
- package/lib/types/client/index.d.ts +45 -0
- package/lib/types/client/locales.d.ts +319 -0
- package/lib/types/client/native-panel.d.ts +70 -0
- package/lib/types/client/panel/ClusterTab.d.ts +7 -0
- package/lib/types/client/panel/DeployTab.d.ts +10 -0
- package/lib/types/client/panel/FleetTab.d.ts +10 -0
- package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
- package/lib/types/client/panel/HostsTab.d.ts +25 -0
- package/lib/types/client/panel/LogsTab.d.ts +10 -0
- package/lib/types/client/panel/SshPanel.d.ts +14 -0
- package/lib/types/client/panel/TerminalTab.d.ts +27 -0
- package/lib/types/client/panel/TransferTab.d.ts +7 -0
- package/lib/types/client/panel/TunnelEditDialog.d.ts +15 -0
- package/lib/types/client/panel/TunnelsTab.d.ts +27 -0
- package/lib/types/client/panel/controller.d.ts +253 -0
- package/lib/types/client/panel/helpers.d.ts +45 -0
- package/lib/types/client/panel/tabs.d.ts +62 -0
- package/lib/types/client/panel/xterm.css.d.ts +2 -0
- package/lib/types/client/settings-binding.d.ts +71 -0
- package/lib/types/deploy/orchestrator.d.ts +158 -0
- package/lib/types/deploy/tools.d.ts +14 -0
- package/lib/types/dsh-home.d.ts +16 -0
- package/lib/types/engine/cluster.d.ts +19 -0
- package/lib/types/engine/connection-pool.d.ts +183 -0
- package/lib/types/engine/proxy-command.d.ts +36 -0
- package/lib/types/engine/pty.d.ts +32 -0
- package/lib/types/engine/sftp.d.ts +20 -0
- package/lib/types/engine/terminal-sessions.d.ts +67 -0
- package/lib/types/engine/tunnel-discovery.d.ts +89 -0
- package/lib/types/engine/tunnel-remarks.d.ts +49 -0
- package/lib/types/engine/tunnel.d.ts +76 -0
- package/lib/types/engine.d.ts +103 -0
- package/lib/types/http.d.ts +59 -0
- package/lib/types/index.d.ts +128 -0
- package/lib/types/inspect/checks.d.ts +118 -0
- package/lib/types/inspect/inspection.d.ts +111 -0
- package/lib/types/inspect/tools.d.ts +50 -0
- package/lib/types/logs/search.d.ts +131 -0
- package/lib/types/logs/tools.d.ts +6 -0
- package/lib/types/loopback.d.ts +64 -0
- package/lib/types/monitor/loop.d.ts +133 -0
- package/lib/types/monitor/metrics.d.ts +151 -0
- package/lib/types/mount-once.d.ts +55 -0
- package/lib/types/protocol.d.ts +524 -0
- package/lib/types/routes.d.ts +82 -0
- package/lib/types/security/known-hosts.d.ts +153 -0
- package/lib/types/security/master-secret.d.ts +157 -0
- package/lib/types/security/redact.d.ts +44 -0
- package/lib/types/security/secrets.d.ts +70 -0
- package/lib/types/ssh-config.d.ts +42 -0
- package/lib/types/store.d.ts +183 -0
- package/lib/types/tool-surface.d.ts +72 -0
- package/lib/types/tools.d.ts +56 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +126 -6
- package/src/activity/history.ts +117 -0
- package/src/alerting/notify.ts +212 -0
- package/src/alerting/prompt-summary.ts +71 -0
- package/src/alerting/rules.ts +281 -0
- package/src/alerting/tools.ts +263 -0
- package/src/audit/audit-log.ts +199 -0
- package/src/audit/recorder.ts +73 -0
- package/src/client/api.ts +782 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/index.ts +150 -0
- package/src/client/locales.ts +654 -0
- package/src/client/native-panel.tsx +141 -0
- package/src/client/panel/ClusterTab.tsx +141 -0
- package/src/client/panel/DeployTab.tsx +314 -0
- package/src/client/panel/FleetTab.tsx +494 -0
- package/src/client/panel/HostFormDialog.tsx +289 -0
- package/src/client/panel/HostsTab.tsx +395 -0
- package/src/client/panel/LogsTab.tsx +208 -0
- package/src/client/panel/SshPanel.tsx +105 -0
- package/src/client/panel/TerminalTab.tsx +550 -0
- package/src/client/panel/TransferTab.tsx +238 -0
- package/src/client/panel/TunnelEditDialog.tsx +174 -0
- package/src/client/panel/TunnelsTab.tsx +328 -0
- package/src/client/panel/controller.ts +507 -0
- package/src/client/panel/helpers.ts +84 -0
- package/src/client/panel/panel.module.css +1734 -0
- package/src/client/panel/tabs.ts +52 -0
- package/src/client/panel/xterm.css.ts +2 -0
- package/src/client/settings-binding.ts +184 -0
- package/src/deploy/orchestrator.ts +326 -0
- package/src/deploy/tools.ts +225 -0
- package/src/dsh-home.ts +42 -0
- package/src/engine/cluster.ts +60 -0
- package/src/engine/connection-pool.ts +721 -0
- package/src/engine/proxy-command.ts +248 -0
- package/src/engine/pty.ts +78 -0
- package/src/engine/sftp.ts +229 -0
- package/src/engine/terminal-sessions.ts +280 -0
- package/src/engine/tunnel-discovery.ts +353 -0
- package/src/engine/tunnel-remarks.ts +120 -0
- package/src/engine/tunnel.ts +300 -0
- package/src/engine.ts +195 -0
- package/src/http.ts +127 -0
- package/src/index.ts +690 -0
- package/src/inspect/checks.ts +251 -0
- package/src/inspect/inspection.ts +321 -0
- package/src/inspect/tools.ts +366 -0
- package/src/logs/search.ts +251 -0
- package/src/logs/tools.ts +160 -0
- package/src/loopback.ts +119 -0
- package/src/monitor/loop.ts +265 -0
- package/src/monitor/metrics.ts +333 -0
- package/src/mount-once.ts +142 -0
- package/src/protocol.ts +534 -0
- package/src/routes.ts +998 -0
- package/src/security/known-hosts.ts +342 -0
- package/src/security/master-secret.ts +334 -0
- package/src/security/redact.ts +119 -0
- package/src/security/secrets.ts +152 -0
- package/src/ssh-config.ts +182 -0
- package/src/store.ts +757 -0
- package/src/tool-surface.ts +96 -0
- package/src/tools.ts +550 -0
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract between the host half (routes.ts) and the browser half
|
|
3
|
+
* (client/api.ts). Pure types only — imported by both halves, bundled into
|
|
4
|
+
* each, no runtime identity to share.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Authentication flavors a host entry may carry.
|
|
9
|
+
*
|
|
10
|
+
* `none` is a real OpenSSH method (`PreferredAuthentications none`): some
|
|
11
|
+
* sandboxes authenticate by username alone and reject any credential. Refusing
|
|
12
|
+
* to connect without a stored secret would make such a host permanently
|
|
13
|
+
* unreachable even though plain `ssh <alias>` works.
|
|
14
|
+
*/
|
|
15
|
+
export type SshAuthKind = 'key' | 'password' | 'agent' | 'none'
|
|
16
|
+
|
|
17
|
+
/** One stored host entry (the $DSH_HOME/dsh-ssh.json store shape). */
|
|
18
|
+
export interface SshHostEntry {
|
|
19
|
+
/** Stable, user-chosen identifier used by every operation. */
|
|
20
|
+
alias: string
|
|
21
|
+
/** Hostname or IP of the target. */
|
|
22
|
+
host: string
|
|
23
|
+
/** SSH port (default 22). */
|
|
24
|
+
port: number
|
|
25
|
+
/** Login user. */
|
|
26
|
+
user: string
|
|
27
|
+
/** Authentication. */
|
|
28
|
+
auth: {
|
|
29
|
+
kind: SshAuthKind
|
|
30
|
+
/** Absolute path to the private key for 'key' auth. */
|
|
31
|
+
keyPath?: string
|
|
32
|
+
/**
|
|
33
|
+
* Every candidate key, in ssh_config order. OpenSSH tries each
|
|
34
|
+
* `IdentityFile` until one authenticates, so a host configured with two
|
|
35
|
+
* keys must not be reduced to the last one — that turns a working
|
|
36
|
+
* `ssh <alias>` into "All configured authentication methods failed".
|
|
37
|
+
* `keyPath` stays the primary (first) candidate for older readers.
|
|
38
|
+
*/
|
|
39
|
+
keyPaths?: string[]
|
|
40
|
+
/** Passphrase for an encrypted key. */
|
|
41
|
+
passphrase?: string
|
|
42
|
+
/** Password for 'password' auth. */
|
|
43
|
+
password?: string
|
|
44
|
+
/**
|
|
45
|
+
* ssh-agent endpoint for 'agent' auth. A socket path, the special value
|
|
46
|
+
* 'pageant' (PuTTY Pageant on Windows), or undefined for auto-detect
|
|
47
|
+
* (SSH_AUTH_SOCK, then the native OpenSSH named pipe on Windows).
|
|
48
|
+
*/
|
|
49
|
+
agentPath?: string
|
|
50
|
+
}
|
|
51
|
+
/** Jump chain: local aliases connected through in order (ProxyJump). */
|
|
52
|
+
proxyJump: string[]
|
|
53
|
+
/**
|
|
54
|
+
* OpenSSH-compatible ProxyCommand: a shell command whose stdio becomes the
|
|
55
|
+
* connection transport. Tokens %h (host) / %p (port) / %r (user) / %n (alias)
|
|
56
|
+
* expand before exec and %% is a literal percent; an empty value or 'none'
|
|
57
|
+
* means "no proxy command". Mutually exclusive with a non-empty proxyJump.
|
|
58
|
+
*/
|
|
59
|
+
proxyCommand?: string
|
|
60
|
+
/** Free-form note. */
|
|
61
|
+
description?: string
|
|
62
|
+
/** Deployment environment label (development / production / ...). */
|
|
63
|
+
environment?: string
|
|
64
|
+
/** Free-form tags. */
|
|
65
|
+
tags: string[]
|
|
66
|
+
/** Physical location note. */
|
|
67
|
+
location?: string
|
|
68
|
+
/**
|
|
69
|
+
* Opt-in ssh-agent forwarding (OpenSSH ForwardAgent / ssh -A): the host's
|
|
70
|
+
* sessions request agent forwarding so the remote can sign with this
|
|
71
|
+
* machine's agent. Default off; stored only when enabled.
|
|
72
|
+
*/
|
|
73
|
+
forwardAgent?: boolean
|
|
74
|
+
createdAt: number
|
|
75
|
+
updatedAt: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Public (secret-free) projection of an entry, safe for the browser/agent. */
|
|
79
|
+
export interface SshHostSummary {
|
|
80
|
+
alias: string
|
|
81
|
+
host: string
|
|
82
|
+
port: number
|
|
83
|
+
user: string
|
|
84
|
+
auth: SshAuthKind
|
|
85
|
+
/** Whether the key path exists on the host machine (key auth only). */
|
|
86
|
+
keyReady: boolean
|
|
87
|
+
proxyJump: string[]
|
|
88
|
+
/** Configured ProxyCommand, echoed to the browser so the form can edit it. */
|
|
89
|
+
proxyCommand?: string
|
|
90
|
+
description?: string
|
|
91
|
+
environment?: string
|
|
92
|
+
tags: string[]
|
|
93
|
+
location?: string
|
|
94
|
+
/**
|
|
95
|
+
* Whether agent forwarding is enabled. Always projected as a definite
|
|
96
|
+
* boolean: the browser and the tool bridge need a value even for entries
|
|
97
|
+
* stored before the feature existed.
|
|
98
|
+
*/
|
|
99
|
+
forwardAgent: boolean
|
|
100
|
+
createdAt: number
|
|
101
|
+
updatedAt: number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Result of one non-interactive command execution. */
|
|
105
|
+
export interface ExecResult {
|
|
106
|
+
success: boolean
|
|
107
|
+
/** Remote exit code, or null when the channel died without one. */
|
|
108
|
+
exitCode: number | null
|
|
109
|
+
timedOut: boolean
|
|
110
|
+
stdout: string
|
|
111
|
+
stderr: string
|
|
112
|
+
/** Wall-clock duration of the round trip in ms. */
|
|
113
|
+
durationMs: number
|
|
114
|
+
/** Connection error message when the command never ran. */
|
|
115
|
+
error?: string
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** One server entry in a cluster run. */
|
|
119
|
+
export interface ClusterResult {
|
|
120
|
+
alias: string
|
|
121
|
+
ok: boolean
|
|
122
|
+
exitCode?: number | null
|
|
123
|
+
timedOut?: boolean
|
|
124
|
+
stdout?: string
|
|
125
|
+
stderr?: string
|
|
126
|
+
durationMs?: number
|
|
127
|
+
error?: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** SFTP transfer progress frame (upload stream). */
|
|
131
|
+
export interface TransferProgress {
|
|
132
|
+
phase: 'connecting' | 'transferring' | 'done' | 'error'
|
|
133
|
+
file: string
|
|
134
|
+
transferred: number
|
|
135
|
+
total: number
|
|
136
|
+
percent: number
|
|
137
|
+
speedBps?: number
|
|
138
|
+
error?: string
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* One active local port-forward.
|
|
143
|
+
*
|
|
144
|
+
* `source` distinguishes a forward this plugin owns from one that already
|
|
145
|
+
* exists on the machine (`ssh -N -L …` started by hand or by another tool).
|
|
146
|
+
* Listing only our own forwards made a running tunnel look absent; the
|
|
147
|
+
* external row is read-only because the process is not ours to kill.
|
|
148
|
+
*/
|
|
149
|
+
export interface TunnelInfo {
|
|
150
|
+
id: string
|
|
151
|
+
alias: string
|
|
152
|
+
localPort: number
|
|
153
|
+
remoteHost: string
|
|
154
|
+
remotePort: number
|
|
155
|
+
state: 'forwarding' | 'connecting' | 'failed'
|
|
156
|
+
error?: string
|
|
157
|
+
startedAt: number
|
|
158
|
+
/** Who owns the listener. Absent means 'plugin' (older shape). */
|
|
159
|
+
source?: 'plugin' | 'external'
|
|
160
|
+
/** Owning OS process for an external forward. */
|
|
161
|
+
pid?: number
|
|
162
|
+
/** True when the local port actually accepts connections right now. */
|
|
163
|
+
live?: boolean
|
|
164
|
+
/** The ssh option that created it ('-L', '-R' or '-D'), external forwards only. */
|
|
165
|
+
kind?: 'local' | 'remote' | 'dynamic'
|
|
166
|
+
/** Project or service name (e.g. from forwards.conf or user remark). */
|
|
167
|
+
name?: string
|
|
168
|
+
/** Remarks / note about what project or service this tunnel serves. */
|
|
169
|
+
description?: string
|
|
170
|
+
/**
|
|
171
|
+
* True when the name/description came from a stored user remark rather than
|
|
172
|
+
* `~/.ssh/forwards.conf`. The panel marks these so a stale automatic name is
|
|
173
|
+
* not mistaken for one the operator typed.
|
|
174
|
+
*/
|
|
175
|
+
customRemark?: boolean
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* One ssh_config host that the store does not contain yet.
|
|
180
|
+
*
|
|
181
|
+
* The panel shows these so "import" is a decision about visible hosts rather
|
|
182
|
+
* than a button whose only feedback is a count.
|
|
183
|
+
*/
|
|
184
|
+
export interface LocalConfigHost {
|
|
185
|
+
alias: string
|
|
186
|
+
host: string
|
|
187
|
+
port: number
|
|
188
|
+
user: string
|
|
189
|
+
/** What the store would use if this host were imported. */
|
|
190
|
+
auth: SshAuthKind
|
|
191
|
+
/** True when the block cannot be imported as-is (wildcard / Match). */
|
|
192
|
+
skippedReason?: ImportSkipReason
|
|
193
|
+
/** Host description (e.g. from comments preceding the Host block). */
|
|
194
|
+
description?: string
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** One directory listing entry (remote file browser). */
|
|
198
|
+
export interface RemoteDirEntry {
|
|
199
|
+
name: string
|
|
200
|
+
type: 'dir' | 'file' | 'other'
|
|
201
|
+
size: number
|
|
202
|
+
mtimeMs: number
|
|
203
|
+
mode?: number
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Test-connection outcome. */
|
|
207
|
+
export interface TestResult {
|
|
208
|
+
ok: boolean
|
|
209
|
+
latencyMs?: number
|
|
210
|
+
error?: string
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Host edit payload (create/update); 'alias' comes from the URL for updates. */
|
|
214
|
+
export interface HostPayload {
|
|
215
|
+
alias?: string
|
|
216
|
+
host: string
|
|
217
|
+
port?: number
|
|
218
|
+
user: string
|
|
219
|
+
/**
|
|
220
|
+
* Authentication. Required on create; on update an omitted auth keeps the
|
|
221
|
+
* stored secrets (the browser never receives them back).
|
|
222
|
+
*/
|
|
223
|
+
auth?: SshHostEntry['auth']
|
|
224
|
+
proxyJump?: string[]
|
|
225
|
+
/**
|
|
226
|
+
* ProxyCommand to store. An empty string or 'none' clears a stored value;
|
|
227
|
+
* omitting the key leaves it untouched (PATCH semantics).
|
|
228
|
+
*/
|
|
229
|
+
proxyCommand?: string
|
|
230
|
+
description?: string
|
|
231
|
+
environment?: string
|
|
232
|
+
tags?: string[]
|
|
233
|
+
location?: string
|
|
234
|
+
/**
|
|
235
|
+
* Agent forwarding for this host. Omitted on update keeps the stored value;
|
|
236
|
+
* false clears it (PATCH semantics).
|
|
237
|
+
*/
|
|
238
|
+
forwardAgent?: boolean
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Why one ssh_config Host block was not imported. */
|
|
242
|
+
export type ImportSkipReason = 'wildcard' | 'existing' | 'match' | 'invalid'
|
|
243
|
+
|
|
244
|
+
/** One skipped ssh_config block and the reason it could not be imported. */
|
|
245
|
+
export interface ImportSkipBlock {
|
|
246
|
+
/** Host pattern (or '`Match …`' label) that was skipped. */
|
|
247
|
+
name: string
|
|
248
|
+
reason: ImportSkipReason
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Import outcome from ~/.ssh/config. */
|
|
252
|
+
export interface ImportResult {
|
|
253
|
+
parsed: number
|
|
254
|
+
added: number
|
|
255
|
+
/**
|
|
256
|
+
* Existing hosts whose stored shape was corrected from the config — a host
|
|
257
|
+
* that gained a second candidate key, or one switched to `none` auth. An
|
|
258
|
+
* "add-only" import cannot repair those, and reporting them as merely
|
|
259
|
+
* "existing" is what makes a broken host look already imported.
|
|
260
|
+
*/
|
|
261
|
+
updated: number
|
|
262
|
+
skipped: number
|
|
263
|
+
/** Every skipped block with its reason, in scan order and deduplicated by name. */
|
|
264
|
+
skippedBlocks: ImportSkipBlock[]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** JSON error body used by every route. */
|
|
268
|
+
export interface ApiErrorBody {
|
|
269
|
+
error: string
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** WebSocket terminal protocol frames (host -> client and client -> host). */
|
|
273
|
+
export type TerminalServerFrame =
|
|
274
|
+
/** The shell is up; `sessionId` reattaches to it after a view detach. */
|
|
275
|
+
| { type: 'ready'; alias: string; sessionId: string }
|
|
276
|
+
| { type: 'output'; data: string }
|
|
277
|
+
| { type: 'exit'; code: number | null; error?: string }
|
|
278
|
+
| {
|
|
279
|
+
type: 'auth_prompt'
|
|
280
|
+
name: string
|
|
281
|
+
instructions: string
|
|
282
|
+
prompts: Array<{ prompt: string; echo: boolean }>
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export type TerminalClientFrame =
|
|
286
|
+
| { type: 'input'; data: string }
|
|
287
|
+
| { type: 'resize'; cols: number; rows: number }
|
|
288
|
+
| { type: 'auth_response'; responses: string[] }
|
|
289
|
+
/** Leave the socket while the host keeps the shell alive for a reattach. */
|
|
290
|
+
| { type: 'detach' }
|
|
291
|
+
/** End the session outright (the view's disconnect control). */
|
|
292
|
+
| { type: 'close' }
|
|
293
|
+
|
|
294
|
+
// ---------------------------------------------------------- monitoring faces
|
|
295
|
+
//
|
|
296
|
+
// These mirror the shapes the monitoring routes return. They are declared
|
|
297
|
+
// here rather than in the client so the host's route handlers and the
|
|
298
|
+
// panel's readers agree on one definition — a display change that renames a
|
|
299
|
+
// field would otherwise silently blank a column instead of failing the build.
|
|
300
|
+
|
|
301
|
+
/** One check result as the panel reads it. */
|
|
302
|
+
export interface CheckResultRow {
|
|
303
|
+
checkId: string
|
|
304
|
+
alias: string
|
|
305
|
+
value: number | boolean | string | null
|
|
306
|
+
breached: boolean
|
|
307
|
+
raw: string
|
|
308
|
+
error?: string
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** One retained inspection round. */
|
|
312
|
+
export interface InspectionRound {
|
|
313
|
+
startedAt: number
|
|
314
|
+
durationMs: number
|
|
315
|
+
targets: string[]
|
|
316
|
+
results: CheckResultRow[]
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** One host's change between the two most recent rounds. */
|
|
320
|
+
export interface HostChange {
|
|
321
|
+
alias: string
|
|
322
|
+
checkId: string
|
|
323
|
+
title: string
|
|
324
|
+
before?: string
|
|
325
|
+
after: string
|
|
326
|
+
stateChange?: 'new-breach' | 'recovered'
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** The monitoring loop's health. */
|
|
330
|
+
export interface MonitorStatus {
|
|
331
|
+
enabled: boolean
|
|
332
|
+
running: boolean
|
|
333
|
+
intervalMs?: number
|
|
334
|
+
hosts?: number
|
|
335
|
+
lastRoundAt?: number
|
|
336
|
+
nextTickAt?: number
|
|
337
|
+
lastTick?: MonitorTickResult
|
|
338
|
+
reason?: string
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** One round's outcome as the loop recorded it. */
|
|
342
|
+
export interface MonitorTickResult {
|
|
343
|
+
at: number
|
|
344
|
+
ran: boolean
|
|
345
|
+
hosts: number
|
|
346
|
+
breaches: number
|
|
347
|
+
blind: number
|
|
348
|
+
skippedBecause?: string
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** One alert state row. */
|
|
352
|
+
export interface AlertStateRow {
|
|
353
|
+
ruleId: string
|
|
354
|
+
alias: string
|
|
355
|
+
state: 'ok' | 'pending' | 'firing' | 'frozen'
|
|
356
|
+
consecutiveBreaches?: number
|
|
357
|
+
lastValue?: string
|
|
358
|
+
lastFiredAt?: number
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** One alert event. */
|
|
362
|
+
export interface AlertEventRow {
|
|
363
|
+
ruleId: string
|
|
364
|
+
alias: string
|
|
365
|
+
kind: 'trigger' | 'recover'
|
|
366
|
+
value: string
|
|
367
|
+
at: number
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** One aggregated metric bucket. */
|
|
371
|
+
export interface MetricBucketRow {
|
|
372
|
+
at: number
|
|
373
|
+
metric: string
|
|
374
|
+
value: number | null
|
|
375
|
+
samples: number
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** The live security posture. */
|
|
379
|
+
export interface SecurityStatus {
|
|
380
|
+
encryptConfigured: boolean
|
|
381
|
+
secret: { available: boolean; source: 'env' | 'file' | 'none' }
|
|
382
|
+
hostKeyPolicy?: string
|
|
383
|
+
auditEnabled?: boolean
|
|
384
|
+
/** Entries whose stored credentials are still readable without the key. */
|
|
385
|
+
plaintextAliases?: string[]
|
|
386
|
+
/** The key file the panel manages (shown so the operator can back it up). */
|
|
387
|
+
keyPath?: string
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** One deployment step as the panel submits it. */
|
|
391
|
+
export interface DeployStepPayload {
|
|
392
|
+
name: string
|
|
393
|
+
command: string
|
|
394
|
+
/** Undo command. Required: a step without one cannot be rolled back. */
|
|
395
|
+
rollbackCommand: string
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** A deployment plan as the panel submits it. */
|
|
399
|
+
export interface DeployPlanPayload {
|
|
400
|
+
id: string
|
|
401
|
+
description?: string
|
|
402
|
+
steps: DeployStepPayload[]
|
|
403
|
+
batchSize?: number
|
|
404
|
+
timeoutMs?: number
|
|
405
|
+
stopOnFailure?: boolean
|
|
406
|
+
healthCheck?: { command: string; expectExitCode?: number; settleMs?: number }
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** A log-search request as the panel submits it. */
|
|
410
|
+
export interface LogSearchPayload {
|
|
411
|
+
pattern: string
|
|
412
|
+
source?: 'journal' | 'files'
|
|
413
|
+
directory?: string
|
|
414
|
+
unit?: string
|
|
415
|
+
sinceSeconds?: number
|
|
416
|
+
maxLinesPerHost?: number
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** One host's outcome inside a recorded deployment. */
|
|
420
|
+
export interface DeployHostRow {
|
|
421
|
+
alias: string
|
|
422
|
+
ok: boolean
|
|
423
|
+
/** Names of the steps that ran, in order (the orchestrator does not report them). */
|
|
424
|
+
steps: string[]
|
|
425
|
+
/** Health-check verdict, when the plan declared one. */
|
|
426
|
+
healthy?: boolean
|
|
427
|
+
/** Whether a rollback was attempted for this host. */
|
|
428
|
+
rolledBack?: boolean
|
|
429
|
+
/** The exit code of the last step. */
|
|
430
|
+
exitCode?: number | null
|
|
431
|
+
error?: string
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** One recorded deployment run, as the deploy tab reads it. */
|
|
435
|
+
export interface DeployRunRow {
|
|
436
|
+
id: string
|
|
437
|
+
planId: string
|
|
438
|
+
at: number
|
|
439
|
+
finishedAt?: number
|
|
440
|
+
/** The plan's batch size, so the UI can group hosts the way they ran. */
|
|
441
|
+
batchSize: number
|
|
442
|
+
hostCount: number
|
|
443
|
+
ok: boolean
|
|
444
|
+
hosts: DeployHostRow[]
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** One host's slice of a cross-host log search. */
|
|
448
|
+
export interface LogHostRow {
|
|
449
|
+
alias: string
|
|
450
|
+
ok: boolean
|
|
451
|
+
lines: string[]
|
|
452
|
+
total: number
|
|
453
|
+
truncated: boolean
|
|
454
|
+
error?: string
|
|
455
|
+
durationMs?: number
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** One cross-host log search result, as the logs tab reads it. */
|
|
459
|
+
export interface LogSearchRow {
|
|
460
|
+
at: number
|
|
461
|
+
pattern: string
|
|
462
|
+
source: string
|
|
463
|
+
/** 'all' or the selected aliases. */
|
|
464
|
+
targets: string[]
|
|
465
|
+
hosts: LogHostRow[]
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** Set or clear the master secret from the panel (interactive setup). */
|
|
469
|
+
export interface MasterSecretPayload {
|
|
470
|
+
/** New master secret. An empty string clears nothing; use action 'clear'. */
|
|
471
|
+
secret?: string
|
|
472
|
+
/** 'set' stores/rotates the secret, 'clear' removes it. */
|
|
473
|
+
action: 'set' | 'clear'
|
|
474
|
+
/** For 'clear': re-encrypt existing plaintext first (refused when false). */
|
|
475
|
+
confirmPlaintext?: boolean
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** Outcome of a master-secret change. */
|
|
479
|
+
export interface MasterSecretResult {
|
|
480
|
+
ok: boolean
|
|
481
|
+
/** Where the secret now comes from. */
|
|
482
|
+
source: 'env' | 'file' | 'none'
|
|
483
|
+
/** Entries re-encrypted by this call. */
|
|
484
|
+
rotated: number
|
|
485
|
+
/** Set when the change was refused or failed. */
|
|
486
|
+
error?: string
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** Route paths the client calls (shared literals). */
|
|
490
|
+
export const SSH_API_BASE = '/api/dsh-ssh' as const
|
|
491
|
+
|
|
492
|
+
export const SSH_API = {
|
|
493
|
+
hosts: SSH_API_BASE + '/hosts',
|
|
494
|
+
importSshConfig: SSH_API_BASE + '/hosts/import-ssh-config',
|
|
495
|
+
/** ssh_config hosts the store does not contain yet (read-only preview). */
|
|
496
|
+
localConfig: SSH_API_BASE + '/hosts/local-config',
|
|
497
|
+
test: SSH_API_BASE + '/test',
|
|
498
|
+
exec: SSH_API_BASE + '/exec',
|
|
499
|
+
cluster: SSH_API_BASE + '/cluster',
|
|
500
|
+
upload: SSH_API_BASE + '/upload',
|
|
501
|
+
download: SSH_API_BASE + '/download',
|
|
502
|
+
ls: SSH_API_BASE + '/ls',
|
|
503
|
+
tunnel: SSH_API_BASE + '/tunnel',
|
|
504
|
+
terminal: SSH_API_BASE + '/terminal',
|
|
505
|
+
/** The monitoring loop's health readout. */
|
|
506
|
+
monitor: SSH_API_BASE + '/monitor',
|
|
507
|
+
/** Manual round trigger, the same path the timer takes. */
|
|
508
|
+
monitorTick: SSH_API_BASE + '/monitor/tick',
|
|
509
|
+
/** Retained inspection rounds. */
|
|
510
|
+
inspection: SSH_API_BASE + '/inspection',
|
|
511
|
+
/** The change set between the two most recent rounds. */
|
|
512
|
+
inspectionDiff: SSH_API_BASE + '/inspection/diff',
|
|
513
|
+
/** Alert states and the recent event feed. */
|
|
514
|
+
alerts: SSH_API_BASE + '/alerts',
|
|
515
|
+
/** Metric series for one host and tier. */
|
|
516
|
+
metrics: SSH_API_BASE + '/metrics',
|
|
517
|
+
/** The live security posture. */
|
|
518
|
+
security: SSH_API_BASE + '/security',
|
|
519
|
+
/** Recorded deployment runs, newest first. */
|
|
520
|
+
deployHistory: SSH_API_BASE + '/deploy/history',
|
|
521
|
+
/** Run a deployment plan recorded into the history. */
|
|
522
|
+
deploy: SSH_API_BASE + '/deploy',
|
|
523
|
+
/** Cross-host log search, recorded into the history. */
|
|
524
|
+
logs: SSH_API_BASE + '/logs',
|
|
525
|
+
/** Recent log-search results, newest first. */
|
|
526
|
+
logsHistory: SSH_API_BASE + '/logs/history',
|
|
527
|
+
/** Store or clear the master secret from the panel. */
|
|
528
|
+
setSecret: SSH_API_BASE + '/security/secret',
|
|
529
|
+
} as const
|
|
530
|
+
|
|
531
|
+
/** NDJSON transfer stream line shapes (upload). */
|
|
532
|
+
export type TransferStreamLine =
|
|
533
|
+
| { type: 'progress'; progress: TransferProgress }
|
|
534
|
+
| { type: 'result'; ok: boolean; transferredBytes?: number; error?: string }
|