@soyrageagency/docker-mcp 1.1.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 +21 -0
- package/README.md +882 -0
- package/dist/ai/credentials.d.ts +72 -0
- package/dist/ai/credentials.js +157 -0
- package/dist/ai/credentials.js.map +1 -0
- package/dist/ai/login.d.ts +22 -0
- package/dist/ai/login.js +189 -0
- package/dist/ai/login.js.map +1 -0
- package/dist/ai/provider.d.ts +29 -0
- package/dist/ai/provider.js +113 -0
- package/dist/ai/provider.js.map +1 -0
- package/dist/assets.d.ts +20 -0
- package/dist/assets.js +56 -0
- package/dist/assets.js.map +1 -0
- package/dist/branding.d.ts +31 -0
- package/dist/branding.js +61 -0
- package/dist/branding.js.map +1 -0
- package/dist/config.d.ts +65 -0
- package/dist/config.js +128 -0
- package/dist/config.js.map +1 -0
- package/dist/docker/client.d.ts +66 -0
- package/dist/docker/client.js +161 -0
- package/dist/docker/client.js.map +1 -0
- package/dist/docker/compose.d.ts +74 -0
- package/dist/docker/compose.js +126 -0
- package/dist/docker/compose.js.map +1 -0
- package/dist/entry.d.ts +15 -0
- package/dist/entry.js +33 -0
- package/dist/entry.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +25 -0
- package/dist/logger.js +68 -0
- package/dist/logger.js.map +1 -0
- package/dist/panel/index.d.ts +16 -0
- package/dist/panel/index.js +53 -0
- package/dist/panel/index.js.map +1 -0
- package/dist/panel/public/app.js +1004 -0
- package/dist/panel/public/index.html +243 -0
- package/dist/panel/public/styles.css +428 -0
- package/dist/panel/server.d.ts +23 -0
- package/dist/panel/server.js +355 -0
- package/dist/panel/server.js.map +1 -0
- package/dist/panel/service.d.ts +327 -0
- package/dist/panel/service.js +1356 -0
- package/dist/panel/service.js.map +1 -0
- package/dist/plugins.d.ts +50 -0
- package/dist/plugins.js +121 -0
- package/dist/plugins.js.map +1 -0
- package/dist/ragedocker.d.ts +21 -0
- package/dist/ragedocker.js +164 -0
- package/dist/ragedocker.js.map +1 -0
- package/dist/tools/about.d.ts +15 -0
- package/dist/tools/about.js +55 -0
- package/dist/tools/about.js.map +1 -0
- package/dist/tools/compose.d.ts +19 -0
- package/dist/tools/compose.js +145 -0
- package/dist/tools/compose.js.map +1 -0
- package/dist/tools/containers.d.ts +13 -0
- package/dist/tools/containers.js +119 -0
- package/dist/tools/containers.js.map +1 -0
- package/dist/tools/context.d.ts +37 -0
- package/dist/tools/context.js +13 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/images.d.ts +11 -0
- package/dist/tools/images.js +38 -0
- package/dist/tools/images.js.map +1 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.js +34 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/lifecycle.d.ts +16 -0
- package/dist/tools/lifecycle.js +165 -0
- package/dist/tools/lifecycle.js.map +1 -0
- package/dist/tools/logs.d.ts +15 -0
- package/dist/tools/logs.js +110 -0
- package/dist/tools/logs.js.map +1 -0
- package/dist/tools/system.d.ts +14 -0
- package/dist/tools/system.js +108 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/tui/ansi.d.ts +66 -0
- package/dist/tui/ansi.js +118 -0
- package/dist/tui/ansi.js.map +1 -0
- package/dist/tui/app.d.ts +160 -0
- package/dist/tui/app.js +1339 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/box.d.ts +18 -0
- package/dist/tui/box.js +38 -0
- package/dist/tui/box.js.map +1 -0
- package/dist/tui/index.d.ts +19 -0
- package/dist/tui/index.js +66 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/update/channel.d.ts +82 -0
- package/dist/update/channel.js +178 -0
- package/dist/update/channel.js.map +1 -0
- package/dist/updates.json +42 -0
- package/dist/utils/format.d.ts +24 -0
- package/dist/utils/format.js +69 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/result.d.ts +35 -0
- package/dist/utils/result.js +31 -0
- package/dist/utils/result.js.map +1 -0
- package/package.json +90 -0
- package/scripts/install.mjs +132 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel & monitoring data service.
|
|
3
|
+
*
|
|
4
|
+
* A UI/monitoring-oriented data layer shared by the panel's REST API, the
|
|
5
|
+
* Prometheus `/metrics` endpoint and the terminal UI. It normalises Docker
|
|
6
|
+
* payloads into compact DTOs, samples live CPU/memory usage, and — crucially —
|
|
7
|
+
* supports a **demo mode** that serves realistic fabricated data (with gentle
|
|
8
|
+
* jitter so it looks alive) for previews, screenshots and client demos.
|
|
9
|
+
*
|
|
10
|
+
* Part of Docker MCP Server.
|
|
11
|
+
* Crafted by SoyRage Agency — https://soyrage.es/
|
|
12
|
+
* MIT licensed (see LICENSE).
|
|
13
|
+
*/
|
|
14
|
+
import type { AppConfig } from "../config.js";
|
|
15
|
+
import type { Logger } from "../logger.js";
|
|
16
|
+
import { DockerClient } from "../docker/client.js";
|
|
17
|
+
/** Compact container row for the UI, including live usage when available. */
|
|
18
|
+
export interface ContainerDTO {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
image: string;
|
|
22
|
+
state: string;
|
|
23
|
+
status: string;
|
|
24
|
+
ports: string[];
|
|
25
|
+
/** Live CPU percentage (0–100·cores), if sampled. */
|
|
26
|
+
cpu?: number;
|
|
27
|
+
/** Live memory usage in bytes, if sampled. */
|
|
28
|
+
memory?: number;
|
|
29
|
+
/** Memory limit in bytes, if known. */
|
|
30
|
+
memoryLimit?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Host/daemon summary for the header cards. */
|
|
33
|
+
export interface SystemDTO {
|
|
34
|
+
engine: string;
|
|
35
|
+
os: string;
|
|
36
|
+
arch: string;
|
|
37
|
+
cpus: number;
|
|
38
|
+
memoryBytes: number;
|
|
39
|
+
containersRunning: number;
|
|
40
|
+
containersTotal: number;
|
|
41
|
+
images: number;
|
|
42
|
+
demo: boolean;
|
|
43
|
+
readOnly: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Image row for the images panel. */
|
|
46
|
+
export interface ImageDTO {
|
|
47
|
+
id: string;
|
|
48
|
+
tag: string;
|
|
49
|
+
sizeBytes: number;
|
|
50
|
+
}
|
|
51
|
+
/** A full point-in-time snapshot used by monitoring & metrics. */
|
|
52
|
+
export interface Snapshot {
|
|
53
|
+
system: SystemDTO;
|
|
54
|
+
containers: ContainerDTO[];
|
|
55
|
+
images: ImageDTO[];
|
|
56
|
+
/** Aggregate CPU percentage across running containers. */
|
|
57
|
+
cpuTotal: number;
|
|
58
|
+
/** Aggregate memory bytes across running containers. */
|
|
59
|
+
memoryUsed: number;
|
|
60
|
+
}
|
|
61
|
+
/** A single entry in a container's filesystem listing. */
|
|
62
|
+
export interface FileEntry {
|
|
63
|
+
name: string;
|
|
64
|
+
type: "dir" | "file" | "link";
|
|
65
|
+
size: number;
|
|
66
|
+
/** Symlink target, when known. */
|
|
67
|
+
target?: string;
|
|
68
|
+
}
|
|
69
|
+
/** An alert raised by the alert engine. */
|
|
70
|
+
export interface Alert {
|
|
71
|
+
/** Severity. */
|
|
72
|
+
level: "critical" | "warning" | "info";
|
|
73
|
+
/** Container the alert relates to (or "system"). */
|
|
74
|
+
source: string;
|
|
75
|
+
/** Short rule key, e.g. "container-down", "high-cpu", "log-error". */
|
|
76
|
+
rule: string;
|
|
77
|
+
/** Human-readable message. */
|
|
78
|
+
message: string;
|
|
79
|
+
/** ISO timestamp. */
|
|
80
|
+
time: string;
|
|
81
|
+
}
|
|
82
|
+
/** Result of running a command in the panel terminal. */
|
|
83
|
+
export interface CommandResult {
|
|
84
|
+
command: string;
|
|
85
|
+
code: number;
|
|
86
|
+
output: string;
|
|
87
|
+
}
|
|
88
|
+
/** A recorded container snapshot/backup. */
|
|
89
|
+
export interface SnapshotInfo {
|
|
90
|
+
id: string;
|
|
91
|
+
container: string;
|
|
92
|
+
type: "commit" | "export";
|
|
93
|
+
/** Image ref (commit) or file path (export). */
|
|
94
|
+
ref: string;
|
|
95
|
+
sizeBytes: number;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
destination: string;
|
|
98
|
+
}
|
|
99
|
+
/** Scheduled backup configuration (in-memory). */
|
|
100
|
+
export interface BackupSchedule {
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
/** 24h time "HH:MM" (local) at which the backup runs. */
|
|
103
|
+
time: string;
|
|
104
|
+
/** Container names to back up, or ["all"]. */
|
|
105
|
+
containers: string[];
|
|
106
|
+
type: "commit" | "export";
|
|
107
|
+
/** Optional email address (delivered via the webhook payload). */
|
|
108
|
+
email: string;
|
|
109
|
+
}
|
|
110
|
+
/** Curated inspect summary for the details drawer. */
|
|
111
|
+
export interface InspectSummary {
|
|
112
|
+
name: string;
|
|
113
|
+
image: string;
|
|
114
|
+
id: string;
|
|
115
|
+
created: string;
|
|
116
|
+
state: string;
|
|
117
|
+
health: string;
|
|
118
|
+
restartPolicy: string;
|
|
119
|
+
command: string;
|
|
120
|
+
ports: string[];
|
|
121
|
+
mounts: string[];
|
|
122
|
+
networks: string[];
|
|
123
|
+
env: string[];
|
|
124
|
+
}
|
|
125
|
+
/** Network row for the System tab. */
|
|
126
|
+
export interface NetworkDTO {
|
|
127
|
+
name: string;
|
|
128
|
+
id: string;
|
|
129
|
+
driver: string;
|
|
130
|
+
scope: string;
|
|
131
|
+
}
|
|
132
|
+
/** Volume row for the System tab. */
|
|
133
|
+
export interface VolumeDTO {
|
|
134
|
+
name: string;
|
|
135
|
+
driver: string;
|
|
136
|
+
mountpoint: string;
|
|
137
|
+
}
|
|
138
|
+
/** Actions the panel can request. */
|
|
139
|
+
export type ContainerAction = "start" | "stop" | "restart";
|
|
140
|
+
/** Unified data provider; delegates to Docker or fabricated demo data. */
|
|
141
|
+
export declare class PanelService {
|
|
142
|
+
private readonly docker;
|
|
143
|
+
private readonly config;
|
|
144
|
+
private readonly logger;
|
|
145
|
+
private readonly demo;
|
|
146
|
+
/** Demo baselines, mutated with light jitter to feel live. */
|
|
147
|
+
private readonly demoBase;
|
|
148
|
+
/** Names with auto-restart enabled (in-memory registry). */
|
|
149
|
+
private readonly autoRestart;
|
|
150
|
+
/** Rolling event log of raised alerts (most recent last). */
|
|
151
|
+
private readonly alertLog;
|
|
152
|
+
private watchdog;
|
|
153
|
+
/** In-memory snapshot registry. */
|
|
154
|
+
private readonly snapshotLog;
|
|
155
|
+
/** Backup schedule + scheduler bookkeeping. */
|
|
156
|
+
private schedule;
|
|
157
|
+
private scheduler;
|
|
158
|
+
private lastScheduleRun;
|
|
159
|
+
/** Rolling time-series for the Trends charts (most recent last). */
|
|
160
|
+
private readonly history;
|
|
161
|
+
private sampler;
|
|
162
|
+
private static readonly HISTORY_CAP;
|
|
163
|
+
constructor(docker: DockerClient, config: AppConfig, logger: Logger);
|
|
164
|
+
get isDemo(): boolean;
|
|
165
|
+
get isReadOnly(): boolean;
|
|
166
|
+
/** Host summary. */
|
|
167
|
+
system(): Promise<SystemDTO>;
|
|
168
|
+
/** Container list WITH live usage (CPU %, memory) for running containers. */
|
|
169
|
+
containers(): Promise<ContainerDTO[]>;
|
|
170
|
+
/** Image list. */
|
|
171
|
+
images(): Promise<ImageDTO[]>;
|
|
172
|
+
/** A full snapshot for monitoring dashboards and the metrics endpoint. */
|
|
173
|
+
snapshot(): Promise<Snapshot>;
|
|
174
|
+
/** Recent logs for one container. */
|
|
175
|
+
logs(reference: string, tail?: number): Promise<string>;
|
|
176
|
+
/** Perform a lifecycle action. Rejected in read-only mode. */
|
|
177
|
+
act(reference: string, action: ContainerAction): Promise<void>;
|
|
178
|
+
/** Names with auto-restart currently enabled. */
|
|
179
|
+
autoRestartList(): string[];
|
|
180
|
+
/** Enable/disable auto-restart for a container. */
|
|
181
|
+
setAutoRestart(name: string, enabled: boolean): void;
|
|
182
|
+
/**
|
|
183
|
+
* Start the background watchdog: every `intervalMs`, any container that has
|
|
184
|
+
* auto-restart enabled but is not running is restarted (unless read-only).
|
|
185
|
+
* Each intervention is recorded as an alert.
|
|
186
|
+
*/
|
|
187
|
+
startWatchdog(intervalMs?: number): void;
|
|
188
|
+
/** Stop the watchdog (used on shutdown). */
|
|
189
|
+
stopWatchdog(): void;
|
|
190
|
+
/** Recent CPU/memory samples for the Trends charts. */
|
|
191
|
+
getHistory(): Array<{
|
|
192
|
+
t: number;
|
|
193
|
+
cpu: number;
|
|
194
|
+
mem: number;
|
|
195
|
+
memBytes: number;
|
|
196
|
+
}>;
|
|
197
|
+
/** Start sampling CPU/memory into the history ring buffer. */
|
|
198
|
+
startSampler(intervalMs?: number): void;
|
|
199
|
+
private tickSampler;
|
|
200
|
+
private tickWatchdog;
|
|
201
|
+
/** Append an alert to the rolling log (bounded to the last 200). */
|
|
202
|
+
private addAlert;
|
|
203
|
+
/**
|
|
204
|
+
* Compute the current alerts: live state-based rules (down / high CPU / high
|
|
205
|
+
* memory / unhealthy) plus a scan of recent logs for error/warn lines, merged
|
|
206
|
+
* with the rolling event log (watchdog interventions, etc.).
|
|
207
|
+
*/
|
|
208
|
+
alerts(): Promise<Alert[]>;
|
|
209
|
+
/** List a directory inside a container. */
|
|
210
|
+
listFiles(name: string, path?: string): Promise<{
|
|
211
|
+
path: string;
|
|
212
|
+
entries: FileEntry[];
|
|
213
|
+
}>;
|
|
214
|
+
/** Read a text file inside a container (bounded to 128 KB). */
|
|
215
|
+
readFile(name: string, path: string): Promise<{
|
|
216
|
+
path: string;
|
|
217
|
+
content: string;
|
|
218
|
+
truncated: boolean;
|
|
219
|
+
}>;
|
|
220
|
+
/**
|
|
221
|
+
* Write a text file inside a container (editor save). Blocked in read-only
|
|
222
|
+
* mode. Content is streamed to `sh -c 'cat > "$1"'` with the path passed as
|
|
223
|
+
* an argument (no shell interpolation of the path).
|
|
224
|
+
*/
|
|
225
|
+
writeFile(name: string, path: string, content: string): Promise<{
|
|
226
|
+
path: string;
|
|
227
|
+
bytes: number;
|
|
228
|
+
}>;
|
|
229
|
+
/** Whether the AI copilot is available (demo simulates it). */
|
|
230
|
+
get aiEnabled(): boolean;
|
|
231
|
+
/** A short human label for the active model, for the status bar. */
|
|
232
|
+
get aiLabel(): string;
|
|
233
|
+
/**
|
|
234
|
+
* AI copilot. `mode`:
|
|
235
|
+
* - "command": natural language → a suggested docker command + explanation
|
|
236
|
+
* - "edit": rewrite file `context` per the `prompt` instruction
|
|
237
|
+
* Uses an OpenAI-compatible endpoint when configured; falls back to a helpful
|
|
238
|
+
* message (and a heuristic command) otherwise. Demo mode simulates it.
|
|
239
|
+
*/
|
|
240
|
+
aiAssist(mode: "command" | "edit", prompt: string, context?: string): Promise<{
|
|
241
|
+
command?: string;
|
|
242
|
+
explanation?: string;
|
|
243
|
+
content?: string;
|
|
244
|
+
text?: string;
|
|
245
|
+
source: string;
|
|
246
|
+
}>;
|
|
247
|
+
/** Run a command inside a container and return its combined output. */
|
|
248
|
+
private exec;
|
|
249
|
+
/**
|
|
250
|
+
* Run a `docker …` (or `docker compose …`) command typed in the panel
|
|
251
|
+
* terminal. Commands are parsed into an argv array and spawned WITHOUT a
|
|
252
|
+
* shell (no injection). A deny-list blocks dangerous verbs; write verbs are
|
|
253
|
+
* blocked in read-only mode; read verbs are always allowed.
|
|
254
|
+
*/
|
|
255
|
+
runCommand(input: string): Promise<CommandResult>;
|
|
256
|
+
private spawnDocker;
|
|
257
|
+
/** List recorded snapshots (most recent first). */
|
|
258
|
+
listSnapshots(): SnapshotInfo[];
|
|
259
|
+
/** Create a snapshot of a container (image commit or filesystem export). */
|
|
260
|
+
createSnapshot(container: string, type?: "commit" | "export"): Promise<SnapshotInfo>;
|
|
261
|
+
/** Get the current backup schedule. */
|
|
262
|
+
getSchedule(): BackupSchedule;
|
|
263
|
+
/** Update the backup schedule (fields are validated/coerced). */
|
|
264
|
+
setSchedule(next: Record<string, unknown>): BackupSchedule;
|
|
265
|
+
/** Start the once-a-minute backup scheduler (idempotent). */
|
|
266
|
+
startScheduler(): void;
|
|
267
|
+
private tickScheduler;
|
|
268
|
+
/** POST a backup notification to the configured webhook (email/cloud bridge). */
|
|
269
|
+
private notify;
|
|
270
|
+
/** Curated inspect summary for the details drawer. */
|
|
271
|
+
inspectSummary(name: string): Promise<InspectSummary>;
|
|
272
|
+
/** Networks for the System tab. */
|
|
273
|
+
networks(): Promise<NetworkDTO[]>;
|
|
274
|
+
/** Volumes for the System tab. */
|
|
275
|
+
volumes(): Promise<VolumeDTO[]>;
|
|
276
|
+
/**
|
|
277
|
+
* Restore a recorded snapshot. Non-destructive by design: a commit snapshot
|
|
278
|
+
* launches a *new* container from the image (the image's CMD/ENTRYPOINT are
|
|
279
|
+
* preserved by `commit`), and an export tar is imported as a new image you can
|
|
280
|
+
* then run. Nothing existing is overwritten.
|
|
281
|
+
*/
|
|
282
|
+
restoreSnapshot(id: string): Promise<{
|
|
283
|
+
ok: boolean;
|
|
284
|
+
message: string;
|
|
285
|
+
container?: string;
|
|
286
|
+
image?: string;
|
|
287
|
+
}>;
|
|
288
|
+
/** One-off command inside a running container (`docker exec … sh -lc`). */
|
|
289
|
+
execOnce(name: string, command: string): Promise<CommandResult>;
|
|
290
|
+
/** Candidate compose files near the working directory (for the editor pickers). */
|
|
291
|
+
findComposeFiles(): string[];
|
|
292
|
+
private isComposePath;
|
|
293
|
+
/** Read a host compose file (compose-named, ≤512 KB). */
|
|
294
|
+
readComposeFile(path: string): {
|
|
295
|
+
path: string;
|
|
296
|
+
content: string;
|
|
297
|
+
};
|
|
298
|
+
/** Write a host compose file (compose-named, ≤512 KB). Blocked when read-only. */
|
|
299
|
+
writeComposeFile(path: string, content: string): {
|
|
300
|
+
path: string;
|
|
301
|
+
bytes: number;
|
|
302
|
+
};
|
|
303
|
+
/** `docker compose` lifecycle against a specific file. */
|
|
304
|
+
composeAction(path: string, action: "up" | "down" | "restart"): Promise<CommandResult>;
|
|
305
|
+
/**
|
|
306
|
+
* Attach an extra host volume to a container by recreating it from its own
|
|
307
|
+
* image with the same env / ports / network / restart policy plus the new
|
|
308
|
+
* bind. The original is stopped and kept (renamed `<name>-preattach-<ts>`) so
|
|
309
|
+
* the change is reversible.
|
|
310
|
+
*/
|
|
311
|
+
attachVolume(name: string, hostPath: string, containerPath: string, readOnly?: boolean): Promise<{
|
|
312
|
+
ok: boolean;
|
|
313
|
+
message: string;
|
|
314
|
+
container: string;
|
|
315
|
+
backup?: string;
|
|
316
|
+
}>;
|
|
317
|
+
/**
|
|
318
|
+
* Render a snapshot in the Prometheus text exposition format so it can be
|
|
319
|
+
* scraped by Prometheus, Grafana Agent, Zabbix (Prometheus preprocessing or
|
|
320
|
+
* HTTP agent), VictoriaMetrics, etc.
|
|
321
|
+
*/
|
|
322
|
+
prometheus(): Promise<string>;
|
|
323
|
+
/** Demo container list with gentle live jitter so usage looks real. */
|
|
324
|
+
private demoContainersLive;
|
|
325
|
+
/** Reflect a lifecycle action in the demo baseline so the UI updates. */
|
|
326
|
+
private applyDemoAction;
|
|
327
|
+
}
|