dsh-server-ops-agent 0.0.0-stage → 0.4.0-beta.5
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/DSH-Linux-/351/246/226/346/254/241/350/277/236/346/216/245.md +96 -0
- package/LICENSE +21 -0
- package/README.md +91 -2
- package/cordis.patch.yml +12 -0
- package/dist/client.js +4102 -0
- package/dist/plugin.d.ts +436 -0
- package/dist/plugin.js +18377 -0
- package/dist/server.js +5094 -0
- package/dist/workspace-tool.d.ts +362 -0
- package/dist/workspace-tool.js +1047 -0
- package/docs/distribution.md +75 -0
- package/docs/v0.4-migration-audit.md +53 -0
- package/generated/linux-release.json +28 -0
- package/generated/linux-release.sha256 +1 -0
- package/generated/linux-release.tgz +0 -0
- package/generated/ssh-licenses.txt +158 -0
- package/package.json +126 -4
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { Client, ClientChannel, ConnectConfig } from "ssh2";
|
|
3
|
+
|
|
4
|
+
declare const PROTOCOL_VERSION: 1;
|
|
5
|
+
declare const PACKAGE_NAME: "dsh-server-ops-agent";
|
|
6
|
+
declare const READ_VERBS: readonly ["service-info", "overview", "resource-history", "activity-list", "incident-detail", "report-detail", "agent-observations", "agent-record", "vault.status", "snapshot.list", "browse", "diff", "job.status", "job.list"];
|
|
7
|
+
declare const ADMIN_VERBS: readonly ["restore.preview", "restore", "snapshot.now", "vault.retry"];
|
|
8
|
+
type ReadVerb = (typeof READ_VERBS)[number];
|
|
9
|
+
type AdminVerb = (typeof ADMIN_VERBS)[number];
|
|
10
|
+
type RpcVerb = ReadVerb | AdminVerb;
|
|
11
|
+
declare const CAPABILITIES: readonly ["samples", "reports", "events", "workspace", "containers", "probes", "tls", "backup", "backup-restic", "backup-duplicity-legacy", "admin-jobs"];
|
|
12
|
+
type Capability = (typeof CAPABILITIES)[number];
|
|
13
|
+
type HealthState = 'ok' | 'warn' | 'bad' | 'unknown';
|
|
14
|
+
type BackupEngine = 'restic' | 'duplicity-legacy';
|
|
15
|
+
type VaultProvider = 'local' | 'baidu' | 'google-drive' | 's3' | 'rclone';
|
|
16
|
+
interface ServiceInfo {
|
|
17
|
+
service: typeof PACKAGE_NAME;
|
|
18
|
+
version: string;
|
|
19
|
+
protocolVersion: typeof PROTOCOL_VERSION;
|
|
20
|
+
node: string;
|
|
21
|
+
ok: true;
|
|
22
|
+
serverId?: string;
|
|
23
|
+
hostname?: string;
|
|
24
|
+
platform?: string;
|
|
25
|
+
arch?: string;
|
|
26
|
+
uptimeSec?: number;
|
|
27
|
+
capabilities?: Capability[];
|
|
28
|
+
profileHash?: string;
|
|
29
|
+
daemonStartedAt?: number;
|
|
30
|
+
}
|
|
31
|
+
interface DailyReportSummary {
|
|
32
|
+
id: string;
|
|
33
|
+
date: string;
|
|
34
|
+
generatedAt: number;
|
|
35
|
+
status: HealthState;
|
|
36
|
+
summaryLines: string[];
|
|
37
|
+
}
|
|
38
|
+
interface CpuMetricSummary {
|
|
39
|
+
load1: number;
|
|
40
|
+
load5: number;
|
|
41
|
+
load15: number;
|
|
42
|
+
cores: number;
|
|
43
|
+
loadPerCpu: number;
|
|
44
|
+
status: HealthState;
|
|
45
|
+
sparkline?: number[];
|
|
46
|
+
}
|
|
47
|
+
interface MemoryMetricSummary {
|
|
48
|
+
totalBytes: number;
|
|
49
|
+
availableBytes: number;
|
|
50
|
+
usedPct: number;
|
|
51
|
+
availPct: number;
|
|
52
|
+
swapUsedPct?: number;
|
|
53
|
+
status: HealthState;
|
|
54
|
+
sparkline?: number[];
|
|
55
|
+
}
|
|
56
|
+
interface MountMetricSummary {
|
|
57
|
+
mount: string;
|
|
58
|
+
device?: string;
|
|
59
|
+
stDev?: number | null;
|
|
60
|
+
totalBytes: number;
|
|
61
|
+
usedBytes: number;
|
|
62
|
+
availBytes: number;
|
|
63
|
+
usedPct: number;
|
|
64
|
+
inodePct?: number;
|
|
65
|
+
thresholdPct: number;
|
|
66
|
+
delta24hBytes: number | null;
|
|
67
|
+
estimatedDaysLeft: number | null;
|
|
68
|
+
lowConfidence?: boolean;
|
|
69
|
+
status: HealthState;
|
|
70
|
+
sparkline?: number[];
|
|
71
|
+
}
|
|
72
|
+
interface FailedUnitSummary {
|
|
73
|
+
unit: string;
|
|
74
|
+
loadState: string;
|
|
75
|
+
activeState: string;
|
|
76
|
+
subState: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
sinceTs?: number;
|
|
79
|
+
}
|
|
80
|
+
interface TlsCertSummary {
|
|
81
|
+
host: string;
|
|
82
|
+
port?: number;
|
|
83
|
+
expiresAt: number;
|
|
84
|
+
daysLeft: number;
|
|
85
|
+
issuer?: string;
|
|
86
|
+
status: HealthState;
|
|
87
|
+
}
|
|
88
|
+
interface SecurityMetricSummary {
|
|
89
|
+
sshFailures24h: number;
|
|
90
|
+
sshFailures5m: number;
|
|
91
|
+
sshHourly24h: number[];
|
|
92
|
+
failedUnits: FailedUnitSummary[];
|
|
93
|
+
certs: TlsCertSummary[];
|
|
94
|
+
status: HealthState;
|
|
95
|
+
}
|
|
96
|
+
interface ContainerStatus {
|
|
97
|
+
name: string;
|
|
98
|
+
label?: string;
|
|
99
|
+
image?: string;
|
|
100
|
+
state: 'running' | 'restarting' | 'exited' | 'paused' | 'dead' | 'missing' | 'unknown';
|
|
101
|
+
health?: 'healthy' | 'unhealthy' | 'starting' | 'none';
|
|
102
|
+
uptimeSec?: number;
|
|
103
|
+
restartCount?: number;
|
|
104
|
+
restartDelta24h?: number;
|
|
105
|
+
status: HealthState;
|
|
106
|
+
}
|
|
107
|
+
interface HttpProbeStatus {
|
|
108
|
+
id: string;
|
|
109
|
+
label?: string;
|
|
110
|
+
url: string;
|
|
111
|
+
statusCode: number | null;
|
|
112
|
+
latencyMs: number | null;
|
|
113
|
+
checkedAt: number;
|
|
114
|
+
status: HealthState;
|
|
115
|
+
error?: string;
|
|
116
|
+
}
|
|
117
|
+
interface SupervisorCheckStatus {
|
|
118
|
+
id: string;
|
|
119
|
+
label: string;
|
|
120
|
+
runningPrograms: string[];
|
|
121
|
+
stoppedPrograms: string[];
|
|
122
|
+
lastTaskAgeSec?: number | null;
|
|
123
|
+
checkedAt: number;
|
|
124
|
+
status: HealthState;
|
|
125
|
+
detail?: string;
|
|
126
|
+
}
|
|
127
|
+
interface ExternalProbeStatus {
|
|
128
|
+
id: string;
|
|
129
|
+
label: string;
|
|
130
|
+
signal: string;
|
|
131
|
+
observedAt: number | null;
|
|
132
|
+
stale: boolean;
|
|
133
|
+
status: HealthState;
|
|
134
|
+
summary?: string;
|
|
135
|
+
facts?: Record<string, unknown>;
|
|
136
|
+
}
|
|
137
|
+
interface BackupCopySummary {
|
|
138
|
+
vaultId: string;
|
|
139
|
+
code: 'L' | 'B' | 'G' | 'R';
|
|
140
|
+
label: string;
|
|
141
|
+
provider: VaultProvider;
|
|
142
|
+
status: HealthState;
|
|
143
|
+
lastSuccessAt: number | null;
|
|
144
|
+
}
|
|
145
|
+
interface BackupOverviewSummary {
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
status: HealthState;
|
|
148
|
+
engine: BackupEngine | 'none';
|
|
149
|
+
lastSnapshotAt: number | null;
|
|
150
|
+
lastSnapshotId?: string;
|
|
151
|
+
copyStates: BackupCopySummary[];
|
|
152
|
+
headline: string;
|
|
153
|
+
}
|
|
154
|
+
interface OverviewResponse {
|
|
155
|
+
serverId: string;
|
|
156
|
+
hostname: string;
|
|
157
|
+
collectedAt: number;
|
|
158
|
+
stale: boolean;
|
|
159
|
+
offlineCache?: boolean;
|
|
160
|
+
cachedAt?: number;
|
|
161
|
+
health: {
|
|
162
|
+
status: HealthState;
|
|
163
|
+
headline: string;
|
|
164
|
+
activeIncidents: number;
|
|
165
|
+
unreadAlerts: number;
|
|
166
|
+
};
|
|
167
|
+
todayReport?: DailyReportSummary;
|
|
168
|
+
metrics: {
|
|
169
|
+
cpu: CpuMetricSummary;
|
|
170
|
+
memory: MemoryMetricSummary;
|
|
171
|
+
mounts: MountMetricSummary[];
|
|
172
|
+
security: SecurityMetricSummary;
|
|
173
|
+
};
|
|
174
|
+
services: {
|
|
175
|
+
containers: ContainerStatus[];
|
|
176
|
+
httpProbes: HttpProbeStatus[];
|
|
177
|
+
supervisors: SupervisorCheckStatus[];
|
|
178
|
+
externalProbes: ExternalProbeStatus[];
|
|
179
|
+
};
|
|
180
|
+
backupSummary: BackupOverviewSummary;
|
|
181
|
+
capabilities: Capability[];
|
|
182
|
+
}
|
|
183
|
+
interface DeployProbeResult {
|
|
184
|
+
host: string;
|
|
185
|
+
osId: string;
|
|
186
|
+
osVersion: string;
|
|
187
|
+
arch: string;
|
|
188
|
+
hasSystemd: boolean;
|
|
189
|
+
sudoNonInteractive: boolean;
|
|
190
|
+
systemNodeVersion: string | null;
|
|
191
|
+
bundledNodeInstalled: boolean;
|
|
192
|
+
bundledNodeVersion: string | null;
|
|
193
|
+
installedServiceVersion: string | null;
|
|
194
|
+
serviceActive: boolean;
|
|
195
|
+
python3Version: string | null;
|
|
196
|
+
hasNcUnixSocket: boolean;
|
|
197
|
+
resticVersion: string | null;
|
|
198
|
+
rootAvailBytes: number | null;
|
|
199
|
+
readyToInstall: boolean;
|
|
200
|
+
warnings: string[];
|
|
201
|
+
}
|
|
202
|
+
interface DeployStatusResult {
|
|
203
|
+
installed: boolean;
|
|
204
|
+
active: boolean;
|
|
205
|
+
version: string | null;
|
|
206
|
+
protocolVersion: number | null;
|
|
207
|
+
serverId: string | null;
|
|
208
|
+
readSocketReady: boolean;
|
|
209
|
+
adminSocketReady: boolean;
|
|
210
|
+
jobRunnerReady: boolean;
|
|
211
|
+
capabilities: Capability[];
|
|
212
|
+
}
|
|
213
|
+
interface SshEndpointConfig {
|
|
214
|
+
host: string;
|
|
215
|
+
port: number;
|
|
216
|
+
user: string;
|
|
217
|
+
fingerprint: string;
|
|
218
|
+
keyPath: string;
|
|
219
|
+
}
|
|
220
|
+
interface HostFingerprintResult {
|
|
221
|
+
host: string;
|
|
222
|
+
port: number;
|
|
223
|
+
fingerprint: string;
|
|
224
|
+
keyType: string;
|
|
225
|
+
}
|
|
226
|
+
interface WorkspaceTarget {
|
|
227
|
+
host: string;
|
|
228
|
+
serverId: string;
|
|
229
|
+
capabilities?: Capability[];
|
|
230
|
+
}
|
|
231
|
+
interface DeployConnectionInput {
|
|
232
|
+
host: string;
|
|
233
|
+
port?: number;
|
|
234
|
+
user?: string;
|
|
235
|
+
username?: string;
|
|
236
|
+
fingerprint?: string;
|
|
237
|
+
hostKeySha256?: string;
|
|
238
|
+
keyPath?: string;
|
|
239
|
+
}
|
|
240
|
+
interface DeployInstallOptions {
|
|
241
|
+
grantAdmin?: boolean;
|
|
242
|
+
bootstrapNode22?: boolean;
|
|
243
|
+
upgrade?: boolean;
|
|
244
|
+
}
|
|
245
|
+
interface DeployProbeExtendedResult extends DeployProbeResult {
|
|
246
|
+
detected?: {
|
|
247
|
+
docker: boolean;
|
|
248
|
+
caddy: boolean;
|
|
249
|
+
mounts: string[];
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
interface DeployInstallOutcome {
|
|
253
|
+
ok: true;
|
|
254
|
+
serverId: string;
|
|
255
|
+
host: string;
|
|
256
|
+
version: string;
|
|
257
|
+
reconnected: true;
|
|
258
|
+
grantedGroups: string[];
|
|
259
|
+
serviceInfo: ServiceInfo;
|
|
260
|
+
overview: OverviewResponse | null;
|
|
261
|
+
}
|
|
262
|
+
interface PluginRuntimeBridge {
|
|
263
|
+
workspaceTarget(cwd: string | undefined): WorkspaceTarget | null;
|
|
264
|
+
getServerConfig(serverId: string): SshEndpointConfig | null;
|
|
265
|
+
daemon<T = unknown>(action: RpcVerb, data?: Record<string, unknown>, serverId?: string): Promise<T>;
|
|
266
|
+
probeHostFingerprint(host: string, port?: number): Promise<HostFingerprintResult>;
|
|
267
|
+
deployProbe(input: DeployConnectionInput): Promise<DeployProbeExtendedResult>;
|
|
268
|
+
deployInstall(input: DeployConnectionInput, options?: DeployInstallOptions): Promise<DeployInstallOutcome>;
|
|
269
|
+
deployStatus(input: DeployConnectionInput): Promise<DeployStatusResult>;
|
|
270
|
+
}
|
|
271
|
+
declare const SSH_IDLE_TIMEOUT_MS: number;
|
|
272
|
+
interface SshClientLike {
|
|
273
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
274
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
275
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
|
276
|
+
connect(config: ConnectConfig): void;
|
|
277
|
+
exec(command: string, callback: (err: Error | undefined, channel: ClientChannel) => void): void;
|
|
278
|
+
end(): void;
|
|
279
|
+
destroy(): void;
|
|
280
|
+
}
|
|
281
|
+
type SshClientFactory = () => SshClientLike;
|
|
282
|
+
type SshAuthEntry = {
|
|
283
|
+
type: 'agent';
|
|
284
|
+
username: string;
|
|
285
|
+
agent: string;
|
|
286
|
+
} | {
|
|
287
|
+
type: 'publickey';
|
|
288
|
+
username: string;
|
|
289
|
+
key: Buffer | string;
|
|
290
|
+
};
|
|
291
|
+
interface SshConnectionOptions {
|
|
292
|
+
clientFactory?: SshClientFactory;
|
|
293
|
+
idleTimeoutMs?: number;
|
|
294
|
+
keepaliveIntervalMs?: number;
|
|
295
|
+
readyTimeoutMs?: number;
|
|
296
|
+
requestTimeoutMs?: number;
|
|
297
|
+
maxConcurrentExecs?: number;
|
|
298
|
+
authResolver?: (config: SshEndpointConfig) => Promise<SshAuthEntry[]>;
|
|
299
|
+
}
|
|
300
|
+
declare function createSshClient(): Client;
|
|
301
|
+
interface RunCommandResult {
|
|
302
|
+
code: number | null;
|
|
303
|
+
output: string;
|
|
304
|
+
stderr: string;
|
|
305
|
+
}
|
|
306
|
+
declare class SshConnection {
|
|
307
|
+
readonly config: SshEndpointConfig;
|
|
308
|
+
lastConnectedAt: number | null;
|
|
309
|
+
verified: Promise<unknown> | null;
|
|
310
|
+
private readonly clientFactory;
|
|
311
|
+
private readonly usesCustomFactory;
|
|
312
|
+
private readonly idleTimeoutMs;
|
|
313
|
+
private readonly keepaliveIntervalMs;
|
|
314
|
+
private readonly readyTimeoutMs;
|
|
315
|
+
private readonly requestTimeoutMs;
|
|
316
|
+
private readonly maxConcurrentExecs;
|
|
317
|
+
private readonly authResolver;
|
|
318
|
+
private client;
|
|
319
|
+
private connecting;
|
|
320
|
+
private idleTimer;
|
|
321
|
+
private pending;
|
|
322
|
+
private activeExecs;
|
|
323
|
+
private execWaiters;
|
|
324
|
+
private closed;
|
|
325
|
+
constructor(config: SshEndpointConfig, options?: SshConnectionOptions);
|
|
326
|
+
get isConnected(): boolean;
|
|
327
|
+
private connect;
|
|
328
|
+
request<T = unknown>(action: RpcVerb, data?: Record<string, unknown>): Promise<T>;
|
|
329
|
+
private acquireExecSlot;
|
|
330
|
+
private releaseExecSlot;
|
|
331
|
+
run(command: string, input: string | Buffer, timeoutMs: number, limitBytes: number): Promise<RunCommandResult>;
|
|
332
|
+
private exec;
|
|
333
|
+
/**
|
|
334
|
+
* Disconnect the underlying SSH transport without marking this wrapper closed.
|
|
335
|
+
* Subsequent requests will establish a fresh SSH session (e.g. after usermod -aG).
|
|
336
|
+
*/
|
|
337
|
+
disconnect(): void;
|
|
338
|
+
close(): void;
|
|
339
|
+
}
|
|
340
|
+
interface DshLlmContextLike {
|
|
341
|
+
get?: (serviceName: string) => unknown;
|
|
342
|
+
}
|
|
343
|
+
interface ReleaseAssetInfo {
|
|
344
|
+
version: string;
|
|
345
|
+
digest: string;
|
|
346
|
+
bytes: number;
|
|
347
|
+
archivePath: string;
|
|
348
|
+
}
|
|
349
|
+
interface DeployDependencies {
|
|
350
|
+
connectionFactory?: (config: SshEndpointConfig) => SshConnection;
|
|
351
|
+
connectionOptions?: SshConnectionOptions;
|
|
352
|
+
releaseLoader?: () => Promise<{
|
|
353
|
+
info: ReleaseAssetInfo;
|
|
354
|
+
archive: Buffer;
|
|
355
|
+
}>;
|
|
356
|
+
onInstalled?: (result: {
|
|
357
|
+
config: SshEndpointConfig;
|
|
358
|
+
serviceInfo: ServiceInfo;
|
|
359
|
+
overview: OverviewResponse | null;
|
|
360
|
+
client: SshConnection;
|
|
361
|
+
}) => Promise<void>;
|
|
362
|
+
}
|
|
363
|
+
interface WorkspaceServicesLike {
|
|
364
|
+
workspaceRegistry: {
|
|
365
|
+
create(cwd: string, label: string): Promise<{
|
|
366
|
+
id: string;
|
|
367
|
+
}>;
|
|
368
|
+
};
|
|
369
|
+
agents?: {
|
|
370
|
+
get(sessionId: string): {
|
|
371
|
+
session: {
|
|
372
|
+
header: {
|
|
373
|
+
cwd?: string;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
model?: {
|
|
377
|
+
select(selection: {
|
|
378
|
+
provider: string;
|
|
379
|
+
model: string;
|
|
380
|
+
}): void;
|
|
381
|
+
};
|
|
382
|
+
} | undefined;
|
|
383
|
+
};
|
|
384
|
+
agentPresets?: {
|
|
385
|
+
presetForSession(session: {
|
|
386
|
+
header: {
|
|
387
|
+
cwd?: string;
|
|
388
|
+
};
|
|
389
|
+
}): string | undefined;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
declare const name = "server-operations";
|
|
393
|
+
declare const version: "0.4.0-beta.5";
|
|
394
|
+
declare const protocolVersion: 1;
|
|
395
|
+
interface ApiRequestLike {
|
|
396
|
+
method?: string;
|
|
397
|
+
headers: Record<string, string | string[] | undefined>;
|
|
398
|
+
socket: {
|
|
399
|
+
remoteAddress?: string;
|
|
400
|
+
encrypted?: boolean;
|
|
401
|
+
};
|
|
402
|
+
setEncoding?: (encoding: BufferEncoding) => void;
|
|
403
|
+
[Symbol.asyncIterator](): AsyncIterator<string | Buffer>;
|
|
404
|
+
}
|
|
405
|
+
interface ApiResponseLike {
|
|
406
|
+
headersSent?: boolean;
|
|
407
|
+
writeHead(status: number, headers?: Record<string, string>): this;
|
|
408
|
+
end(body?: string): void;
|
|
409
|
+
}
|
|
410
|
+
interface ConnectionServiceLike {
|
|
411
|
+
browserPeer: unknown;
|
|
412
|
+
admit(req: ApiRequestLike): {
|
|
413
|
+
peer?: unknown;
|
|
414
|
+
} | null | undefined;
|
|
415
|
+
}
|
|
416
|
+
interface WebServerServiceLike {
|
|
417
|
+
register(route: {
|
|
418
|
+
kind: 'exact';
|
|
419
|
+
path: string;
|
|
420
|
+
handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
421
|
+
}): () => void;
|
|
422
|
+
}
|
|
423
|
+
interface PluginContext extends DshLlmContextLike {
|
|
424
|
+
inject?: (services: string[], callback: (app: any) => void | (() => void)) => void;
|
|
425
|
+
}
|
|
426
|
+
declare function matchesWorkbench(req: Pick<ApiRequestLike, 'headers' | 'socket'>): boolean;
|
|
427
|
+
declare function createDefaultRuntimeBridge(deployDeps?: DeployDependencies): PluginRuntimeBridge;
|
|
428
|
+
interface ApiHandlerDeps {
|
|
429
|
+
connection: ConnectionServiceLike;
|
|
430
|
+
ctx?: DshLlmContextLike;
|
|
431
|
+
getWorkspaceServices?: () => WorkspaceServicesLike | undefined;
|
|
432
|
+
bridge?: PluginRuntimeBridge;
|
|
433
|
+
}
|
|
434
|
+
declare function createApiHandler(deps: ApiHandlerDeps): (req: ApiRequestLike, res: ApiResponseLike) => Promise<void>;
|
|
435
|
+
declare function apply(ctx: PluginContext): void;
|
|
436
|
+
export { ApiHandlerDeps, ApiRequestLike, ApiResponseLike, ConnectionServiceLike, PluginContext, SSH_IDLE_TIMEOUT_MS, WebServerServiceLike, apply, createApiHandler, createDefaultRuntimeBridge, createSshClient, matchesWorkbench, name, protocolVersion, version };
|