-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplugin.js
More file actions
1546 lines (1536 loc) · 61.4 KB
/
Copy pathplugin.js
File metadata and controls
1546 lines (1536 loc) · 61.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as sdk from "@hermes/plugin-sdk";
import { useEffect, useRef, useState } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
const ID = "hermes-ssh";
const VERSION = "0.3.3";
// Public verification key only. The release signing key never ships to users.
const UPDATE_KEY = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEdDcg2pf4qQg4y89ZLfoIhfJqyKP+bJMA0Q0YVDK0VAbAgyVi5CaodDuUgibOqTx1zQg9xrXdzYbCvpgMjIFBCw==";
const UPDATE_REPO = "Adolanium/hermes-ssh";
const UPDATE_LIMIT = 500_000;
const updateState = sdk.atom({ busy: false, message: "", error: "", backup: null, available: null, restoreAvailable: null });
const UPDATE_LOCK = Symbol.for("hermes-ssh.update-lock");
function updatePatch(value) {
if (!disposed) updateState.set({ ...updateState.get(), ...value });
}
function versionParts(version) {
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(version))
throw new Error("The release has an invalid version.");
const parts = version.split(".").map(Number);
if (!parts.every(Number.isSafeInteger)) throw new Error("Invalid release version.");
return parts;
}
function newerVersion(next, current) {
const a = versionParts(next), b = versionParts(current);
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
return false;
}
function decode64(value) {
if (typeof value !== "string" || value.length > 12_000)
throw new Error("Invalid update signature.");
return Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
}
async function digest(text) {
return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text))),
(b) => b.toString(16).padStart(2, "0")).join("");
}
async function verifyRelease(release) {
if (release.draft || release.prerelease) throw new Error("This is not a stable release.");
const match = String(release.body || "").match(/```hermes-ssh-update\s*\n([\s\S]*?)\n```/);
if (!match) throw new Error("This release has no signed update. The installed version is unchanged.");
const envelope = JSON.parse(match[1]);
const payload = decode64(envelope.payload);
const key = await crypto.subtle.importKey("spki", decode64(UPDATE_KEY),
{ name: "ECDSA", namedCurve: "P-256" }, false, ["verify"]);
if (!await crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, key,
decode64(envelope.signature), payload))
throw new Error("The update signature is invalid. Nothing was installed.");
const info = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(payload));
versionParts(info.version);
if (info.schema !== 1 || info.plugin !== ID || release.tag_name !== `v${info.version}` ||
!/^[a-f0-9]{40}$/.test(info.commit) || !/^[a-f0-9]{64}$/.test(info.sha256) ||
!Number.isInteger(info.bytes) || info.bytes < 1 || info.bytes > UPDATE_LIMIT)
throw new Error("The signed release metadata is invalid.");
return info;
}
async function fetchUpdateText(url, limit) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30_000);
try {
const response = await fetch(url, { signal: controller.signal, credentials: "omit",
referrerPolicy: "no-referrer", cache: "no-store", redirect: "error" });
if (response.status === 404) {
const error = new Error("The release file is unavailable on GitHub. Try again later.");
error.status = 404;
throw error;
}
if (response.status === 403 || response.status === 429)
throw new Error("GitHub is limiting update checks. Try again later.");
if (!response.ok) throw new Error(`Update download failed (${response.status}). Try again later.`);
if (Number(response.headers.get("content-length")) > limit || !response.body)
throw new Error("The update download is too large or empty.");
const reader = response.body.getReader();
const chunks = [];
let length = 0;
while (true) {
const { done, value } = await reader.read();
if (done) break;
length += value.length;
if (length > limit) { await reader.cancel(); throw new Error("The update download is too large."); }
chunks.push(value);
}
const bytes = new Uint8Array(length);
let offset = 0;
for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.length; }
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
} catch (error) {
if (error.name === "AbortError") throw new Error("Update check timed out. Try again.");
throw error;
} finally { clearTimeout(timeout); }
}
function updateDesktop() {
const desktop = globalThis.window?.hermesDesktop;
if (!desktop?.desktopPluginsRoot || !desktop?.readFileText || !desktop?.writeTextFile || !desktop?.renamePath)
throw new Error("Open this plugin in Hermes Desktop to update it. This Desktop must support local plugin files.");
return desktop;
}
async function readUpdateFile(desktop, path) {
const result = await desktop.readFileText(path);
if (result.truncated || typeof result.text !== "string" || new TextEncoder().encode(result.text).length > UPDATE_LIMIT)
throw new Error("The plugin file could not be read completely.");
return result.text;
}
async function updateLocation(desktop) {
const root = await desktop.desktopPluginsRoot();
if (typeof root !== "string" || !root.trim()) throw new Error("Desktop's local plugin folder is unavailable.");
return root.replace(/[\\/]+$/, "") + "/" + ID;
}
function backupKey(dir) { return "updater:backup:" + dir; }
function validBackup(record) {
return record && /^plugin\.backup-[a-f0-9-]{36}\.js$/.test(record.name) && /^[a-f0-9]{64}$/.test(record.sha256);
}
async function loadUpdateBackup() {
try {
const dir = await updateLocation(updateDesktop());
const record = await context?.storage.get(backupKey(dir), null);
updatePatch({ backup: validBackup(record) ? record : null });
} catch { /* SSH remains usable on Desktop versions without updater APIs. */ }
}
// Only Electron-local filesystem APIs are used here, never shell.exec or an SSH profile.
// Stage and verify first. Renaming preserves the old file if the final step fails.
async function replacePlugin(desktop, dir, before, next, storage) {
const file = dir + "/plugin.js";
const stage = "plugin.staged-" + crypto.randomUUID() + ".js";
const backup = { name: "plugin.backup-" + crypto.randomUUID() + ".js", sha256: await digest(before) };
await desktop.writeTextFile(dir + "/" + stage, next);
if (await readUpdateFile(desktop, dir + "/" + stage) !== next)
throw new Error("The staged update could not be verified. The installed version is unchanged.");
if (disposed || state.get().busy || state.get().panel || await updateLocation(desktop) !== dir || await readUpdateFile(desktop, file) !== before)
throw new Error("The Desktop profile or installed plugin changed. Reload Desktop and check again.");
const previousRecord = await storage.get(backupKey(dir), null);
let moved = false;
try {
await storage.set(backupKey(dir), backup);
await desktop.renamePath(file, backup.name);
moved = true;
await desktop.renamePath(dir + "/" + stage, "plugin.js");
} catch (error) {
try { if (moved) await desktop.renamePath(dir + "/" + backup.name, "plugin.js"); }
catch { throw new Error(`Update failed. Restore ${backup.name} to plugin.js in ${dir}, then reload Desktop.`); }
await storage.set(backupKey(dir), previousRecord);
throw new Error("Update failed. The previous plugin was restored. " + error.message);
}
return backup;
}
function dismissUpdate() {
if (!updateState.get().busy) updatePatch({ available: null, restoreAvailable: null, message: "", error: "" });
}
async function runUpdate(action = "check") {
if (globalThis[UPDATE_LOCK] || state.get().busy || state.get().panel) return;
if (!["check", "install", "restore", "restore-confirm"].includes(action)) return;
const offered = updateState.get().available;
const restoreOffered = updateState.get().restoreAvailable;
if (action === "install" && !offered) return;
if (action === "restore-confirm" && !restoreOffered) return;
globalThis[UPDATE_LOCK] = true;
updatePatch({ busy: true, error: "", available: null, restoreAvailable: null, message: action === "restore-confirm" ? "Restoring the previous version…" : action === "restore" ? "Checking the backup…" : action === "install" ? "Verifying the selected update…" : "Checking for updates…" });
try {
const desktop = updateDesktop();
const dir = await updateLocation(desktop);
const storage = context.storage;
const before = await readUpdateFile(desktop, dir + "/plugin.js");
// A renamed or duplicate installation must never overwrite another copy.
if (!before.includes(`const VERSION = "${VERSION}";`) || !before.includes(`const UPDATE_KEY = "${UPDATE_KEY}";`))
throw new Error("This isn't the loaded plugin's installation. Install it under hermes-ssh/plugin.js and reload Desktop.");
let next, message;
if (action === "restore" || action === "restore-confirm") {
const backup = await storage.get(backupKey(dir), null);
if (!validBackup(backup)) throw new Error("No previous version is available.");
if (action === "restore-confirm" && (restoreOffered.dir !== dir ||
restoreOffered.sha256 !== await digest(before) ||
restoreOffered.backup.name !== backup.name || restoreOffered.backup.sha256 !== backup.sha256))
throw new Error("The installation or backup changed. Choose Restore previous version again.");
next = await readUpdateFile(desktop, dir + "/" + backup.name);
if (await digest(next) !== backup.sha256) throw new Error("The backup has changed. It was not restored.");
if (action === "restore") {
const version = next.match(/const VERSION = "([0-9]+\.[0-9]+\.[0-9]+)";/)?.[1];
updatePatch({ restoreAvailable: { dir, sha256: await digest(before), backup: { ...backup } },
message: `Restore ${version ? "Hermes SSH v" + version : "the previous version"}? This replaces the current plugin. Saved machines and SSH keys are preserved.` });
return;
}
message = "Previous version restored. Reload desktop plugins if the page hasn't refreshed.";
} else {
let release = offered?.release;
if (action === "check") {
try {
release = JSON.parse(await fetchUpdateText(`https://api.github.com/repos/${UPDATE_REPO}/releases/latest`, 100_000));
} catch (error) {
if (error.status !== 404) throw error;
updatePatch({ message: `No update is published yet. You're still on v${VERSION}.` });
return;
}
}
const info = await verifyRelease(release);
if (!newerVersion(info.version, VERSION)) {
updatePatch({ message: `You're up to date. Hermes SSH v${VERSION}.` });
return;
}
if (action === "check") {
updatePatch({ available: { release, version: info.version, dir, sha256: await digest(before) },
message: `Hermes SSH v${info.version} is available. Would you like to update?` });
return;
}
// Consent is for this signed release and this installation, never a later release.
if (offered.dir !== dir || offered.sha256 !== await digest(before))
throw new Error("The Desktop profile or installed plugin changed. Check for updates again.");
updatePatch({ message: `Downloading v${info.version}…` });
next = await fetchUpdateText(`https://raw.githubusercontent.com/${UPDATE_REPO}/${info.commit}/plugin.js`, UPDATE_LIMIT);
if (new TextEncoder().encode(next).length !== info.bytes || await digest(next) !== info.sha256 ||
!next.includes(`const VERSION = "${info.version}";`) || !next.includes(`const ID = "${ID}";`))
throw new Error("The update does not match the signed release. Nothing was installed.");
message = `Updated to v${info.version}. Reload desktop plugins if the page hasn't refreshed.`;
}
updatePatch({ message: "Saving the previous version and applying the update…" });
const backup = await replacePlugin(desktop, dir, before, next, storage);
updatePatch({ backup, message });
} catch (error) {
updatePatch({ error: error.message || "Couldn't reach GitHub. Check your connection and try again.", message: "" });
} finally {
globalThis[UPDATE_LOCK] = false;
updatePatch({ busy: false });
}
}
const ROUTE = "/ssh-connections";
const host = sdk.host;
const state = sdk.atom({
machines: [],
origin: "",
loading: true,
error: "",
selected: null,
panel: false,
busy: "",
notice: "",
});
let context = null;
let disposed = false;
let routeVersion = 0;
let managementRoute = null;
let returnFocus = null;
function ownerKey() {
const owner = host.state.focusedSessionOwner?.get();
return JSON.stringify(
owner || {
connectionId: host.state.connectionId?.get(),
profile: host.state.profile?.get(),
},
);
}
// All operations use stock gateway methods. Users install only this file.
let platformPromise;
const endpoint = (m) => JSON.stringify([m.host, m.user, m.port, m.key, m.cwd]);
async function rpc(method, params = {}) {
const route = await managementRoute;
if (!route)
throw new Error(
"Reconnect the originating Hermes host before managing SSH.",
);
return host.requestProfile(route, method, params, 100000);
}
async function scope() {
const route = await managementRoute;
if (!route) throw new Error("The originating Hermes host is unavailable.");
return JSON.stringify([route.connectionId, route.targetProfile]);
}
async function records() {
return context.storage.get("machines:" + (await scope()), []);
}
async function persist(list) {
context.storage.set("machines:" + (await scope()), list);
}
async function getMachine(id) {
const value = (await records()).find((m) => m.id === id);
if (!value)
throw new Error(
"Machine no longer exists. Open Connections and select it again.",
);
return value;
}
async function replaceMachine(m, expected) {
const list = await records();
const old = list.find((x) => x.id === m.id);
if (expected && JSON.stringify(old) !== JSON.stringify(expected))
throw new Error("This connection changed during setup. Select it again.");
await persist([...list.filter((x) => x.id !== m.id), m]);
return m;
}
async function shell(command) {
const r = await rpc("shell.exec", { command });
if (r.code !== 0)
throw new Error(
r.stderr ||
r.stdout ||
"SSH command failed. Check access and your SSH agent.",
);
return String(r.stdout || "").trim();
}
async function windows() {
platformPromise ||= shell("echo %OS%").then((s) => s === "Windows_NT");
return platformPromise;
}
function quote(value, win) {
value = String(value);
if (/[\r\n\0]/.test(value))
throw new Error("Line breaks are not allowed in SSH settings.");
if (win) {
if (/["%!^&|<>]/.test(value))
throw new Error(
"This Windows path contains unsupported shell characters. Choose a simple path.",
);
return '"' + value + '"';
}
return "'" + value.replaceAll("'", "'\"'\"'") + "'";
}
function validateMachine(m) {
const record = Object.fromEntries(
["name", "host", "user", "cwd", "key"].map((k) => [
k,
String(m[k] || "").trim(),
]),
);
record.cwd ||= "~";
record.port = Number(m.port || 22);
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,47}$/.test(record.name))
throw new Error(
"Use a name with letters, numbers, hyphens or underscores, up to 48 characters.",
);
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.:%-]*$/.test(record.host))
throw new Error("Enter a hostname, SSH alias or IP address.");
if (!/^[a-zA-Z0-9_][a-zA-Z0-9_.@\\-]*$/.test(record.user))
throw new Error("Enter the remote account's username.");
if (!Number.isInteger(record.port) || record.port < 1 || record.port > 65535)
throw new Error("Port must be between 1 and 65535.");
if (!/^(\/|~\/|~$)/.test(record.cwd) || /[\r\n\0]/.test(record.cwd))
throw new Error("Use an absolute remote folder or ~/folder.");
if (record.key && !/^(\/|[a-zA-Z]:[\\/])/.test(record.key))
throw new Error("Use an absolute private-key path on the Hermes host.");
return record;
}
async function testConnection(m) {
if (!m.trusted)
throw new Error(
"Review first-use host trust and file synchronization before connecting.",
);
const win = await windows();
const args = [
"ssh",
"-T",
"-o",
"BatchMode=yes",
"-o",
"StrictHostKeyChecking=accept-new",
"-o",
"ConnectTimeout=10",
"-p",
String(m.port),
];
if (m.key) args.push("-i", m.key);
args.push("-l", m.user, m.host, "bash", "-c", "pwd");
const cwd = await shell(args.map((x) => quote(x, win)).join(" "));
if (!cwd.startsWith("/"))
throw new Error(
"The remote machine did not return a Bash working directory.",
);
const resolved =
m.cwd === "~" ? cwd : m.cwd.startsWith("~/") ? cwd + m.cwd.slice(1) : m.cwd;
const folderArgs = args.slice(0, -3);
folderArgs.push("test", "-d", quote(resolved, false), "-a", "-x", quote(resolved, false));
await shell(folderArgs.map((x) => quote(x, win)).join(" "));
return replaceMachine(
{
...m,
last_test: { at: Date.now() / 1000, os: "Bash available", cwd: resolved },
},
m,
);
}
async function api(operation, payload = {}) {
if (operation === "list")
return { machines: await records(), origin: "the originating Hermes host" };
if (operation === "save") {
const list = await records(),
old = list.find((x) => x.id === payload.id);
const clean = validateMachine(payload);
if (
list.some(
(x) =>
x.id !== old?.id && x.name.toLowerCase() === clean.name.toLowerCase(),
)
)
throw new Error("A machine already uses that name.");
if (payload.id && !old)
throw new Error("This connection was removed. Add it again.");
const same = old && endpoint(old) === endpoint(clean);
return replaceMachine(
{
...clean,
id: old?.id || crypto.randomUUID(),
trusted: !!(same && old.trusted),
last_test: same ? old.last_test : null,
},
old,
);
}
if (operation === "remove") {
await persist((await records()).filter((x) => x.id !== payload.id));
return {};
}
if (operation === "scan") return { token: payload.id, fingerprints: [] };
if (operation === "trust") {
const m = await getMachine(payload.token);
return replaceMachine({ ...m, trusted: true }, m);
}
if (operation === "test") return testConnection(await getMachine(payload.id));
if (operation === "keys")
return {
keys: context.storage.get("keys:" + (await scope()), []),
agent_ready: false,
};
if (operation === "public-key") {
const win = await windows();
const path = payload.path;
if (!path || !/^(\/|[a-zA-Z]:[\\/])/.test(path))
throw new Error("Enter an absolute key path first.");
const key = await shell(
(win ? "type " : "cat ") + quote(path + ".pub", win),
);
if (!/^(ssh-|ecdsa-)/.test(key) || key.includes("PRIVATE KEY"))
throw new Error("The matching .pub file is not an SSH public key.");
return key;
}
if (operation === "keygen") {
if (payload.confirm_unencrypted !== true)
throw new Error("Confirm creation of a key without a passphrase.");
const win = await windows();
const home = await shell(
win ? "echo %USERPROFILE%" : "printf '%s' \"$HOME\"",
);
const folder = home + (win ? "\\.ssh" : "/.ssh");
const q = quote(folder, win);
await shell(win ? `if not exist ${q} mkdir ${q}` : `mkdir -p ${q}`);
const path =
folder +
(win ? "\\" : "/") +
"hermes_desktop_" +
crypto.randomUUID().replaceAll("-", "").slice(0, 16);
await shell(`ssh-keygen -q -t ed25519 -N "" -f ${quote(path, win)}`);
const public_key = await api("public-key", { path });
const key = { name: path.split(/[\\/]/).at(-1), path, public_key };
const sk = "keys:" + (await scope());
context.storage.set(sk, [...context.storage.get(sk, []), key]);
return key;
}
if (operation === "prepare") {
const machine = await testConnection(await getMachine(payload.id));
const profile =
"ssh-" +
machine.name.slice(0, 18).toLowerCase() +
"-" +
crypto.randomUUID().slice(0, 8);
const created = await rpc("profiles.create", {
name: profile,
description: `SSH: ${machine.name} (${machine.host})`,
no_skills: true,
mirror_credentials: true,
});
if (!created.ok)
throw new Error("Hermes could not create the SSH workspace.");
const terminal = {
backend: "ssh",
ssh_host: machine.host,
ssh_user: machine.user,
ssh_port: machine.port,
ssh_key: machine.key,
cwd: machine.last_test.cwd,
timeout: 120,
};
// This is a newly created profile. Replace its default terminal section as
// one mapping before Desktop starts any task on it.
const result = await rpc("cli.exec", {
argv: [
"--profile",
profile,
"config",
"set",
"--force",
"terminal",
JSON.stringify(terminal),
],
});
if (result.blocked || result.code !== 0)
throw new Error(
result.hint ||
result.output ||
"Workspace configuration failed. The task was not opened.",
);
const current = await getMachine(machine.id);
if (endpoint(current) !== endpoint(machine))
throw new Error(
"The machine changed during connection. Select it again.",
);
return { profile, machine };
}
throw new Error("Unknown SSH operation.");
}
function patch(value) {
if (!disposed) state.set({ ...state.get(), ...value });
}
async function refresh() {
const version = ++routeVersion;
try {
const data = await api("list");
if (version === routeVersion) patch({ ...data, loading: false, error: "" });
} catch (e) {
if (version === routeVersion) patch({ loading: false, error: e.message });
}
}
function openPanel(machine = null) {
returnFocus = typeof document === "undefined" ? null : document.activeElement;
patch({ selected: machine, panel: true, error: "", notice: "" });
host.navigate(ROUTE);
}
function closePanel() {
patch({ panel: false, selected: null });
requestAnimationFrame(() => {
if (returnFocus?.isConnected) returnFocus.focus();
else document.querySelector(".hssh-heading button")?.focus();
});
}
async function connect(machine) {
if (state.get().busy) return;
const origin = ownerKey();
patch({
busy: machine.id,
error: "",
notice: `Connecting to ${machine.name}…`,
});
try {
const ready = await api("prepare", { id: machine.id });
if (disposed || origin !== ownerKey())
throw new Error(
"The active Hermes connection changed. Select the machine again to open it.",
);
const routes = await host.profileRoutes();
const connection = (await managementRoute)?.connectionId;
const route = routes.find(
(r) =>
r.profile === ready.profile &&
(!connection || r.connectionId === connection),
);
if (!route)
throw new Error(
"The SSH profile was created. Restart Hermes Desktop to discover it, then connect again.",
);
host.newChat(route);
patch({ notice: `Workspace ready on ${machine.name}`, panel: false });
} catch (e) {
patch({ error: e.message, notice: "" });
host.navigate(ROUTE);
} finally {
patch({ busy: "" });
}
}
async function middleware(draft) {
const match = /^\/ssh(?:\s+(.*))?\s*$/i.exec(draft.text.trim());
if (!match) return draft;
// Always consume our command, including errors. Throwing middleware is
// passed to the model by core; a connection failure must not do that.
try {
if (draft.attachments?.length)
throw new Error("Send attachments after opening the SSH workspace.");
host.navigate(ROUTE);
const name = (match[1] || "").trim();
const data = await api("list");
patch({ ...data, loading: false, error: "" });
if (!name) {
patch({ panel: !data.machines.length });
return null;
}
const machine = data.machines.find(
(x) => x.name.toLowerCase() === name.toLowerCase(),
);
if (!machine) {
openPanel({ name });
return null;
}
if (!machine.trusted) {
openPanel(machine);
return null;
}
await connect(machine);
} catch (e) {
patch({ error: e.message, loading: false });
host.navigate(ROUTE);
}
return null;
}
const CSS = `
.hssh{--ssh-bg:var(--ui-surface-background,Canvas);--ssh-raised:var(--ui-bg-secondary,Canvas);--ssh-text:var(--ui-text-primary,CanvasText);--ssh-muted:var(--ui-text-secondary,GrayText);--ssh-line:var(--ui-stroke-secondary,ButtonBorder);color:var(--ssh-text);background:var(--ssh-bg);font:13px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;height:100%;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--ssh-line) transparent;container-type:inline-size}
.hssh *{box-sizing:border-box}.hssh ::selection{background:var(--ui-accent);color:var(--ssh-bg)}.hssh button,.hssh input,.hssh select{font:inherit}.hssh button{cursor:pointer}.hssh button:disabled{cursor:default;opacity:.48}.hssh :focus-visible{outline:2px solid var(--ui-accent);outline-offset:4px}.hssh input{caret-color:var(--ui-accent)}
.hssh-main{max-width:1160px;margin:auto;padding:52px 48px 32px}.hssh-heading{display:flex;align-items:center;justify-content:space-between;gap:24px}.hssh h1{font-size:30px;line-height:1.2;letter-spacing:-.035em;font-weight:600;margin:0}.hssh-subtitle{color:var(--ssh-muted);margin:9px 0 0;max-width:60ch}.hssh-tabs{display:flex;gap:24px;border-bottom:1px solid var(--ssh-line);margin:30px 0 30px}.hssh-tab{padding:0 1px 13px;border-bottom:2px solid var(--ssh-text);display:flex;align-items:center;gap:8px;font-weight:600}.hssh-tab small{font-size:11px;font-weight:400;color:var(--ssh-muted);margin-left:3px}
.hssh-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:36px;padding:8px 14px;border:1px solid var(--ssh-line);border-radius:8px;background:transparent;color:var(--ssh-text);white-space:nowrap;transition:background .16s ease,border-color .16s ease}.hssh-btn:hover:not(:disabled){background:var(--ssh-raised);border-color:var(--ssh-muted)}.hssh-btn.primary{background:var(--ssh-text);color:var(--ssh-bg);border-color:transparent;font-weight:600}.hssh-btn.primary:hover:not(:disabled){opacity:.88;background:var(--ssh-text)}.hssh-btn.quiet{border-color:transparent;padding:6px 8px}.hssh-btn.danger{color:var(--ui-red)}.hssh-icon{width:17px;height:17px;display:inline-block;flex:none}.hssh-icon svg{display:block;width:100%;height:100%}
.hssh-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:28px;align-items:start}.hssh-grid.editing{grid-template-columns:minmax(230px,.8fr) minmax(330px,1.2fr)}.hssh-section-line{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}.hssh-section-line h2{font-size:13px;font-weight:600;margin:0}.hssh-section-line span{font-size:12px;color:var(--ssh-muted)}
.hssh-empty{border:1px solid var(--ssh-line);border-radius:14px;min-height:330px;display:flex;align-items:center;justify-content:center;padding:35px 25px;text-align:center}.hssh-empty h2{font-size:21px;letter-spacing:-.025em;font-weight:550;margin:24px 0 8px}.hssh-empty p{max-width:39ch;color:var(--ssh-muted);margin:0 auto 23px}.hssh-empty .hssh-diagram{width:206px;height:72px;margin:0 auto;color:var(--ssh-muted)}.hssh-diagram .endpoint{color:var(--ssh-text)}.hssh-diagram .signal{stroke-dasharray:3 5;animation:ssh-flow 3s linear infinite}@keyframes ssh-flow{to{stroke-dashoffset:-32}}.hssh-grid.editing .hssh-empty{min-height:230px}.hssh-grid.editing .hssh-empty .hssh-diagram{width:155px}.hssh-grid.editing .hssh-empty h2{font-size:18px}
.hssh-machine{display:flex;align-items:center;gap:17px;padding:22px 2px;border-bottom:1px solid var(--ssh-line);min-width:0}.hssh-machine:first-child{border-top:1px solid var(--ssh-line)}.hssh-machine-icon{width:42px;height:42px;display:grid;place-items:center;background:var(--ssh-raised);border-radius:10px;flex:none}.hssh-machine-icon .hssh-icon{width:22px;height:22px}.hssh-machine-info{min-width:0;flex:1}.hssh-machine-name{font-size:15px;font-weight:600;letter-spacing:-.015em;overflow-wrap:anywhere}.hssh-machine-address{font-size:12px;color:var(--ssh-muted);overflow-wrap:anywhere;margin-top:2px}.hssh-machine-status{font-size:11px;margin-top:7px;display:flex;gap:5px;align-items:center;color:var(--ssh-muted)}.hssh-machine-status .hssh-icon{width:13px;height:13px}.hssh-machine-actions{display:flex;gap:5px;align-items:center}.hssh-grid.editing .hssh-machine{flex-wrap:wrap;padding:18px 0;gap:12px}.hssh-grid.editing .hssh-machine-actions{margin-left:54px}.hssh-folder{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;color:var(--ssh-muted);margin-top:5px;overflow-wrap:anywhere}
.hssh-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;color:var(--ssh-muted);font-size:12px;padding:22px 0;margin-top:12px}.hssh-footer code,.hssh-code{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;background:var(--ssh-raised);padding:4px 7px;border-radius:4px;color:var(--ssh-text)}.hssh-footer span{display:flex;gap:7px;align-items:center}.hssh-note{font-size:12px;color:var(--ssh-muted);max-width:65ch}.hssh-notice{padding:12px 15px;border:1px solid var(--ssh-line);border-radius:8px;margin:0 0 22px;display:flex;align-items:flex-start;gap:10px;overflow-wrap:anywhere}.hssh-notice.error{color:var(--ui-red)}.hssh-notice p{margin:0;flex:1}.hssh-notice .hssh-btn{min-height:24px;padding:0 3px}
.hssh-panel{border:1px solid var(--ssh-line);border-radius:14px;overflow:hidden;animation:ssh-panel .22s cubic-bezier(.16,1,.3,1)}@keyframes ssh-panel{from{clip-path:inset(0 0 5% 0);opacity:.5}to{clip-path:inset(0);opacity:1}}.hssh-panel-head{padding:22px 24px 18px;display:flex;justify-content:space-between;gap:12px;align-items:flex-start;background:var(--ssh-raised)}.hssh-panel-head h2{font-size:19px;font-weight:600;letter-spacing:-.025em;margin:0}.hssh-panel-head p{font-size:12px;color:var(--ssh-muted);margin:4px 0 0}.hssh-panel-body{padding:24px}.hssh-steps{display:flex;gap:18px;align-items:center;margin:0 0 25px;font-size:12px;color:var(--ssh-muted)}.hssh-step{display:flex;gap:6px;align-items:center}.hssh-step.current{color:var(--ssh-text);font-weight:600}.hssh-step .hssh-icon{width:14px;height:14px}.hssh-form{display:flex;flex-direction:column;gap:18px}.hssh-field{display:flex;flex-direction:column;gap:6px;min-width:0}.hssh-field>span{font-weight:550;font-size:12px}.hssh-field input,.hssh-field select{width:100%;min-height:39px;border:1px solid var(--ssh-line);border-radius:7px;padding:8px 11px;background:var(--ssh-bg);color:var(--ssh-text);min-width:0}.hssh-field input::placeholder{color:var(--ssh-muted);opacity:.85}.hssh-field small{font-size:11px;color:var(--ssh-muted)}.hssh-fields{display:grid;grid-template-columns:1fr 90px;gap:12px}.hssh-input-row{display:flex;gap:8px;align-items:center}.hssh-input-row .hssh-field{flex:1}.hssh-panel-foot{margin-top:25px;display:flex;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid var(--ssh-line);padding-top:20px}.hssh-inline-link{border:0;background:none;padding:0;text-decoration:underline;text-underline-offset:3px;color:var(--ssh-muted);font-size:12px}.hssh-key-actions{display:flex;flex-wrap:wrap;gap:12px}.hssh-key-copy{background:var(--ssh-raised);border-radius:8px;padding:12px;overflow-wrap:anywhere;font:11px/1.7 ui-monospace,SFMono-Regular,Consolas,monospace;margin:12px 0}.hssh-fingerprint{font:11px/1.8 ui-monospace,SFMono-Regular,Consolas,monospace;overflow-wrap:anywhere;padding:13px 0;border-bottom:1px solid var(--ssh-line)}.hssh-fingerprint span{display:block;color:var(--ssh-muted);font:11px/1.8 inherit}.hssh-check{display:flex;gap:9px;align-items:flex-start;font-size:12px;cursor:pointer;margin-top:16px}.hssh-check input{margin-top:4px;accent-color:var(--ui-accent)}.hssh-success{display:flex;align-items:center;gap:12px;margin-bottom:20px}.hssh-success .hssh-icon{width:26px;height:26px;color:var(--ui-green)}.hssh-success h3{font-size:17px;font-weight:550;margin:0}.hssh-success p{margin:2px 0 0;color:var(--ssh-muted);font-size:12px}.hssh-details{margin:0}.hssh-details>div{display:flex;justify-content:space-between;gap:18px;border-bottom:1px solid var(--ssh-line);padding:11px 0}.hssh-details dt{font-size:12px;color:var(--ssh-muted)}.hssh-details dd{margin:0;font-size:12px;text-align:right;overflow-wrap:anywhere}.hssh-remove{margin-top:18px;padding-top:17px;border-top:1px solid var(--ssh-line)}.hssh-remove p{font-size:12px;color:var(--ssh-muted)}.hssh-loading{padding:80px 0;color:var(--ssh-muted);text-align:center}.hssh-origin{font-size:11px;color:var(--ssh-muted)}
@container(max-width:850px){.hssh-main{padding:32px 25px}.hssh-grid.editing{grid-template-columns:1fr}.hssh-grid.editing>section:first-child{display:none}.hssh-panel{max-width:580px;width:100%;justify-self:center}.hssh-heading{gap:12px}.hssh h1{font-size:27px}}
@container(max-width:480px){.hssh-main{padding:24px 18px}.hssh-heading{align-items:flex-start}.hssh-heading>.hssh-btn{padding:8px 10px}.hssh-subtitle{font-size:12px}.hssh-footer{flex-direction:column;align-items:flex-start;gap:9px}.hssh-machine{flex-wrap:wrap}.hssh-machine-actions{margin-left:59px}.hssh-panel-head,.hssh-panel-body{padding:18px}.hssh-empty{min-height:300px}.hssh-steps{gap:12px}}
.hssh-updates{border-top:1px solid var(--ssh-line);margin-top:28px;padding-top:20px}.hssh-update-row{display:flex;justify-content:space-between;align-items:center;gap:18px;flex-wrap:wrap}.hssh-update-row strong{font-size:12px;font-weight:600}.hssh-update-row p,.hssh-update-status{font-size:12px;color:var(--ssh-muted);margin:4px 0;overflow-wrap:anywhere}.hssh-update-status{margin-top:12px}.hssh-update-status.error{color:var(--ui-red)}.hssh-updates>.hssh-btn{margin-top:10px}
@media(prefers-reduced-motion:reduce){.hssh *{animation:none!important;transition:none!important}}
`;
// Geometry only: a consistent set of small interface symbols.
const paths = {
server: [
"M4 3h16v7H4z",
"M4 14h16v7H4z",
"M8 6.5h.01M8 17.5h.01M12 6.5h5M12 17.5h5",
],
plus: ["M12 5v14M5 12h14"],
arrow: ["M5 12h14M13 6l6 6-6 6"],
close: ["M6 6l12 12M18 6L6 18"],
check: ["M5 12l4 4L19 6"],
shield: ["M12 3l8 3v6c0 5-8 9-8 9s-8-4-8-9V6z", "M8 12l3 3 5-6"],
key: ["M14 10a5 5 0 1 0-4 4l9 7 3-3-3-3 1-2-3-1z"],
folder: ["M3 6h7l2 3h9v11H3z"],
terminal: ["M5 6l6 6-6 6M13 18h6"],
more: ["M5 12h.01M12 12h.01M19 12h.01"],
copy: ["M9 9h12v12H9zM15 5V3H3v12h2"],
refresh: ["M20 7v5h-5M4 17v-5h5", "M6 6a8 8 0 0 1 13 1M18 18A8 8 0 0 1 5 17"],
alert: ["M12 3L2 21h20zM12 9v5M12 17h.01"],
back: ["M19 12H5M11 6l-6 6 6 6"],
};
function Icon({ name }) {
return jsx("span", {
className: "hssh-icon",
"aria-hidden": true,
children: jsx("svg", {
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: 1.5,
strokeLinecap: "round",
strokeLinejoin: "round",
children: (paths[name] || paths.server).map((d, i) =>
jsx("path", { d }, i),
),
}),
});
}
function Button({ children, icon, variant = "", ...props }) {
return jsxs("button", {
type: "button",
className: `hssh-btn ${variant}`,
...props,
children: [icon && jsx(Icon, { name: icon }), children],
});
}
function Field({ label, hint, ...props }) {
return jsxs("label", {
className: "hssh-field",
children: [
jsx("span", { children: label }),
jsx("input", props),
hint && jsx("small", { children: hint }),
],
});
}
function Diagram() {
return jsxs("svg", {
className: "hssh-diagram",
viewBox: "0 0 206 72",
fill: "none",
stroke: "currentColor",
strokeWidth: 1.5,
"aria-hidden": true,
children: [
jsx("path", {
className: "endpoint",
d: "M10 17h44v31H10zM5 54h54M20 54l2-6h20l2 6M152 12h44v20h-44zM152 40h44v20h-44zM158 22h2M158 50h2M169 22h19M169 50h19",
}),
jsx("path", { d: "M69 36h65", className: "signal" }),
jsx("path", { d: "M126 31l8 5-8 5" }),
],
});
}
function Notice({ error, children, dismiss }) {
return jsxs("div", {
className: `hssh-notice ${error ? "error" : ""}`,
role: error ? "alert" : "status",
children: [
jsx(Icon, { name: error ? "alert" : "check" }),
jsx("p", { children }),
dismiss &&
jsx(Button, {
icon: "close",
variant: "quiet",
"aria-label": "Dismiss message",
onClick: dismiss,
}),
],
});
}
function Empty({ onAdd }) {
return jsx("div", {
className: "hssh-empty",
children: jsxs("div", {
children: [
jsx(Diagram, {}),
jsx("h2", { children: "Your next workspace is out there." }),
jsx("p", {
children:
"Connect a machine once. Let Hermes work with its files, tools, and terminal whenever you need it.",
}),
jsx(Button, {
variant: "primary",
icon: "plus",
onClick: onAdd,
children: "Add your first machine",
}),
],
}),
});
}
function Machine({ machine, busy }) {
return jsxs("article", {
className: "hssh-machine",
children: [
jsx("div", {
className: "hssh-machine-icon",
children: jsx(Icon, { name: "server" }),
}),
jsxs("div", {
className: "hssh-machine-info",
children: [
jsx("div", {
className: "hssh-machine-name",
children: machine.name,
}),
jsx("div", {
className: "hssh-machine-address",
children: `${machine.user ? machine.user + "@" : ""}${machine.host}${machine.port !== 22 ? ":" + machine.port : ""}`,
}),
jsx("div", { className: "hssh-folder", children: machine.cwd }),
jsxs("div", {
className: "hssh-machine-status",
children: [
jsx(Icon, { name: machine.last_test ? "check" : "shield" }),
machine.last_test
? `Connected ${new Date(machine.last_test.at * 1000).toLocaleDateString()}`
: machine.trusted
? "Ready to test access"
: "Setup required",
],
}),
],
}),
jsxs("div", {
className: "hssh-machine-actions",
children: [
jsx(Button, {
onClick: () =>
machine.trusted ? connect(machine) : openPanel(machine),
disabled: !!busy,
children: busy === machine.id ? "Connecting…" : "Connect",
}),
jsx(Button, {
variant: "quiet",
icon: "more",
"aria-label": `Edit ${machine.name}`,
onClick: () => openPanel(machine),
disabled: !!busy,
}),
],
}),
],
});
}
function Setup({ selected, onClose }) {
const [form, setForm] = useState({
name: "",
host: "",
user: "",
port: 22,
cwd: "~",
key: "",
...selected,
});
const [stage, setStage] = useState("details");
const [working, setWorking] = useState("");
const [error, setError] = useState("");
const [scan, setScan] = useState(null);
const [accepted, setAccepted] = useState(false);
const [keyInfo, setKeyInfo] = useState({ keys: [], agent_ready: false });
const [publicKey, setPublicKey] = useState("");
const [createKey, setCreateKey] = useState(false);
const [remove, setRemove] = useState(false);
const [copied, setCopied] = useState(false);
const stepFocus = useRef(null);
useEffect(() => {
api("keys")
.then(setKeyInfo)
.catch(() => {});
}, []);
useEffect(() => {
if (stage !== "details") stepFocus.current?.focus();
}, [stage]);
function field(name) {
return {
value: form[name],
onChange: (e) => {
setForm({ ...form, [name]: e.target.value });
setError("");
},
};
}
async function perform(label, fn) {
setWorking(label);
setError("");
try {
await fn();
} catch (e) {
setError(e.message);
} finally {
setWorking("");
}
}
async function save() {
await perform("Saving…", async () => {
const saved = await api("save", form);
setForm(saved);
await refresh();
if (saved.trusted) {
const tested = await api("test", { id: saved.id });
setForm(tested);
setStage("ready");
await refresh();
} else {
setScan(await api("scan", { id: saved.id }));
setStage("trust");
}
});
}
async function trust() {
await perform("Testing connection…", async () => {
const trusted = await api("trust", { token: scan.token });
setForm(trusted);
const tested = await api("test", { id: trusted.id });
setForm(tested);
setStage("ready");
await refresh();
});
}
async function copyKey() {
const ok = await context.os.writeClipboard(publicKey);
if (ok) {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} else
setError("Clipboard unavailable. Select and copy the public key below.");
}
const details = jsxs("form", {
className: "hssh-form",
onSubmit: (e) => {
e.preventDefault();
save();
},
children: [
jsx(Field, {
label: "Machine name",
placeholder: "my-machine-1",
...field("name"),
autoFocus: true,
required: true,
maxLength: 48,
hint: "The name you use with /ssh.",
}),
jsx(Field, {
label: "Host",
placeholder: "192.168.1.42 or devbox.example.com",
...field("host"),
required: true,
}),
jsxs("div", {
className: "hssh-fields",
children: [
jsx(Field, {
label: "Username",
placeholder: "Remote account username",
required: true,
...field("user"),
}),
jsx(Field, {
label: "Port",
type: "number",
min: 1,
max: 65535,
...field("port"),
required: true,
}),
],
}),
jsx(Field, {
label: "Remote folder",
placeholder: "~/projects",
...field("cwd"),
required: true,
}),
jsxs("label", {
className: "hssh-field",
children: [
jsx("span", { children: "Authentication" }),
jsx("select", {
value: form.key || "",
onChange: (e) => {
setForm({ ...form, key: e.target.value });
setPublicKey(
keyInfo.keys.find((k) => k.path === e.target.value)
?.public_key || "",
);
},
children: [
jsx("option", {
value: "",
children: "SSH agent / existing SSH configuration",
}),
...keyInfo.keys.map((k) =>
jsx("option", { value: k.path, children: k.name }, k.path),
),
...(form.key && !keyInfo.keys.some((k) => k.path === form.key)
? [
jsx(
"option",
{ value: form.key, children: form.key },
"custom",
),
]
: []),
],
}),
jsx("small", {
children: keyInfo.agent_ready
? "Your SSH agent has an identity loaded."
: "For encrypted keys, unlock your SSH agent before connecting.",
}),
],
}),
jsx(Field, {
label: "Private key path",
placeholder: "Optional · use SSH agent",
...field("key"),
hint: "Path on the originating Hermes host. Private keys never enter chat.",
}),
jsxs("div", {
className: "hssh-key-actions",
children: [
jsx("button", {
type: "button",
className: "hssh-inline-link",
onClick: () => setCreateKey(!createKey),
children: "Create a dedicated key",
}),
form.key &&
jsx("button", {
type: "button",
className: "hssh-inline-link",
onClick: () =>
perform("Reading public key…", async () => {
setPublicKey(await api("public-key", { path: form.key }));
}),
children: "Show public key",
}),
],
}),
createKey &&
jsxs("div", {
children: [
jsx("p", {
className: "hssh-note",
children:
"Creates an Ed25519 key without a passphrase using OpenSSH. To use a passphrase or hardware key, choose an existing key instead.",
}),
jsx(Button, {
disabled: !!working,
onClick: () =>
perform("Creating key…", async () => {
const k = await api("keygen", { confirm_unencrypted: true });
setForm({ ...form, key: k.path });
setPublicKey(k.public_key);
setKeyInfo(await api("keys"));
setCreateKey(false);
}),
icon: "key",
children: "Create key without passphrase",
}),