dsh-server-ops-agent 0.3.0-beta.1 → 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 +79 -16
- package/README.md +79 -19
- package/cordis.patch.yml +1 -1
- 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 +26 -3
- package/generated/linux-release.sha256 +1 -0
- package/generated/linux-release.tgz +0 -0
- package/generated/ssh-licenses.txt +5 -8
- package/package.json +93 -29
- package/client.js +0 -640
- package/connection-protocol.js +0 -7
- package/connections.js +0 -213
- package/deployment.js +0 -93
- package/generated/ssh-client.cjs +0 -20120
- package/native-workspace.js +0 -75
- package/plugin.js +0 -140
- package/ssh-client.js +0 -182
- package/workspace-tool.js +0 -21
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
declare const PROTOCOL_VERSION: 1;
|
|
2
|
+
declare const PACKAGE_NAME: "dsh-server-ops-agent";
|
|
3
|
+
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"];
|
|
4
|
+
declare const ADMIN_VERBS: readonly ["restore.preview", "restore", "snapshot.now", "vault.retry"];
|
|
5
|
+
type ReadVerb = (typeof READ_VERBS)[number];
|
|
6
|
+
type AdminVerb = (typeof ADMIN_VERBS)[number];
|
|
7
|
+
type RpcVerb = ReadVerb | AdminVerb;
|
|
8
|
+
declare const CAPABILITIES: readonly ["samples", "reports", "events", "workspace", "containers", "probes", "tls", "backup", "backup-restic", "backup-duplicity-legacy", "admin-jobs"];
|
|
9
|
+
type Capability = (typeof CAPABILITIES)[number];
|
|
10
|
+
type HealthState = 'ok' | 'warn' | 'bad' | 'unknown';
|
|
11
|
+
type BackupEngine = 'restic' | 'duplicity-legacy';
|
|
12
|
+
type VaultProvider = 'local' | 'baidu' | 'google-drive' | 's3' | 'rclone';
|
|
13
|
+
interface ServiceInfo {
|
|
14
|
+
service: typeof PACKAGE_NAME;
|
|
15
|
+
version: string;
|
|
16
|
+
protocolVersion: typeof PROTOCOL_VERSION;
|
|
17
|
+
node: string;
|
|
18
|
+
ok: true;
|
|
19
|
+
serverId?: string;
|
|
20
|
+
hostname?: string;
|
|
21
|
+
platform?: string;
|
|
22
|
+
arch?: string;
|
|
23
|
+
uptimeSec?: number;
|
|
24
|
+
capabilities?: Capability[];
|
|
25
|
+
profileHash?: string;
|
|
26
|
+
daemonStartedAt?: number;
|
|
27
|
+
}
|
|
28
|
+
interface DailyReportSummary {
|
|
29
|
+
id: string;
|
|
30
|
+
date: string;
|
|
31
|
+
generatedAt: number;
|
|
32
|
+
status: HealthState;
|
|
33
|
+
summaryLines: string[];
|
|
34
|
+
}
|
|
35
|
+
interface CpuMetricSummary {
|
|
36
|
+
load1: number;
|
|
37
|
+
load5: number;
|
|
38
|
+
load15: number;
|
|
39
|
+
cores: number;
|
|
40
|
+
loadPerCpu: number;
|
|
41
|
+
status: HealthState;
|
|
42
|
+
sparkline?: number[];
|
|
43
|
+
}
|
|
44
|
+
interface MemoryMetricSummary {
|
|
45
|
+
totalBytes: number;
|
|
46
|
+
availableBytes: number;
|
|
47
|
+
usedPct: number;
|
|
48
|
+
availPct: number;
|
|
49
|
+
swapUsedPct?: number;
|
|
50
|
+
status: HealthState;
|
|
51
|
+
sparkline?: number[];
|
|
52
|
+
}
|
|
53
|
+
interface MountMetricSummary {
|
|
54
|
+
mount: string;
|
|
55
|
+
device?: string;
|
|
56
|
+
stDev?: number | null;
|
|
57
|
+
totalBytes: number;
|
|
58
|
+
usedBytes: number;
|
|
59
|
+
availBytes: number;
|
|
60
|
+
usedPct: number;
|
|
61
|
+
inodePct?: number;
|
|
62
|
+
thresholdPct: number;
|
|
63
|
+
delta24hBytes: number | null;
|
|
64
|
+
estimatedDaysLeft: number | null;
|
|
65
|
+
lowConfidence?: boolean;
|
|
66
|
+
status: HealthState;
|
|
67
|
+
sparkline?: number[];
|
|
68
|
+
}
|
|
69
|
+
interface FailedUnitSummary {
|
|
70
|
+
unit: string;
|
|
71
|
+
loadState: string;
|
|
72
|
+
activeState: string;
|
|
73
|
+
subState: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
sinceTs?: number;
|
|
76
|
+
}
|
|
77
|
+
interface TlsCertSummary {
|
|
78
|
+
host: string;
|
|
79
|
+
port?: number;
|
|
80
|
+
expiresAt: number;
|
|
81
|
+
daysLeft: number;
|
|
82
|
+
issuer?: string;
|
|
83
|
+
status: HealthState;
|
|
84
|
+
}
|
|
85
|
+
interface SecurityMetricSummary {
|
|
86
|
+
sshFailures24h: number;
|
|
87
|
+
sshFailures5m: number;
|
|
88
|
+
sshHourly24h: number[];
|
|
89
|
+
failedUnits: FailedUnitSummary[];
|
|
90
|
+
certs: TlsCertSummary[];
|
|
91
|
+
status: HealthState;
|
|
92
|
+
}
|
|
93
|
+
interface ContainerStatus {
|
|
94
|
+
name: string;
|
|
95
|
+
label?: string;
|
|
96
|
+
image?: string;
|
|
97
|
+
state: 'running' | 'restarting' | 'exited' | 'paused' | 'dead' | 'missing' | 'unknown';
|
|
98
|
+
health?: 'healthy' | 'unhealthy' | 'starting' | 'none';
|
|
99
|
+
uptimeSec?: number;
|
|
100
|
+
restartCount?: number;
|
|
101
|
+
restartDelta24h?: number;
|
|
102
|
+
status: HealthState;
|
|
103
|
+
}
|
|
104
|
+
interface HttpProbeStatus {
|
|
105
|
+
id: string;
|
|
106
|
+
label?: string;
|
|
107
|
+
url: string;
|
|
108
|
+
statusCode: number | null;
|
|
109
|
+
latencyMs: number | null;
|
|
110
|
+
checkedAt: number;
|
|
111
|
+
status: HealthState;
|
|
112
|
+
error?: string;
|
|
113
|
+
}
|
|
114
|
+
interface SupervisorCheckStatus {
|
|
115
|
+
id: string;
|
|
116
|
+
label: string;
|
|
117
|
+
runningPrograms: string[];
|
|
118
|
+
stoppedPrograms: string[];
|
|
119
|
+
lastTaskAgeSec?: number | null;
|
|
120
|
+
checkedAt: number;
|
|
121
|
+
status: HealthState;
|
|
122
|
+
detail?: string;
|
|
123
|
+
}
|
|
124
|
+
interface ExternalProbeStatus {
|
|
125
|
+
id: string;
|
|
126
|
+
label: string;
|
|
127
|
+
signal: string;
|
|
128
|
+
observedAt: number | null;
|
|
129
|
+
stale: boolean;
|
|
130
|
+
status: HealthState;
|
|
131
|
+
summary?: string;
|
|
132
|
+
facts?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
interface BackupCopySummary {
|
|
135
|
+
vaultId: string;
|
|
136
|
+
code: 'L' | 'B' | 'G' | 'R';
|
|
137
|
+
label: string;
|
|
138
|
+
provider: VaultProvider;
|
|
139
|
+
status: HealthState;
|
|
140
|
+
lastSuccessAt: number | null;
|
|
141
|
+
}
|
|
142
|
+
interface BackupOverviewSummary {
|
|
143
|
+
enabled: boolean;
|
|
144
|
+
status: HealthState;
|
|
145
|
+
engine: BackupEngine | 'none';
|
|
146
|
+
lastSnapshotAt: number | null;
|
|
147
|
+
lastSnapshotId?: string;
|
|
148
|
+
copyStates: BackupCopySummary[];
|
|
149
|
+
headline: string;
|
|
150
|
+
}
|
|
151
|
+
interface OverviewResponse {
|
|
152
|
+
serverId: string;
|
|
153
|
+
hostname: string;
|
|
154
|
+
collectedAt: number;
|
|
155
|
+
stale: boolean;
|
|
156
|
+
offlineCache?: boolean;
|
|
157
|
+
cachedAt?: number;
|
|
158
|
+
health: {
|
|
159
|
+
status: HealthState;
|
|
160
|
+
headline: string;
|
|
161
|
+
activeIncidents: number;
|
|
162
|
+
unreadAlerts: number;
|
|
163
|
+
};
|
|
164
|
+
todayReport?: DailyReportSummary;
|
|
165
|
+
metrics: {
|
|
166
|
+
cpu: CpuMetricSummary;
|
|
167
|
+
memory: MemoryMetricSummary;
|
|
168
|
+
mounts: MountMetricSummary[];
|
|
169
|
+
security: SecurityMetricSummary;
|
|
170
|
+
};
|
|
171
|
+
services: {
|
|
172
|
+
containers: ContainerStatus[];
|
|
173
|
+
httpProbes: HttpProbeStatus[];
|
|
174
|
+
supervisors: SupervisorCheckStatus[];
|
|
175
|
+
externalProbes: ExternalProbeStatus[];
|
|
176
|
+
};
|
|
177
|
+
backupSummary: BackupOverviewSummary;
|
|
178
|
+
capabilities: Capability[];
|
|
179
|
+
}
|
|
180
|
+
interface DeployProbeResult {
|
|
181
|
+
host: string;
|
|
182
|
+
osId: string;
|
|
183
|
+
osVersion: string;
|
|
184
|
+
arch: string;
|
|
185
|
+
hasSystemd: boolean;
|
|
186
|
+
sudoNonInteractive: boolean;
|
|
187
|
+
systemNodeVersion: string | null;
|
|
188
|
+
bundledNodeInstalled: boolean;
|
|
189
|
+
bundledNodeVersion: string | null;
|
|
190
|
+
installedServiceVersion: string | null;
|
|
191
|
+
serviceActive: boolean;
|
|
192
|
+
python3Version: string | null;
|
|
193
|
+
hasNcUnixSocket: boolean;
|
|
194
|
+
resticVersion: string | null;
|
|
195
|
+
rootAvailBytes: number | null;
|
|
196
|
+
readyToInstall: boolean;
|
|
197
|
+
warnings: string[];
|
|
198
|
+
}
|
|
199
|
+
interface DeployStatusResult {
|
|
200
|
+
installed: boolean;
|
|
201
|
+
active: boolean;
|
|
202
|
+
version: string | null;
|
|
203
|
+
protocolVersion: number | null;
|
|
204
|
+
serverId: string | null;
|
|
205
|
+
readSocketReady: boolean;
|
|
206
|
+
adminSocketReady: boolean;
|
|
207
|
+
jobRunnerReady: boolean;
|
|
208
|
+
capabilities: Capability[];
|
|
209
|
+
}
|
|
210
|
+
interface SshEndpointConfig {
|
|
211
|
+
host: string;
|
|
212
|
+
port: number;
|
|
213
|
+
user: string;
|
|
214
|
+
fingerprint: string;
|
|
215
|
+
keyPath: string;
|
|
216
|
+
}
|
|
217
|
+
interface HostFingerprintResult {
|
|
218
|
+
host: string;
|
|
219
|
+
port: number;
|
|
220
|
+
fingerprint: string;
|
|
221
|
+
keyType: string;
|
|
222
|
+
}
|
|
223
|
+
interface WorkspaceTarget {
|
|
224
|
+
host: string;
|
|
225
|
+
serverId: string;
|
|
226
|
+
capabilities?: Capability[];
|
|
227
|
+
}
|
|
228
|
+
interface DeployConnectionInput {
|
|
229
|
+
host: string;
|
|
230
|
+
port?: number;
|
|
231
|
+
user?: string;
|
|
232
|
+
username?: string;
|
|
233
|
+
fingerprint?: string;
|
|
234
|
+
hostKeySha256?: string;
|
|
235
|
+
keyPath?: string;
|
|
236
|
+
}
|
|
237
|
+
interface DeployInstallOptions {
|
|
238
|
+
grantAdmin?: boolean;
|
|
239
|
+
bootstrapNode22?: boolean;
|
|
240
|
+
upgrade?: boolean;
|
|
241
|
+
}
|
|
242
|
+
interface DeployProbeExtendedResult extends DeployProbeResult {
|
|
243
|
+
detected?: {
|
|
244
|
+
docker: boolean;
|
|
245
|
+
caddy: boolean;
|
|
246
|
+
mounts: string[];
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
interface DeployInstallOutcome {
|
|
250
|
+
ok: true;
|
|
251
|
+
serverId: string;
|
|
252
|
+
host: string;
|
|
253
|
+
version: string;
|
|
254
|
+
reconnected: true;
|
|
255
|
+
grantedGroups: string[];
|
|
256
|
+
serviceInfo: ServiceInfo;
|
|
257
|
+
overview: OverviewResponse | null;
|
|
258
|
+
}
|
|
259
|
+
interface PluginRuntimeBridge {
|
|
260
|
+
workspaceTarget(cwd: string | undefined): WorkspaceTarget | null;
|
|
261
|
+
getServerConfig(serverId: string): SshEndpointConfig | null;
|
|
262
|
+
daemon<T = unknown>(action: RpcVerb, data?: Record<string, unknown>, serverId?: string): Promise<T>;
|
|
263
|
+
probeHostFingerprint(host: string, port?: number): Promise<HostFingerprintResult>;
|
|
264
|
+
deployProbe(input: DeployConnectionInput): Promise<DeployProbeExtendedResult>;
|
|
265
|
+
deployInstall(input: DeployConnectionInput, options?: DeployInstallOptions): Promise<DeployInstallOutcome>;
|
|
266
|
+
deployStatus(input: DeployConnectionInput): Promise<DeployStatusResult>;
|
|
267
|
+
}
|
|
268
|
+
interface AgentSessionLike {
|
|
269
|
+
header?: {
|
|
270
|
+
cwd?: string;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
interface AgentLike {
|
|
274
|
+
id?: string;
|
|
275
|
+
session?: AgentSessionLike;
|
|
276
|
+
ctx?: {
|
|
277
|
+
tools?: {
|
|
278
|
+
restrict?: (options: {
|
|
279
|
+
allow: string[];
|
|
280
|
+
}) => void;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
interface ToolExecutionContext {
|
|
285
|
+
agent?: AgentLike;
|
|
286
|
+
signal?: AbortSignal;
|
|
287
|
+
}
|
|
288
|
+
interface UserQuestionOption {
|
|
289
|
+
label: string;
|
|
290
|
+
description: string;
|
|
291
|
+
}
|
|
292
|
+
interface UserQuestionItem {
|
|
293
|
+
id: string;
|
|
294
|
+
header: string;
|
|
295
|
+
question: string;
|
|
296
|
+
options: UserQuestionOption[];
|
|
297
|
+
}
|
|
298
|
+
interface UserQuestionAnswer {
|
|
299
|
+
id: string;
|
|
300
|
+
selected?: string[];
|
|
301
|
+
custom?: string;
|
|
302
|
+
}
|
|
303
|
+
interface UserQuestionsService {
|
|
304
|
+
ask(request: {
|
|
305
|
+
agent?: AgentLike;
|
|
306
|
+
signal?: AbortSignal;
|
|
307
|
+
questions: UserQuestionItem[];
|
|
308
|
+
}): Promise<{
|
|
309
|
+
answers?: UserQuestionAnswer[];
|
|
310
|
+
} | undefined>;
|
|
311
|
+
}
|
|
312
|
+
interface RegisteredToolDefinition<TArgs = Record<string, unknown>> {
|
|
313
|
+
name: string;
|
|
314
|
+
description: string;
|
|
315
|
+
parameters: Record<string, unknown>;
|
|
316
|
+
output?: {
|
|
317
|
+
schema: Record<string, unknown>;
|
|
318
|
+
render: (args: unknown, value: unknown) => Array<{
|
|
319
|
+
type: 'text';
|
|
320
|
+
text: string;
|
|
321
|
+
}>;
|
|
322
|
+
};
|
|
323
|
+
execute: (args: TArgs, exec: ToolExecutionContext) => Promise<unknown>;
|
|
324
|
+
}
|
|
325
|
+
interface WorkspaceToolContext {
|
|
326
|
+
tools?: {
|
|
327
|
+
guard?: (fn: (exec: {
|
|
328
|
+
name: string;
|
|
329
|
+
}) => string | undefined) => void;
|
|
330
|
+
register?: <TArgs = Record<string, unknown>>(tool: RegisteredToolDefinition<TArgs>) => void;
|
|
331
|
+
};
|
|
332
|
+
systemPrompt?: {
|
|
333
|
+
section?: (config: {
|
|
334
|
+
name: string;
|
|
335
|
+
order: number;
|
|
336
|
+
text: string;
|
|
337
|
+
}) => void;
|
|
338
|
+
};
|
|
339
|
+
userQuestions?: UserQuestionsService;
|
|
340
|
+
get?: (serviceName: string) => unknown;
|
|
341
|
+
on?: (event: string, listener: (payload: {
|
|
342
|
+
agent?: AgentLike;
|
|
343
|
+
}) => void) => void;
|
|
344
|
+
}
|
|
345
|
+
interface BackupToolOptions {
|
|
346
|
+
pollIntervalMs?: number;
|
|
347
|
+
}
|
|
348
|
+
interface RecoveryToolOptions {
|
|
349
|
+
pollAttempts?: number;
|
|
350
|
+
pollDelayMs?: number;
|
|
351
|
+
}
|
|
352
|
+
declare const name = "server-ops-readonly";
|
|
353
|
+
declare const inject: readonly ["tools", "systemPrompt", "userQuestions"];
|
|
354
|
+
declare const ALL_OPS_TOOL_NAMES: readonly ["read_host_observations", "read_backup_status", "list_backup_snapshots", "browse_backup_files", "trigger_backup_snapshot", "retry_backup_destination", "read_backup_job", "find_missing_workspace_items", "recover_workspace_items", "read_workspace_recovery", "deploy_probe", "deploy_install", "deploy_status"];
|
|
355
|
+
declare const OPS_SYSTEM_PROMPT: string;
|
|
356
|
+
interface ApplyWorkspaceToolOptions {
|
|
357
|
+
bridge?: PluginRuntimeBridge;
|
|
358
|
+
backup?: BackupToolOptions;
|
|
359
|
+
recovery?: RecoveryToolOptions;
|
|
360
|
+
}
|
|
361
|
+
declare function apply(ctx: WorkspaceToolContext, options?: ApplyWorkspaceToolOptions): void;
|
|
362
|
+
export { ALL_OPS_TOOL_NAMES, ApplyWorkspaceToolOptions, OPS_SYSTEM_PROMPT, type WorkspaceToolContext, apply, inject, name };
|