mcp-ssh-manager 3.8.7 → 4.0.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/.eslintignore +5 -0
- package/.gitattributes +5 -0
- package/CHANGELOG.md +371 -6
- package/CLAUDE.md +6 -0
- package/CODE_OF_CONDUCT.md +18 -0
- package/CONTRIBUTING.md +30 -0
- package/Formula/ssh-manager.rb +60 -0
- package/README.md +484 -964
- package/ROADMAP-V4.md +451 -0
- package/brand/README.md +43 -0
- package/brand/icon.svg +32 -0
- package/brand/mark.svg +18 -0
- package/brand/wordmark.svg +30 -0
- package/cli/app.js +230 -0
- package/cli/control.js +116 -0
- package/cli/lib/colors.sh +15 -0
- package/cli/lib/menu.sh +145 -96
- package/cli/portability.js +186 -0
- package/cli/ssh-manager +197 -91
- package/cli/ssh-manager.js +14 -0
- package/cli/style.js +17 -0
- package/cli/vault.js +411 -0
- package/desktop/ControlPlaneApp.swift +219 -0
- package/desktop/build.sh +58 -0
- package/desktop/electron/after-pack.cjs +39 -0
- package/desktop/electron/electron-builder.yml +148 -0
- package/desktop/electron/finalize-artifacts.mjs +83 -0
- package/desktop/electron/main.js +815 -0
- package/desktop/electron/package-lock.json +3656 -0
- package/desktop/electron/package.json +30 -0
- package/desktop/electron/prepare-engine.mjs +84 -0
- package/desktop/electron/resources/entitlements.mac.plist +22 -0
- package/desktop/electron/resources/icon.png +0 -0
- package/desktop/electron/resources/trayTemplate.png +0 -0
- package/desktop/electron/resources/trayTemplate@2x.png +0 -0
- package/desktop/electron/smoke-test.mjs +184 -0
- package/dist/ui/app.css +1 -0
- package/dist/ui/app.js +501 -0
- package/dist/ui/assets/Forum-Regular.woff2 +0 -0
- package/dist/ui/assets/JetBrainsMono-Bold.woff2 +0 -0
- package/dist/ui/assets/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/ui/assets/Karla-Variable.woff2 +0 -0
- package/dist/ui/index.html +16 -0
- package/docs/DISTRIBUTION.md +136 -0
- package/docs/FINAL-TEST-V4.md +209 -0
- package/docs/MIGRATION.md +334 -0
- package/docs/TESTING-V4.md +119 -0
- package/docs/superpowers/specs/2026-10-08-desktop-from-npm-and-cli-design.md +187 -0
- package/docs/videos/control-plane.mp4 +0 -0
- package/package.json +61 -30
- package/scripts/build-interface.mjs +73 -0
- package/scripts/capture-screenshots.mjs +191 -0
- package/scripts/demo-env.mjs +461 -0
- package/scripts/frame-screenshots.py +176 -0
- package/scripts/macbook-mockup.py +296 -0
- package/scripts/make-tray-icon.py +61 -0
- package/scripts/preview-candidate.mjs +291 -0
- package/scripts/publish-desktop.mjs +46 -0
- package/scripts/record-demo.mjs +229 -0
- package/scripts/release-version.mjs +32 -0
- package/scripts/render-cli-menu.py +157 -0
- package/scripts/requirements-dev.in +12 -0
- package/scripts/requirements-dev.txt +424 -0
- package/scripts/run-ui-regression.mjs +48 -0
- package/scripts/setup-hooks.sh +7 -13
- package/scripts/smoke-desktop.mjs +80 -0
- package/scripts/test-drag-and-drop.mjs +114 -0
- package/scripts/test-first-run.mjs +5 -0
- package/scripts/test-import-ui.mjs +5 -0
- package/scripts/test-preferences-persist.mjs +5 -0
- package/scripts/test-upgrade-from-published.mjs +226 -0
- package/scripts/verify-mac-build.sh +153 -0
- package/scripts/verify-windows-build.ps1 +15 -0
- package/server.json +3 -3
- package/skills/README.md +42 -0
- package/skills/ssh-incident/SKILL.md +55 -0
- package/skills/ssh-operations/SKILL.md +62 -0
- package/skills/ssh-restricted/SKILL.md +57 -0
- package/src/agent-clients.js +482 -0
- package/src/approval.js +291 -0
- package/src/audit.js +11 -1
- package/src/command-log.js +162 -0
- package/src/config-loader.js +119 -4
- package/src/config-paths.js +101 -0
- package/src/control-plane.js +2730 -0
- package/src/desktop-install.js +747 -0
- package/src/index.js +179 -213
- package/src/live-stream.js +261 -0
- package/src/saved-commands.js +150 -0
- package/src/secret-store.js +573 -0
- package/src/server-aliases.js +8 -7
- package/src/server-config-manager.js +33 -7
- package/src/server-export.js +106 -0
- package/src/server-groups.js +82 -21
- package/src/server-import.js +477 -0
- package/src/shell-quote.js +9 -2
- package/src/ssh-connection.js +155 -0
- package/src/ssh-manager.js +186 -13
- package/src/tunnel-manager.js +79 -0
- package/src/vault-recovery.js +206 -0
- package/src/xlsx.js +322 -0
- package/docs/images/social-preview.png +0 -0
- package/docs/images/social-preview@2x.png +0 -0
- package/docs/images/ssh-manager-cli-menu.png +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* A control plane with something in it, for screenshots, for the demo video, and
|
|
4
|
+
* for anyone who wants to see the interface without wiring up real servers first.
|
|
5
|
+
*
|
|
6
|
+
* ## Why there is a fake SSH server in here
|
|
7
|
+
*
|
|
8
|
+
* The screens worth showing — health, the file browser, a live terminal — are
|
|
9
|
+
* the ones that only exist when something answers on the other end. Pointing the
|
|
10
|
+
* demo at somebody's real infrastructure means the pictures leak it, and pointing
|
|
11
|
+
* it at nothing means five screenshots of empty states.
|
|
12
|
+
*
|
|
13
|
+
* So this starts a genuine ssh2 server on the loopback and lets the product talk
|
|
14
|
+
* to it for real: real SFTP over the wire, real exec, real shell. The *answers*
|
|
15
|
+
* are canned, and nothing else is. What you see is the product working, not a
|
|
16
|
+
* mockup of the product working.
|
|
17
|
+
*
|
|
18
|
+
* ## What is fictional, and what is not
|
|
19
|
+
*
|
|
20
|
+
* Fictional: three hostnames, the numbers the health commands report, the
|
|
21
|
+
* contents of a small file tree. Everything a viewer might mistake for real
|
|
22
|
+
* infrastructure is invented and obviously so — 127.0.0.1, `demo`, round numbers.
|
|
23
|
+
*
|
|
24
|
+
* Not fictional: the protocol, the pooling, the approval flow, the rendering,
|
|
25
|
+
* the transfers. A bug in any of those shows up here the same as in production,
|
|
26
|
+
* which is the point of demoing against a real server rather than a stub.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* node scripts/demo-env.mjs # start, print the URL, stay up
|
|
30
|
+
* node scripts/demo-env.mjs --port 7315
|
|
31
|
+
*/
|
|
32
|
+
import fs from 'fs';
|
|
33
|
+
import os from 'os';
|
|
34
|
+
import path from 'path';
|
|
35
|
+
import { execFileSync } from 'child_process';
|
|
36
|
+
// ssh2 is CommonJS: named imports do not resolve through the ESM bridge.
|
|
37
|
+
import ssh2 from 'ssh2';
|
|
38
|
+
import { ControlPlane } from '../src/control-plane.js';
|
|
39
|
+
import { SecretStore } from '../src/secret-store.js';
|
|
40
|
+
import { defaultSocketPath, buildRequest, requestDecision } from '../src/approval.js';
|
|
41
|
+
import { openStream } from '../src/live-stream.js';
|
|
42
|
+
|
|
43
|
+
const { Server, utils } = ssh2;
|
|
44
|
+
const { STATUS_CODE, OPEN_MODE } = utils.sftp;
|
|
45
|
+
|
|
46
|
+
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'ssh-manager-demo-'));
|
|
47
|
+
const teardown = [];
|
|
48
|
+
|
|
49
|
+
// A demo must never touch the operator's real vault or their real key.
|
|
50
|
+
process.env.SSH_MANAGER_HOME = scratch;
|
|
51
|
+
process.env.SSH_MANAGER_KEY_SOURCE = 'file';
|
|
52
|
+
|
|
53
|
+
/* ------------------------------------------------------------------ answers */
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* What the fake host says when asked.
|
|
57
|
+
*
|
|
58
|
+
* Keyed on a fragment of the command the product actually builds (see
|
|
59
|
+
* src/health-monitor.js), so if a builder changes shape this stops matching and
|
|
60
|
+
* the demo visibly degrades rather than quietly showing stale numbers.
|
|
61
|
+
*/
|
|
62
|
+
function respond(command, persona) {
|
|
63
|
+
const { cpu, memUsed, memTotal, disk, uptime, load } = persona;
|
|
64
|
+
const table = [
|
|
65
|
+
// The health screen sends one script with `=== SECTION ===` markers and
|
|
66
|
+
// parses the whole reply (buildComprehensiveHealthCheckCommand). Answering
|
|
67
|
+
// only the first section it recognises is how this first came back showing
|
|
68
|
+
// "reachable" and no gauges at all.
|
|
69
|
+
['=== CPU ===', () => [
|
|
70
|
+
'=== CPU ===', cpu.toFixed(1),
|
|
71
|
+
'=== MEMORY ===', JSON.stringify({
|
|
72
|
+
total: memTotal, used: memUsed, free: memTotal - memUsed,
|
|
73
|
+
percent: Number((memUsed * 100 / memTotal).toFixed(2)),
|
|
74
|
+
}),
|
|
75
|
+
'=== DISK ===', ...disk.map(d => JSON.stringify(d)),
|
|
76
|
+
'=== LOAD ===', load,
|
|
77
|
+
'=== UPTIME ===', uptime,
|
|
78
|
+
'=== NETWORK ===', '{"interface":"eth0:","rx_bytes":84213904,"tx_bytes":19288471}',
|
|
79
|
+
'',
|
|
80
|
+
].join('\n')],
|
|
81
|
+
// top -bn1 | ... | awk '{print 100 - $1}' → a bare float
|
|
82
|
+
['Cpu(s)', () => `${cpu.toFixed(1)}\n`],
|
|
83
|
+
// free -m | awk ... → one JSON object
|
|
84
|
+
['free -m', () => JSON.stringify({
|
|
85
|
+
total: memTotal, used: memUsed, free: memTotal - memUsed,
|
|
86
|
+
percent: (memUsed * 100 / memTotal).toFixed(2),
|
|
87
|
+
})],
|
|
88
|
+
// df -h | awk ... → one JSON object per line
|
|
89
|
+
['df -h', () => disk.map(d => JSON.stringify(d)).join('\n') + '\n'],
|
|
90
|
+
['/proc/net/dev', () =>
|
|
91
|
+
'{"interface":"eth0:","rx_bytes":84213904,"tx_bytes":19288471}\n'],
|
|
92
|
+
['load average', () => `${load}\n`],
|
|
93
|
+
// Matched before the health command's `uptime -p`, because a person in the
|
|
94
|
+
// shell types `uptime` and expects the familiar one-liner.
|
|
95
|
+
['uptime', () => ` ${new Date().toUTCString().slice(17, 22)} up ${uptime.replace(/^up /, '')},`
|
|
96
|
+
+ ` 2 users, load average: ${load}\n`],
|
|
97
|
+
['systemctl', () => 'ACTIVE\nENABLED\n1284\nactive (running) since\n'],
|
|
98
|
+
['ps aux', () =>
|
|
99
|
+
'{"user":"root","pid":1,"cpu":0.0,"mem":0.1,"vsz":168420,"rss":13284,"command":"/sbin/init"}\n' +
|
|
100
|
+
'{"user":"www-data","pid":842,"cpu":1.4,"mem":2.3,"vsz":214880,"rss":48120,"command":"nginx: worker process"}\n' +
|
|
101
|
+
'{"user":"postgres","pid":1104,"cpu":0.7,"mem":4.1,"vsz":398220,"rss":86440,"command":"postgres: checkpointer"}\n'],
|
|
102
|
+
['whoami', () => `${persona.user}\n`],
|
|
103
|
+
['hostname', () => `${persona.name}\n`],
|
|
104
|
+
];
|
|
105
|
+
const hit = table.find(([fragment]) => command.includes(fragment));
|
|
106
|
+
if (hit) return hit[1]();
|
|
107
|
+
|
|
108
|
+
// Anything else: enough of a shell to be convincing in a terminal recording.
|
|
109
|
+
if (/^\s*(ls|ll)\b/.test(command)) return 'app backups logs releases\n';
|
|
110
|
+
if (/^\s*pwd\b/.test(command)) return `/home/${persona.user}\n`;
|
|
111
|
+
if (/^\s*date\b/.test(command)) return new Date().toUTCString() + '\n';
|
|
112
|
+
if (/^\s*(echo)\s+/.test(command)) return command.replace(/^\s*echo\s+/, '') + '\n';
|
|
113
|
+
return '';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* -------------------------------------------------------------- the SFTP fs */
|
|
117
|
+
|
|
118
|
+
function serveSftp(sftp, root) {
|
|
119
|
+
const handles = new Map();
|
|
120
|
+
let counter = 0;
|
|
121
|
+
const real = p => path.join(root, path.normalize('/' + p));
|
|
122
|
+
const attrsOf = st => ({
|
|
123
|
+
mode: st.mode, size: st.size, uid: st.uid, gid: st.gid,
|
|
124
|
+
atime: Math.floor(st.atimeMs / 1000), mtime: Math.floor(st.mtimeMs / 1000),
|
|
125
|
+
});
|
|
126
|
+
const newHandle = value => {
|
|
127
|
+
const id = Buffer.from(`h${counter++}`);
|
|
128
|
+
handles.set(id.toString(), value);
|
|
129
|
+
return id;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
sftp.on('OPENDIR', (reqid, dir) => {
|
|
133
|
+
try {
|
|
134
|
+
handles.set(`d${counter}`, { entries: fs.readdirSync(real(dir)), dir, sent: false });
|
|
135
|
+
sftp.handle(reqid, Buffer.from(`d${counter++}`));
|
|
136
|
+
} catch { sftp.status(reqid, STATUS_CODE.NO_SUCH_FILE); }
|
|
137
|
+
});
|
|
138
|
+
sftp.on('READDIR', (reqid, handle) => {
|
|
139
|
+
const state = handles.get(handle.toString());
|
|
140
|
+
if (!state || state.sent) return sftp.status(reqid, STATUS_CODE.EOF);
|
|
141
|
+
state.sent = true;
|
|
142
|
+
sftp.name(reqid, state.entries.map(name => ({
|
|
143
|
+
filename: name, longname: name,
|
|
144
|
+
attrs: attrsOf(fs.lstatSync(path.join(real(state.dir), name))),
|
|
145
|
+
})));
|
|
146
|
+
});
|
|
147
|
+
// A browser that cannot stat shows every entry as a file of unknown size.
|
|
148
|
+
for (const event of ['STAT', 'LSTAT']) {
|
|
149
|
+
sftp.on(event, (reqid, target) => {
|
|
150
|
+
try { sftp.attrs(reqid, attrsOf(fs.lstatSync(real(target)))); }
|
|
151
|
+
catch { sftp.status(reqid, STATUS_CODE.NO_SUCH_FILE); }
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
sftp.on('FSTAT', (reqid, handle) => {
|
|
155
|
+
const state = handles.get(handle.toString());
|
|
156
|
+
try { sftp.attrs(reqid, attrsOf(fs.fstatSync(state.fd))); }
|
|
157
|
+
catch { sftp.status(reqid, STATUS_CODE.FAILURE); }
|
|
158
|
+
});
|
|
159
|
+
sftp.on('OPEN', (reqid, filename, flags) => {
|
|
160
|
+
try {
|
|
161
|
+
const mode = (flags & OPEN_MODE.WRITE) ? 'w' : 'r';
|
|
162
|
+
sftp.handle(reqid, newHandle({ fd: fs.openSync(real(filename), mode), pos: 0 }));
|
|
163
|
+
} catch { sftp.status(reqid, STATUS_CODE.NO_SUCH_FILE); }
|
|
164
|
+
});
|
|
165
|
+
sftp.on('READ', (reqid, handle, offset, length) => {
|
|
166
|
+
const state = handles.get(handle.toString());
|
|
167
|
+
const buf = Buffer.alloc(length);
|
|
168
|
+
const read = fs.readSync(state.fd, buf, 0, length, offset);
|
|
169
|
+
if (read === 0) return sftp.status(reqid, STATUS_CODE.EOF);
|
|
170
|
+
sftp.data(reqid, buf.subarray(0, read));
|
|
171
|
+
});
|
|
172
|
+
sftp.on('WRITE', (reqid, handle, offset, data) => {
|
|
173
|
+
fs.writeSync(handles.get(handle.toString()).fd, data, 0, data.length, offset);
|
|
174
|
+
sftp.status(reqid, STATUS_CODE.OK);
|
|
175
|
+
});
|
|
176
|
+
sftp.on('CLOSE', (reqid, handle) => {
|
|
177
|
+
const state = handles.get(handle.toString());
|
|
178
|
+
if (state?.fd !== undefined) { try { fs.closeSync(state.fd); } catch { /* fine */ } }
|
|
179
|
+
handles.delete(handle.toString());
|
|
180
|
+
sftp.status(reqid, STATUS_CODE.OK);
|
|
181
|
+
});
|
|
182
|
+
sftp.on('REALPATH', (reqid, given) => {
|
|
183
|
+
const resolved = given === '.' ? '/srv' : path.posix.normalize(given);
|
|
184
|
+
sftp.name(reqid, [{ filename: resolved, longname: resolved, attrs: {} }]);
|
|
185
|
+
});
|
|
186
|
+
sftp.on('MKDIR', (reqid, dir) => {
|
|
187
|
+
try { fs.mkdirSync(real(dir)); sftp.status(reqid, STATUS_CODE.OK); }
|
|
188
|
+
catch { sftp.status(reqid, STATUS_CODE.FAILURE); }
|
|
189
|
+
});
|
|
190
|
+
sftp.on('RENAME', (reqid, from, to) => {
|
|
191
|
+
try { fs.renameSync(real(from), real(to)); sftp.status(reqid, STATUS_CODE.OK); }
|
|
192
|
+
catch { sftp.status(reqid, STATUS_CODE.FAILURE); }
|
|
193
|
+
});
|
|
194
|
+
sftp.on('REMOVE', (reqid, file) => {
|
|
195
|
+
try { fs.unlinkSync(real(file)); sftp.status(reqid, STATUS_CODE.OK); }
|
|
196
|
+
catch { sftp.status(reqid, STATUS_CODE.FAILURE); }
|
|
197
|
+
});
|
|
198
|
+
sftp.on('RMDIR', (reqid, dir) => {
|
|
199
|
+
try { fs.rmdirSync(real(dir)); sftp.status(reqid, STATUS_CODE.OK); }
|
|
200
|
+
catch { sftp.status(reqid, STATUS_CODE.FAILURE); }
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* ------------------------------------------------------------------- the host */
|
|
205
|
+
|
|
206
|
+
function startHost(persona, root) {
|
|
207
|
+
const keyPath = path.join(scratch, `hostkey-${persona.name}`);
|
|
208
|
+
execFileSync('ssh-keygen', ['-t', 'ed25519', '-f', keyPath, '-N', '', '-q']);
|
|
209
|
+
|
|
210
|
+
const server = new Server({ hostKeys: [fs.readFileSync(keyPath)] }, client => {
|
|
211
|
+
client.on('authentication', ctx => ctx.accept());
|
|
212
|
+
client.on('ready', () => {
|
|
213
|
+
client.on('session', accept => {
|
|
214
|
+
const session = accept();
|
|
215
|
+
session.on('sftp', a => serveSftp(a(), root));
|
|
216
|
+
session.on('exec', (a, _reject, info) => {
|
|
217
|
+
const stream = a();
|
|
218
|
+
stream.write(respond(info.command, persona));
|
|
219
|
+
stream.exit(0);
|
|
220
|
+
stream.end();
|
|
221
|
+
});
|
|
222
|
+
// ssh2's client sends `pty-req` before `shell`, and a server that does
|
|
223
|
+
// not answer it fails the whole request — "Unable to request a
|
|
224
|
+
// pseudo-terminal", which is what this demo showed for a while. Only
|
|
225
|
+
// found by opening a shell and typing in it; every automated check
|
|
226
|
+
// until then had called the handler directly.
|
|
227
|
+
session.on('pty', accept => accept && accept());
|
|
228
|
+
session.on('window-change', accept => accept && accept());
|
|
229
|
+
|
|
230
|
+
// An interactive shell, just enough of one to type into on camera.
|
|
231
|
+
session.on('shell', a => {
|
|
232
|
+
const stream = a();
|
|
233
|
+
const prompt = `\x1b[32m${persona.user}@${persona.name}\x1b[0m:\x1b[34m~\x1b[0m$ `;
|
|
234
|
+
stream.write(`Linux ${persona.name} 6.8.0 x86_64\r\n`);
|
|
235
|
+
stream.write(`Last login: ${new Date().toUTCString()}\r\n\r\n${prompt}`);
|
|
236
|
+
let line = '';
|
|
237
|
+
stream.on('data', chunk => {
|
|
238
|
+
for (const ch of chunk.toString('utf8')) {
|
|
239
|
+
if (ch === '\r' || ch === '\n') {
|
|
240
|
+
stream.write('\r\n');
|
|
241
|
+
if (line.trim() === 'exit') { stream.exit(0); return stream.end(); }
|
|
242
|
+
const out = respond(line, persona);
|
|
243
|
+
if (out) stream.write(out.replace(/\n/g, '\r\n'));
|
|
244
|
+
line = '';
|
|
245
|
+
stream.write(prompt);
|
|
246
|
+
} else if (ch === '\x7f') { // backspace
|
|
247
|
+
if (line) { line = line.slice(0, -1); stream.write('\b \b'); }
|
|
248
|
+
} else if (ch === '\x03') { // ctrl-c
|
|
249
|
+
line = ''; stream.write('^C\r\n' + prompt);
|
|
250
|
+
} else {
|
|
251
|
+
line += ch; stream.write(ch);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
client.on('error', () => { /* a client hanging up is normal */ });
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
teardown.push(() => server.close());
|
|
262
|
+
return new Promise(resolve =>
|
|
263
|
+
server.listen(0, '127.0.0.1', () => resolve(server.address().port)));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* --------------------------------------------------------------------- setup */
|
|
267
|
+
|
|
268
|
+
/** A small file tree, so the browser has something with shape to show. */
|
|
269
|
+
function makeTree(root) {
|
|
270
|
+
const files = {
|
|
271
|
+
'srv/app/releases/2026-08-28/manifest.json': '{\n "release": "2026-08-28",\n "ok": true\n}\n',
|
|
272
|
+
'srv/app/releases/2026-08-21/manifest.json': '{\n "release": "2026-08-21",\n "ok": true\n}\n',
|
|
273
|
+
'srv/app/current/config.yml': 'workers: 4\ntimeout: 30\n',
|
|
274
|
+
'srv/app/current/app.log': 'ready\nserving on :8080\n',
|
|
275
|
+
'srv/backups/db-2026-08-28.sql.gz': 'x'.repeat(4096),
|
|
276
|
+
'srv/backups/db-2026-08-27.sql.gz': 'x'.repeat(4096),
|
|
277
|
+
'srv/logs/nginx/access.log': 'GET / 200\n'.repeat(40),
|
|
278
|
+
'srv/logs/nginx/error.log': '',
|
|
279
|
+
};
|
|
280
|
+
for (const [rel, body] of Object.entries(files)) {
|
|
281
|
+
const target = path.join(root, rel);
|
|
282
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
283
|
+
fs.writeFileSync(target, body);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const PERSONAS = [
|
|
288
|
+
{ name: 'production', user: 'deploy', group: 'production', cpu: 34.2, memUsed: 5312,
|
|
289
|
+
memTotal: 16008, uptime: 'up 4 weeks, 2 days', load: '0.42, 0.51, 0.48',
|
|
290
|
+
disk: [{ mount: '/', size: '80G', used: '38G', avail: '38G', percent: 51 },
|
|
291
|
+
{ mount: '/var', size: '200G', used: '64G', avail: '126G', percent: 34 }] },
|
|
292
|
+
{ name: 'staging', user: 'deploy', group: 'staging', cpu: 8.7, memUsed: 2140,
|
|
293
|
+
memTotal: 8192, uptime: 'up 6 days, 3 hours', load: '0.11, 0.09, 0.08',
|
|
294
|
+
disk: [{ mount: '/', size: '40G', used: '12G', avail: '26G', percent: 32 }] },
|
|
295
|
+
{ name: 'backup', user: 'root', group: 'infra', cpu: 61.5, memUsed: 3600,
|
|
296
|
+
memTotal: 4096, uptime: 'up 129 days', load: '1.84, 1.62, 1.40',
|
|
297
|
+
disk: [{ mount: '/', size: '32G', used: '9G', avail: '22G', percent: 30 },
|
|
298
|
+
{ mount: '/mnt/archive', size: '4.0T', used: '3.6T', avail: '380G', percent: 91 }] },
|
|
299
|
+
];
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Put something real in flight, so Waiting and Live have content.
|
|
303
|
+
*
|
|
304
|
+
* @param {string} url The control plane URL, token included
|
|
305
|
+
*/
|
|
306
|
+
async function seedActivity(url) {
|
|
307
|
+
// A command that trips the destructive check, left pending. requestDecision
|
|
308
|
+
// resolves when somebody decides or the deadline passes; we deliberately do
|
|
309
|
+
// not await it — the point is that it sits there.
|
|
310
|
+
const request = buildRequest(
|
|
311
|
+
{ name: 'production', host: '127.0.0.1', user: 'deploy', mode: 'unrestricted' },
|
|
312
|
+
'ssh_execute',
|
|
313
|
+
{ command: 'rm -rf /srv/app/releases/2026-08-21' },
|
|
314
|
+
'rm -rf /srv/app/releases/2026-08-21',
|
|
315
|
+
);
|
|
316
|
+
requestDecision(request, { timeoutMs: 60 * 60 * 1000 })
|
|
317
|
+
.catch(() => { /* nobody decided; the demo ended first */ });
|
|
318
|
+
|
|
319
|
+
// An open shell on staging, with a couple of commands already run, so the Live
|
|
320
|
+
// view has scrollback rather than a blank terminal.
|
|
321
|
+
// Every request carries the token, so build paths off the URL we were given
|
|
322
|
+
// rather than resolving against its origin — `new URL('/api/…', url)` drops
|
|
323
|
+
// the query string and every call comes back 401.
|
|
324
|
+
const base = new URL(url);
|
|
325
|
+
const api = (pathname, params = {}) => {
|
|
326
|
+
const target = new URL(pathname, base);
|
|
327
|
+
target.search = base.search;
|
|
328
|
+
for (const [key, value] of Object.entries(params)) target.searchParams.set(key, value);
|
|
329
|
+
return target;
|
|
330
|
+
};
|
|
331
|
+
const post = (pathname, body, params) => fetch(api(pathname, params), {
|
|
332
|
+
method: 'POST',
|
|
333
|
+
headers: { 'content-type': 'application/json' },
|
|
334
|
+
body: JSON.stringify(body),
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// A live command, through the same openStream() the engine uses. Nothing is
|
|
338
|
+
// faked into the registry: the socket carries it exactly as it would in
|
|
339
|
+
// anger, which is why the Live view can be trusted as a picture of the product.
|
|
340
|
+
const stream = openStream('production', 'tail -f /srv/logs/nginx/access.log');
|
|
341
|
+
if (stream) {
|
|
342
|
+
// The stream connects asynchronously; writing immediately loses the first
|
|
343
|
+
// lines, which is how this first came back with an empty scrollback.
|
|
344
|
+
await new Promise(r => setTimeout(r, 400));
|
|
345
|
+
const lines = [
|
|
346
|
+
'\u001b[2m2026-08-31T10:12:03Z\u001b[0m 192.0.2.44 GET /api/orders \u001b[32m200\u001b[0m 41ms',
|
|
347
|
+
'\u001b[2m2026-08-31T10:12:03Z\u001b[0m 192.0.2.19 GET /assets/app.css \u001b[32m200\u001b[0m 3ms',
|
|
348
|
+
'\u001b[2m2026-08-31T10:12:04Z\u001b[0m 198.51.100.7 POST /api/checkout \u001b[32m201\u001b[0m 128ms',
|
|
349
|
+
'\u001b[2m2026-08-31T10:12:05Z\u001b[0m 192.0.2.44 GET /api/orders/8821 \u001b[33m404\u001b[0m 7ms',
|
|
350
|
+
'\u001b[2m2026-08-31T10:12:06Z\u001b[0m 203.0.113.5 GET /health \u001b[32m200\u001b[0m 1ms',
|
|
351
|
+
];
|
|
352
|
+
for (const line of lines) {
|
|
353
|
+
await new Promise(r => setTimeout(r, 120));
|
|
354
|
+
stream.write('stdout', line + '\n');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
const open = await post('/api/terminal', { server: 'staging' });
|
|
360
|
+
if (open.ok) {
|
|
361
|
+
const { id } = await open.json();
|
|
362
|
+
for (const line of ['uptime\r', 'df -h /\r', 'ls\r']) {
|
|
363
|
+
await new Promise(r => setTimeout(r, 300));
|
|
364
|
+
await post('/api/terminal/input', { data: line }, { id });
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
} catch { /* the demo is still useful without it */ }
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async function main() {
|
|
371
|
+
const args = process.argv.slice(2);
|
|
372
|
+
const portFlag = args.indexOf('--port');
|
|
373
|
+
const port = portFlag >= 0 ? Number(args[portFlag + 1]) : 0;
|
|
374
|
+
|
|
375
|
+
const root = path.join(scratch, 'hosts');
|
|
376
|
+
makeTree(root);
|
|
377
|
+
|
|
378
|
+
// The file browser's left pane is *this* machine, so point HOME at a stand-in.
|
|
379
|
+
// Without this the screenshots publish whatever happens to be in the
|
|
380
|
+
// maintainer's home directory — which is how the first set of README images
|
|
381
|
+
// had to be thrown away and taken again.
|
|
382
|
+
// Under /Users/Shared rather than $TMPDIR: the breadcrumb is part of the
|
|
383
|
+
// picture, and `Users > Shared > ssh-manager-demo` reads like a home
|
|
384
|
+
// directory where `/var/folders/0g/_1g568_j7lg51…` reads like a fault.
|
|
385
|
+
// Removed on exit with the rest of the scratch.
|
|
386
|
+
const home = fs.existsSync('/Users/Shared')
|
|
387
|
+
? path.join('/Users/Shared', 'ssh-manager-demo')
|
|
388
|
+
: path.join(scratch, 'home', 'demo');
|
|
389
|
+
fs.rmSync(home, { recursive: true, force: true });
|
|
390
|
+
for (const dir of ['Desktop', 'Documents', 'Downloads', 'Projects/api', 'Projects/website']) {
|
|
391
|
+
fs.mkdirSync(path.join(home, dir), { recursive: true });
|
|
392
|
+
}
|
|
393
|
+
fs.writeFileSync(path.join(home, 'Documents', 'runbook.md'), '# Runbook\n');
|
|
394
|
+
fs.writeFileSync(path.join(home, 'Projects', 'api', 'deploy.sh'), '#!/bin/sh\necho deploying\n');
|
|
395
|
+
fs.writeFileSync(path.join(home, 'Projects', 'website', 'index.html'), '<h1>hello</h1>\n');
|
|
396
|
+
process.env.HOME = home;
|
|
397
|
+
|
|
398
|
+
// Into the vault rather than the environment: the Servers screen manages what
|
|
399
|
+
// is *in the vault*, so an env-only server would run fine and show up nowhere.
|
|
400
|
+
const store = new SecretStore(path.join(scratch, 'vault.json'));
|
|
401
|
+
for (const persona of PERSONAS) {
|
|
402
|
+
const sshPort = await startHost(persona, root);
|
|
403
|
+
store.setServer(persona.name, {
|
|
404
|
+
host: '127.0.0.1',
|
|
405
|
+
port: sshPort,
|
|
406
|
+
user: persona.user,
|
|
407
|
+
password: 'demo',
|
|
408
|
+
group: persona.group,
|
|
409
|
+
defaultDir: '/srv',
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const plane = new ControlPlane({ socketPath: defaultSocketPath(), port, auditPaths: [] });
|
|
414
|
+
const { url } = await plane.start();
|
|
415
|
+
|
|
416
|
+
console.log(`
|
|
417
|
+
Demo control plane running — three fake hosts on the loopback.
|
|
418
|
+
|
|
419
|
+
${url}
|
|
420
|
+
|
|
421
|
+
app view: ${url}${url.includes('?') ? '&' : '?'}shell=macos
|
|
422
|
+
|
|
423
|
+
Nothing here touches your own servers or your own vault: home is ${scratch}.
|
|
424
|
+
Ctrl-C to stop; the scratch directory goes with it.
|
|
425
|
+
`);
|
|
426
|
+
|
|
427
|
+
// Waiting and Live are empty screens until something is actually happening, and
|
|
428
|
+
// an empty screen is a bad screenshot and a worse demo. So put real work in
|
|
429
|
+
// flight: a destructive command genuinely paused on the approval socket, and a
|
|
430
|
+
// shell genuinely open on one of the hosts. Both go through the same code an
|
|
431
|
+
// agent would; neither is drawn.
|
|
432
|
+
await seedActivity(url);
|
|
433
|
+
|
|
434
|
+
// Dropping a file on the Dock icon only happens in the packaged application,
|
|
435
|
+
// so the browser has no way to reach that code path. With this set, the demo
|
|
436
|
+
// announces the same event the desktop shell would, which is how the dialog
|
|
437
|
+
// that asks "send it where?" can be seen and tested without a build.
|
|
438
|
+
if (process.env.SSH_MANAGER_DEMO_DROP) {
|
|
439
|
+
// Repeated, because a page that opens later would otherwise miss the one
|
|
440
|
+
// announcement and the dialog would look broken rather than un-triggered.
|
|
441
|
+
const paths = process.env.SSH_MANAGER_DEMO_DROP.split(',').map(p => p.trim());
|
|
442
|
+
const timer = setInterval(() => plane.announce({ type: 'dropped-files', paths }), 12000);
|
|
443
|
+
timer.unref();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const stop = async () => {
|
|
447
|
+
for (const fn of teardown) { try { fn(); } catch { /* going away anyway */ } }
|
|
448
|
+
await plane.stop();
|
|
449
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
450
|
+
if (home.startsWith('/Users/Shared/')) fs.rmSync(home, { recursive: true, force: true });
|
|
451
|
+
process.exit(0);
|
|
452
|
+
};
|
|
453
|
+
process.on('SIGINT', stop);
|
|
454
|
+
process.on('SIGTERM', stop);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
main().catch(error => {
|
|
458
|
+
console.error(`Demo failed to start: ${error.message}`);
|
|
459
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
460
|
+
process.exit(1);
|
|
461
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Wrap the raw UI captures in a window, so a README reader sees a product rather
|
|
4
|
+
than a rectangle of pixels.
|
|
5
|
+
|
|
6
|
+
Two frames, because the thing genuinely runs two ways and they do not look the
|
|
7
|
+
same to the person using it:
|
|
8
|
+
|
|
9
|
+
browser a tab pointed at the local control plane — what `npx mcp-ssh-manager
|
|
10
|
+
--ui` gives you
|
|
11
|
+
app the packaged desktop build, whose window is `titleBarStyle:
|
|
12
|
+
'hiddenInset'`: no title bar at all, traffic lights floating over the
|
|
13
|
+
sidebar's top row at (18, 18). Those numbers are read off
|
|
14
|
+
desktop/electron/main.js (`trafficLightPosition`) rather than
|
|
15
|
+
invented, so the picture keeps matching the product when the product
|
|
16
|
+
moves.
|
|
17
|
+
|
|
18
|
+
Composited with Pillow rather than rendered through headless Chrome: Chrome 152
|
|
19
|
+
does not return from --headless on this machine, and a compositor we control is
|
|
20
|
+
one less thing that can quietly stop working before a release.
|
|
21
|
+
|
|
22
|
+
Everything below is in device pixels. The captures are 2x, so a 12pt CSS
|
|
23
|
+
traffic light is 24px here.
|
|
24
|
+
|
|
25
|
+
Usage: python3 scripts/frame-screenshots.py [name ...] (default: every v4-*.png)
|
|
26
|
+
"""
|
|
27
|
+
import pathlib
|
|
28
|
+
import sys
|
|
29
|
+
|
|
30
|
+
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
|
31
|
+
|
|
32
|
+
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
33
|
+
IMAGES = ROOT / 'docs' / 'images'
|
|
34
|
+
RAW = IMAGES / '.raw'
|
|
35
|
+
FONT = '/System/Library/Fonts/SFNS.ttf'
|
|
36
|
+
|
|
37
|
+
SCALE = 2
|
|
38
|
+
PAD = 44 * SCALE # room for the shadow to fall into
|
|
39
|
+
BAR = 42 * SCALE # browser chrome height
|
|
40
|
+
LIGHT = 12 * SCALE # traffic light diameter
|
|
41
|
+
GAP = 8 * SCALE
|
|
42
|
+
|
|
43
|
+
# Warm neutrals, pulled toward the interface's own palette so the frame reads as
|
|
44
|
+
# part of the same object rather than a stock mockup dropped around it.
|
|
45
|
+
CHROME_TOP, CHROME_BOT = (243, 240, 238), (234, 230, 227)
|
|
46
|
+
HAIRLINE = (217, 211, 206)
|
|
47
|
+
PILL_BG, PILL_EDGE, PILL_TEXT = (255, 255, 255), (222, 216, 211), (111, 103, 99)
|
|
48
|
+
LIGHTS = [(255, 95, 87), (254, 188, 46), (40, 200, 64)]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def rounded_mask(size, radius):
|
|
52
|
+
mask = Image.new('L', size, 0)
|
|
53
|
+
ImageDraw.Draw(mask).rounded_rectangle([0, 0, size[0] - 1, size[1] - 1],
|
|
54
|
+
radius=radius, fill=255)
|
|
55
|
+
return mask
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def vertical_gradient(size, top, bottom):
|
|
59
|
+
w, h = size
|
|
60
|
+
strip = Image.new('RGB', (1, h))
|
|
61
|
+
px = strip.load()
|
|
62
|
+
for y in range(h):
|
|
63
|
+
t = y / max(h - 1, 1)
|
|
64
|
+
px[0, y] = tuple(round(a + (b - a) * t) for a, b in zip(top, bottom))
|
|
65
|
+
return strip.resize(size, Image.BILINEAR)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def draw_lights(canvas, left, top):
|
|
69
|
+
"""The three macOS window buttons, with the faint inner edge they really have."""
|
|
70
|
+
d = ImageDraw.Draw(canvas, 'RGBA')
|
|
71
|
+
for i, colour in enumerate(LIGHTS):
|
|
72
|
+
x = left + i * (LIGHT + GAP)
|
|
73
|
+
d.ellipse([x, top, x + LIGHT, top + LIGHT], fill=(*colour, 255),
|
|
74
|
+
outline=(0, 0, 0, 28), width=max(1, SCALE // 2))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def browser_bar(width):
|
|
78
|
+
"""Chrome: traffic lights on the left, one address pill centred."""
|
|
79
|
+
bar = vertical_gradient((width, BAR), CHROME_TOP, CHROME_BOT).convert('RGBA')
|
|
80
|
+
d = ImageDraw.Draw(bar)
|
|
81
|
+
d.line([(0, BAR - 1), (width, BAR - 1)], fill=HAIRLINE, width=1)
|
|
82
|
+
draw_lights(bar, 16 * SCALE, (BAR - LIGHT) // 2)
|
|
83
|
+
|
|
84
|
+
pw, ph = 340 * SCALE, 24 * SCALE
|
|
85
|
+
px, py = (width - pw) // 2, (BAR - ph) // 2
|
|
86
|
+
d.rounded_rectangle([px, py, px + pw, py + ph], radius=6 * SCALE,
|
|
87
|
+
fill=PILL_BG, outline=PILL_EDGE, width=1)
|
|
88
|
+
|
|
89
|
+
# A padlock, then the address. The real URL carries a session token; showing
|
|
90
|
+
# the origin alone is the honest short form and keeps the token out of a
|
|
91
|
+
# picture that ends up in a README.
|
|
92
|
+
label = 'localhost:7315'
|
|
93
|
+
font = ImageFont.truetype(FONT, 11 * SCALE + 1)
|
|
94
|
+
tw = d.textlength(label, font=font)
|
|
95
|
+
lock_w = 9 * SCALE
|
|
96
|
+
start = px + (pw - (lock_w + 6 * SCALE + tw)) / 2
|
|
97
|
+
ly = py + ph / 2
|
|
98
|
+
d.rounded_rectangle([start, ly - 3 * SCALE, start + lock_w, ly + 3 * SCALE],
|
|
99
|
+
radius=1.4 * SCALE, fill=(138, 130, 125))
|
|
100
|
+
d.arc([start + 1.6 * SCALE, ly - 6.4 * SCALE, start + lock_w - 1.6 * SCALE, ly],
|
|
101
|
+
start=180, end=360, fill=(138, 130, 125), width=round(1.2 * SCALE))
|
|
102
|
+
d.text((start + lock_w + 6 * SCALE, ly), label, font=font,
|
|
103
|
+
fill=PILL_TEXT, anchor='lm')
|
|
104
|
+
return bar
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def frame(src: pathlib.Path, kind: str, out: pathlib.Path) -> pathlib.Path:
|
|
108
|
+
shot = Image.open(src).convert('RGB')
|
|
109
|
+
w, h = shot.size
|
|
110
|
+
bar_h = BAR if kind == 'browser' else 0
|
|
111
|
+
radius = (10 if kind == 'browser' else 12) * SCALE
|
|
112
|
+
|
|
113
|
+
window = Image.new('RGBA', (w, h + bar_h), (252, 252, 252, 255))
|
|
114
|
+
if bar_h:
|
|
115
|
+
window.paste(browser_bar(w), (0, 0))
|
|
116
|
+
window.paste(shot, (0, bar_h))
|
|
117
|
+
if kind == 'app':
|
|
118
|
+
# hiddenInset puts the lights over the content itself, at (18, 18):
|
|
119
|
+
# centred in the rail's 48px top row, which `?shell=macos` keeps clear.
|
|
120
|
+
draw_lights(window, 18 * SCALE, 18 * SCALE)
|
|
121
|
+
|
|
122
|
+
window.putalpha(rounded_mask(window.size, radius))
|
|
123
|
+
|
|
124
|
+
canvas = Image.new('RGBA', (w + PAD * 2, h + bar_h + PAD * 2), (0, 0, 0, 0))
|
|
125
|
+
|
|
126
|
+
# Two shadows: a tight one that seats the window, and a wide soft one that
|
|
127
|
+
# gives it height. One alone reads as either a sticker or a smudge.
|
|
128
|
+
for blur, offset, alpha, inset in ((3 * SCALE, 1 * SCALE, 40, 0),
|
|
129
|
+
(22 * SCALE, 14 * SCALE, 52, 6 * SCALE)):
|
|
130
|
+
layer = Image.new('RGBA', canvas.size, (0, 0, 0, 0))
|
|
131
|
+
ImageDraw.Draw(layer).rounded_rectangle(
|
|
132
|
+
[PAD + inset, PAD + offset + inset,
|
|
133
|
+
PAD + w - inset, PAD + h + bar_h + offset - inset],
|
|
134
|
+
radius=radius, fill=(28, 22, 18, alpha))
|
|
135
|
+
canvas.alpha_composite(layer.filter(ImageFilter.GaussianBlur(blur)))
|
|
136
|
+
|
|
137
|
+
canvas.alpha_composite(window, (PAD, PAD))
|
|
138
|
+
|
|
139
|
+
# A hairline so the light window keeps an edge against a light README.
|
|
140
|
+
edge = Image.new('RGBA', canvas.size, (0, 0, 0, 0))
|
|
141
|
+
ImageDraw.Draw(edge).rounded_rectangle(
|
|
142
|
+
[PAD, PAD, PAD + w, PAD + h + bar_h], radius=radius,
|
|
143
|
+
outline=(28, 22, 18, 38), width=max(1, SCALE // 2))
|
|
144
|
+
canvas.alpha_composite(edge)
|
|
145
|
+
|
|
146
|
+
canvas.save(out, optimize=True)
|
|
147
|
+
return out
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def main():
|
|
151
|
+
"""Frame each raw capture with the chrome it was captured for.
|
|
152
|
+
|
|
153
|
+
The pairing is not cosmetic: a capture taken with `?shell=macos` already
|
|
154
|
+
leaves the rail's top row clear for the window buttons, and one taken
|
|
155
|
+
without it does not. Framing an app capture as a browser (or the
|
|
156
|
+
reverse) puts the traffic lights on top of the sidebar's own controls.
|
|
157
|
+
"""
|
|
158
|
+
raws = RAW.glob('*.png')
|
|
159
|
+
names = sys.argv[1:]
|
|
160
|
+
if names:
|
|
161
|
+
raws = [RAW / f'{n}.png' for n in names]
|
|
162
|
+
made = 0
|
|
163
|
+
for src in sorted(raws):
|
|
164
|
+
if not src.exists():
|
|
165
|
+
print(f' ! {src.name}: pas de source')
|
|
166
|
+
continue
|
|
167
|
+
kind = 'app' if src.stem.endswith('-app') else 'browser'
|
|
168
|
+
out = frame(src, kind, IMAGES / src.name)
|
|
169
|
+
print(f' {out.name:<28} {out.stat().st_size // 1024:>4} Ko')
|
|
170
|
+
made += 1
|
|
171
|
+
if not made:
|
|
172
|
+
sys.exit(f'aucune capture dans {RAW} — lancer scripts/capture-screenshots.mjs')
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
if __name__ == '__main__':
|
|
176
|
+
main()
|