@yunuseon/kayra 0.14.0 → 0.16.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/ansible/ansible.cfg +6 -3
- package/ansible/callback_plugins/kayra.py +299 -0
- package/cli/dist/cli.js +165 -31
- package/cli/dist/commands/app-check.js +1 -1
- package/cli/dist/commands/index.js +52 -0
- package/cli/dist/commands/server.js +68 -49
- package/cli/dist/commands/status.js +181 -30
- package/cli/dist/commands/validate.js +92 -31
- package/cli/dist/deployer/answers.js +21 -0
- package/cli/dist/deployer/ctl.js +20 -6
- package/cli/dist/gather.js +9 -5
- package/cli/dist/interpret.js +104 -61
- package/cli/dist/main.js +100 -75
- package/cli/dist/net.js +52 -0
- package/cli/dist/plan.js +37 -4
- package/cli/dist/ui/explain.js +37 -0
- package/cli/dist/ui/line.js +39 -0
- package/cli/dist/ui/progress.js +144 -0
- package/cli/dist/ui/terminal.js +104 -0
- package/cli/dist/ui/text.js +73 -0
- package/cli/dist/ui/views.js +129 -0
- package/cli/dist/validate.js +8 -3
- package/cli/dist/web/assets/index-3W_NFATj.css +1 -0
- package/cli/dist/web/assets/index-DRFX9Q77.js +2 -0
- package/cli/dist/web/index.html +15 -0
- package/package.json +3 -2
- package/scripts/agent/guard.sh +2 -0
- package/scripts/local/verify.sh +2 -2
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** Optique's rule too, so help and kayra agree: a nonempty FORCE_COLOR, else no NO_COLOR, then a terminal. */
|
|
2
|
+
export const colors = (tty, env) => {
|
|
3
|
+
if ((env["FORCE_COLOR"] ?? "") !== "")
|
|
4
|
+
return true;
|
|
5
|
+
if ((env["NO_COLOR"] ?? "") !== "" || env["NODE_DISABLE_COLORS"] !== undefined)
|
|
6
|
+
return false;
|
|
7
|
+
return tty && env["TERM"] !== "dumb";
|
|
8
|
+
};
|
|
9
|
+
// OSC 9 is a notification in these, and OSC 9;4 a progress bar in some; elsewhere either may print as text.
|
|
10
|
+
const notifying = ["iTerm.app", "WezTerm", "ghostty"];
|
|
11
|
+
const showingProgress = ["WezTerm", "ghostty"];
|
|
12
|
+
const linking = ["iTerm.app", "WezTerm", "ghostty", "vscode"];
|
|
13
|
+
export const screen = (stream, env) => {
|
|
14
|
+
const tty = stream.isTTY === true;
|
|
15
|
+
const live = tty && env["TERM"] !== "dumb" && (env["CI"] ?? "") === "";
|
|
16
|
+
const program = env["TERM_PROGRAM"] ?? "";
|
|
17
|
+
// tmux and screen swallow what they do not know, or pass it to the wrong pane.
|
|
18
|
+
const direct = live && env["TMUX"] === undefined && env["STY"] === undefined;
|
|
19
|
+
return {
|
|
20
|
+
colors: colors(tty, env),
|
|
21
|
+
live,
|
|
22
|
+
// A pseudo-terminal may report 0.
|
|
23
|
+
columns: stream.columns !== undefined && stream.columns > 0 ? stream.columns : Number(env["COLUMNS"]) || 80,
|
|
24
|
+
title: live,
|
|
25
|
+
notifications: direct && notifying.includes(program),
|
|
26
|
+
progressBar: direct && (showingProgress.includes(program) || env["WT_SESSION"] !== undefined),
|
|
27
|
+
links: direct && linking.includes(program),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const printable = (text) => text.replace(/\p{Cc}/gu, " ");
|
|
31
|
+
const osc = (body) => `\u001b]${body}\u0007`;
|
|
32
|
+
export const escapes = {
|
|
33
|
+
clearLine: "\r\u001b[2K",
|
|
34
|
+
/** xterm's title stack: the shell's title comes back when kayra is done. */
|
|
35
|
+
pushTitle: "\u001b[22;0t",
|
|
36
|
+
popTitle: "\u001b[23;0t",
|
|
37
|
+
title: (text) => osc(`0;${printable(text)}`),
|
|
38
|
+
notify: (text) => osc(`9;${printable(text)}`),
|
|
39
|
+
progress: (percent) => osc(`9;4;1;${String(Math.round(percent))}`),
|
|
40
|
+
progressDone: osc("9;4;0;0"),
|
|
41
|
+
link: (text, href) => `${osc(`8;;${printable(href)}`)}${text}${osc("8;;")}`,
|
|
42
|
+
/** To the start of the line `count` lines up; nothing for none, since CSI 0 F still moves one. */
|
|
43
|
+
up: (count) => (count > 0 ? `\u001b[${String(count)}F` : ""),
|
|
44
|
+
clearDown: "\u001b[J",
|
|
45
|
+
};
|
|
46
|
+
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
47
|
+
const frameOf = (ms) => frames[Math.floor(ms / 80) % frames.length] ?? "";
|
|
48
|
+
/** Draws a line in place, again every frame, until stopped; stopping clears it. */
|
|
49
|
+
export const spinner = (write, draw) => {
|
|
50
|
+
const started = performance.now();
|
|
51
|
+
const frame = () => {
|
|
52
|
+
const ms = performance.now() - started;
|
|
53
|
+
write(`${escapes.clearLine}${draw(frameOf(ms), ms)}`);
|
|
54
|
+
};
|
|
55
|
+
frame();
|
|
56
|
+
const timer = setInterval(frame, 80);
|
|
57
|
+
return () => {
|
|
58
|
+
clearInterval(timer);
|
|
59
|
+
write(escapes.clearLine);
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const tick = (ms) => new Promise((resolve) => {
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
resolve(undefined);
|
|
65
|
+
}, ms);
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Draws a block of lines in place, again every frame and as each update lands,
|
|
69
|
+
* until all have; then clears it and returns the state they made. Each line
|
|
70
|
+
* must fit the terminal: one that wraps throws the redraw off.
|
|
71
|
+
*/
|
|
72
|
+
export const watch = async (write, initial, updates, draw) => {
|
|
73
|
+
const started = performance.now();
|
|
74
|
+
const redraw = (state, drawn) => {
|
|
75
|
+
const lines = draw(state, frameOf(performance.now() - started));
|
|
76
|
+
write(`${escapes.up(drawn)}${lines.map((line) => `${escapes.clearLine}${line}\n`).join("")}${escapes.clearDown}`);
|
|
77
|
+
return lines.length;
|
|
78
|
+
};
|
|
79
|
+
const go = async (state, waiting, drawn) => {
|
|
80
|
+
const shown = redraw(state, drawn);
|
|
81
|
+
if (waiting.length === 0) {
|
|
82
|
+
write(`${escapes.up(shown)}${escapes.clearDown}`);
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
const next = await Promise.race([...waiting.map((each) => each.landed), tick(80)]);
|
|
86
|
+
return next === undefined
|
|
87
|
+
? go(state, waiting, shown)
|
|
88
|
+
: go(next.update(state), waiting.filter((each) => each.id !== next.id), shown);
|
|
89
|
+
};
|
|
90
|
+
return go(initial, updates.map((update, id) => ({ id, landed: update.then((done) => ({ id, update: done })) })), 0);
|
|
91
|
+
};
|
|
92
|
+
/** What watch() returns, drawn nowhere: for a stream that is no terminal. */
|
|
93
|
+
export const settle = async (initial, updates) => (await Promise.all(updates)).reduce((state, update) => update(state), initial);
|
|
94
|
+
/** Each state as the updates land, in the order they land: for a viewer elsewhere (the web interface). */
|
|
95
|
+
export const follow = async (initial, updates, each) => {
|
|
96
|
+
const go = async (state, waiting) => {
|
|
97
|
+
each(state);
|
|
98
|
+
if (waiting.length === 0)
|
|
99
|
+
return state;
|
|
100
|
+
const next = await Promise.race(waiting.map((one) => one.landed));
|
|
101
|
+
return go(next.update(state), waiting.filter((one) => one.id !== next.id));
|
|
102
|
+
};
|
|
103
|
+
return go(initial, updates.map((update, id) => ({ id, landed: update.then((done) => ({ id, update: done })) })));
|
|
104
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { characters, width } from "./line.js";
|
|
2
|
+
/** 0.4s, 12s, 2m03s, 1h04m: never more precise than it is worth reading. */
|
|
3
|
+
export const duration = (ms) => {
|
|
4
|
+
const seconds = Math.max(0, ms) / 1000;
|
|
5
|
+
if (seconds < 10)
|
|
6
|
+
return `${(Math.floor(seconds * 10) / 10).toFixed(1)}s`;
|
|
7
|
+
if (seconds < 60)
|
|
8
|
+
return `${String(Math.floor(seconds))}s`;
|
|
9
|
+
const minutes = Math.floor(seconds / 60);
|
|
10
|
+
if (minutes < 60)
|
|
11
|
+
return `${String(minutes)}m${String(Math.floor(seconds % 60)).padStart(2, "0")}s`;
|
|
12
|
+
return `${String(Math.floor(minutes / 60))}h${String(minutes % 60).padStart(2, "0")}m`;
|
|
13
|
+
};
|
|
14
|
+
/** `left`, then `right` flush with the last column, at least two spaces apart. */
|
|
15
|
+
export const spread = (left, right, columns) => [
|
|
16
|
+
...left,
|
|
17
|
+
" ".repeat(Math.max(2, columns - width(left) - width(right))),
|
|
18
|
+
...right,
|
|
19
|
+
];
|
|
20
|
+
/** At most `columns` wide, cut with an ellipsis: a line redrawn in place must not wrap. */
|
|
21
|
+
export const truncate = (line, columns) => {
|
|
22
|
+
if (width(line) <= columns)
|
|
23
|
+
return line;
|
|
24
|
+
const cut = line.reduce((so, span) => {
|
|
25
|
+
const text = typeof span === "string" ? span : span.text;
|
|
26
|
+
const chars = characters(text);
|
|
27
|
+
const kept = chars.slice(0, Math.max(0, so.room)).join("");
|
|
28
|
+
const piece = typeof span === "string" ? kept : { ...span, text: kept };
|
|
29
|
+
return { kept: kept === "" ? so.kept : [...so.kept, piece], room: so.room - chars.length };
|
|
30
|
+
}, { kept: [], room: columns - 1 });
|
|
31
|
+
return [...cut.kept, "…"];
|
|
32
|
+
};
|
|
33
|
+
/** Words in lines of at most `columns`; a word longer than that gets a line of its own. */
|
|
34
|
+
export const wrap = (words, columns) => words.reduce((lines, word) => {
|
|
35
|
+
const last = lines.at(-1);
|
|
36
|
+
if (last === undefined)
|
|
37
|
+
return [word];
|
|
38
|
+
return characters(last).length + 1 + characters(word).length <= columns ? [...lines.slice(0, -1), `${last} ${word}`] : [...lines, word];
|
|
39
|
+
}, []);
|
|
40
|
+
/** How long ago, as a reader rounds it: 45s ago, 12m ago, 30h ago, 3d ago. */
|
|
41
|
+
export const ago = (ms) => {
|
|
42
|
+
const seconds = Math.floor(Math.max(0, ms) / 1000);
|
|
43
|
+
if (seconds < 60)
|
|
44
|
+
return `${String(seconds)}s ago`;
|
|
45
|
+
const minutes = Math.floor(seconds / 60);
|
|
46
|
+
if (minutes < 60)
|
|
47
|
+
return `${String(minutes)}m ago`;
|
|
48
|
+
const hours = Math.floor(minutes / 60);
|
|
49
|
+
return hours < 48 ? `${String(hours)}h ago` : `${String(Math.floor(hours / 24))}d ago`;
|
|
50
|
+
};
|
|
51
|
+
/** Rows of cells in columns as wide as their widest cell, two spaces apart; nothing trails a row's last cell. */
|
|
52
|
+
export const table = (rows) => {
|
|
53
|
+
const filled = rows.map((row) => row.slice(0, row.findLastIndex((cell) => width(cell) > 0) + 1));
|
|
54
|
+
const widths = filled.reduce((most, row) => Array.from({ length: Math.max(most.length, row.length) }, (_, at) => Math.max(most[at] ?? 0, width(row[at] ?? []))), []);
|
|
55
|
+
return filled.map((row) => row.flatMap((cell, at) => (at === row.length - 1 ? cell : [...cell, " ".repeat((widths[at] ?? 0) - width(cell) + 2)])));
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Rows for table() that fit `room` columns: the cells of the columns in
|
|
59
|
+
* `shrink` cut, in that order, each to no less than its first row's (the
|
|
60
|
+
* heading's) width.
|
|
61
|
+
*/
|
|
62
|
+
export const fit = (rows, room, shrink) => {
|
|
63
|
+
const widths = rows.reduce((most, row) => Array.from({ length: Math.max(most.length, row.length) }, (_, at) => Math.max(most[at] ?? 0, width(row[at] ?? []))), []);
|
|
64
|
+
const over = widths.reduce((sum, each) => sum + each, 0) + 2 * Math.max(0, widths.length - 1) - room;
|
|
65
|
+
const cut = shrink.reduce((so, at) => {
|
|
66
|
+
const now = so.widths[at] ?? 0;
|
|
67
|
+
const less = Math.min(Math.max(0, so.over), Math.max(0, now - width(rows[0]?.[at] ?? [])));
|
|
68
|
+
return { widths: so.widths.with(at, now - less), over: so.over - less };
|
|
69
|
+
}, { widths, over }).widths;
|
|
70
|
+
return rows.map((row) => row.map((cell, at) => truncate(cell, cut[at] ?? width(cell))));
|
|
71
|
+
};
|
|
72
|
+
/** Paths by the root they are under, the longest first: the engine may live inside the fleet. */
|
|
73
|
+
export const shortener = (roots) => (text) => roots.toSorted(([a], [b]) => b.length - a.length).reduce((short, [path, name]) => short.replaceAll(path, name), text);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { accent, active, bad, muted, ok, strong, warn } from "./line.js";
|
|
3
|
+
import { ago, duration, table } from "./text.js";
|
|
4
|
+
const deployed = z.object({ sha: z.string(), time: z.iso.datetime() });
|
|
5
|
+
/** `ctl runs <app> --json`, as this kayra reads it. */
|
|
6
|
+
export const runsSchema = z.object({
|
|
7
|
+
app: z.string(),
|
|
8
|
+
live: deployed.exactOptional(),
|
|
9
|
+
runs: z.array(z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
state: z.enum(["running", "success", "failure"]),
|
|
12
|
+
why: z.string(),
|
|
13
|
+
what: z.string(),
|
|
14
|
+
sha: z.string().exactOptional(),
|
|
15
|
+
started: z.iso.datetime(),
|
|
16
|
+
finished: z.iso.datetime().exactOptional(),
|
|
17
|
+
})),
|
|
18
|
+
});
|
|
19
|
+
/** `ctl rollback <app> --json`, as this kayra reads it. */
|
|
20
|
+
export const releasesSchema = z.object({
|
|
21
|
+
app: z.string(),
|
|
22
|
+
releases: z.array(deployed.extend({ live: z.boolean() })),
|
|
23
|
+
});
|
|
24
|
+
/** The answer as the schema has it, or nothing: then it is not the answer this kayra expects. */
|
|
25
|
+
export const parsed = (schema, answer) => {
|
|
26
|
+
try {
|
|
27
|
+
const json = JSON.parse(answer);
|
|
28
|
+
const result = schema.safeParse(json);
|
|
29
|
+
return result.success ? result.data : undefined;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** Lines as printing them one by one gives the text back: newline-ended, as a ctl writes. */
|
|
36
|
+
const linesOf = (text) => (text === "" ? [] : text.replace(/\n$/, "").split("\n"));
|
|
37
|
+
const short = (sha) => sha.slice(0, 7);
|
|
38
|
+
const since = (time, now) => ago(now - Date.parse(time));
|
|
39
|
+
const heading = (view, ...more) => [strong(view.app), muted(` on ${view.server}`), ...more];
|
|
40
|
+
const live = (release, now) => release === undefined
|
|
41
|
+
? [muted(" · not deployed yet")]
|
|
42
|
+
: [muted(" · live "), accent(short(release.sha)), muted(` since ${since(release.time, now)}`)];
|
|
43
|
+
const hint = (command, what) => [" ", active("→"), " ", strong(command), muted(` ${what}`)];
|
|
44
|
+
const states = {
|
|
45
|
+
success: [ok("✓ success")],
|
|
46
|
+
failure: [bad("✗ failure")],
|
|
47
|
+
running: [active("◆ running")],
|
|
48
|
+
};
|
|
49
|
+
const took = (run, now) => run.finished === undefined
|
|
50
|
+
? [active(`${duration(now - Date.parse(run.started))}…`)]
|
|
51
|
+
: [duration(Date.parse(run.finished) - Date.parse(run.started))];
|
|
52
|
+
const commit = (run, release) => {
|
|
53
|
+
if (run.sha === undefined)
|
|
54
|
+
return [muted("—")];
|
|
55
|
+
return run.sha === release?.sha ? [accent(short(run.sha))] : [short(run.sha)];
|
|
56
|
+
};
|
|
57
|
+
/** `kayra app runs`: what runs now, then a table of the newest runs. */
|
|
58
|
+
export const runsView = (view, answer, now) => {
|
|
59
|
+
const rows = table([
|
|
60
|
+
["STATE", "COMMIT", "WHY", "WHEN", "TOOK", "RUN"].map((title) => [muted(title)]),
|
|
61
|
+
...answer.runs.map((run) => [states[run.state], commit(run, answer.live), [run.why], [since(run.started, now)], took(run, now), [muted(run.id)]]),
|
|
62
|
+
]);
|
|
63
|
+
return [
|
|
64
|
+
heading(view, ...live(answer.live, now)),
|
|
65
|
+
[],
|
|
66
|
+
...(answer.runs.length === 0
|
|
67
|
+
? [[" ", muted("no runs yet")]]
|
|
68
|
+
: [...rows.map((row) => [" ", ...row]), [], hint(`kayra app logs ${view.server} ${view.app} [RUN]`, "shows a run's log, the newest by default")]),
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
/** `kayra app rollback` without a commit: every release, the live one marked, and how to go back to one. */
|
|
72
|
+
export const releasesView = (view, answer, now) => {
|
|
73
|
+
const earlier = answer.releases.find((release) => !release.live);
|
|
74
|
+
const rows = table([
|
|
75
|
+
[[muted(" COMMIT")], [muted("DEPLOYED")]],
|
|
76
|
+
...answer.releases.map((release) => [
|
|
77
|
+
release.live ? [ok("●"), " ", accent(short(release.sha))] : [" ", short(release.sha)],
|
|
78
|
+
[since(release.time, now)],
|
|
79
|
+
release.live ? [ok("live")] : [],
|
|
80
|
+
]),
|
|
81
|
+
]);
|
|
82
|
+
const count = answer.releases.length;
|
|
83
|
+
return [
|
|
84
|
+
heading(view, muted(` · ${String(count)} release${count === 1 ? "" : "s"}`)),
|
|
85
|
+
[],
|
|
86
|
+
...rows.map((row) => [" ", ...row]),
|
|
87
|
+
[],
|
|
88
|
+
earlier === undefined
|
|
89
|
+
? [" ", muted("nothing earlier to roll back to")]
|
|
90
|
+
: hint(`kayra app rollback ${view.server} ${view.app} ${short(earlier.sha)}`, "deploys that one again"),
|
|
91
|
+
];
|
|
92
|
+
};
|
|
93
|
+
const errors = /\b(error|fatal|failed|failure|panic|refused|denied|unhealthy)\b/i;
|
|
94
|
+
const warnings = /\b(warn|warning|deprecated)\b/i;
|
|
95
|
+
/** The deployer's time, before each line it logs. */
|
|
96
|
+
const stamped = /^(\d{2}:\d{2}:\d{2} )(.*)$/s;
|
|
97
|
+
const logLine = (line) => {
|
|
98
|
+
const [, time = "", text = line] = stamped.exec(line) ?? [];
|
|
99
|
+
const tone = errors.test(text) ? bad : warnings.test(text) ? warn : text.startsWith("── ") ? strong : text.startsWith("Deployed ") ? ok : undefined;
|
|
100
|
+
return [...(time === "" ? [] : [muted(time)]), tone === undefined ? text : tone(text)];
|
|
101
|
+
};
|
|
102
|
+
/** `kayra app logs`: the log as it is, its errors and warnings marked; uncoloured, the same bytes. */
|
|
103
|
+
export const logView = (log) => linesOf(log).map(logLine);
|
|
104
|
+
/** A deployer's answer as its view draws it, or as it came if it is not what the view reads (an older ctl). */
|
|
105
|
+
export const draw = (view, answer, now) => {
|
|
106
|
+
switch (view.view) {
|
|
107
|
+
case "runs": {
|
|
108
|
+
const runs = parsed(runsSchema, answer);
|
|
109
|
+
return runs === undefined ? linesOf(answer) : runsView(view, runs, now);
|
|
110
|
+
}
|
|
111
|
+
case "releases": {
|
|
112
|
+
const releases = parsed(releasesSchema, answer);
|
|
113
|
+
return releases === undefined ? linesOf(answer) : releasesView(view, releases, now);
|
|
114
|
+
}
|
|
115
|
+
case "log":
|
|
116
|
+
return logView(answer);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
/** What --dry-run says about a drawn answer. */
|
|
120
|
+
export const drawnAs = (view) => {
|
|
121
|
+
switch (view.view) {
|
|
122
|
+
case "runs":
|
|
123
|
+
return "its answer drawn as a table of runs";
|
|
124
|
+
case "releases":
|
|
125
|
+
return "its answer drawn as the releases, the live one marked";
|
|
126
|
+
case "log":
|
|
127
|
+
return "the log as it is, errors and warnings marked on a terminal";
|
|
128
|
+
}
|
|
129
|
+
};
|
package/cli/dist/validate.js
CHANGED
|
@@ -8,12 +8,17 @@ const distance = (a, b) => indices(b.length)
|
|
|
8
8
|
Math.min((row[i + 1] ?? 0) + 1, (next[i] ?? 0) + 1, (row[i] ?? 0) + (a.charAt(i) === b.charAt(j) ? 0 : 1)),
|
|
9
9
|
], [j + 1]), indices(a.length + 1))
|
|
10
10
|
.at(-1) ?? 0;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/** The known name a key is most likely a typo of, if one is close enough. */
|
|
12
|
+
export const closest = (key, known) => {
|
|
13
|
+
const nearest = known
|
|
13
14
|
.map((name) => ({ name, cost: distance(key, name) }))
|
|
14
15
|
.toSorted((x, y) => x.cost - y.cost)
|
|
15
16
|
.at(0);
|
|
16
|
-
return
|
|
17
|
+
return nearest !== undefined && nearest.cost <= Math.max(2, Math.floor(key.length / 4)) ? nearest.name : undefined;
|
|
18
|
+
};
|
|
19
|
+
const suggestion = (key, known) => {
|
|
20
|
+
const name = closest(key, known);
|
|
21
|
+
return name === undefined ? "" : ` — did you mean '${name}'?`;
|
|
17
22
|
};
|
|
18
23
|
/** The first problem Zod found, said for the file it is in. */
|
|
19
24
|
const firstIssue = (file, error, known, unknownKey) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--bg:#f7f7f8;--panel:#fff;--panel-2:#f2f2f4;--line:#e4e4e8;--line-strong:#d4d4da;--fg:#18181b;--fg-2:#52525b;--muted:#8a8a94;--accent:#5b5bd6;--accent-soft:#ededfc;--ok:#18794e;--ok-soft:#e6f6ed;--bad:#ce2c31;--bad-soft:#feebec;--warn:#ab6400;--warn-soft:#fff4d5;--active:#0d74ce;--active-soft:#e6f2fd;--code-bg:#0f0f12;--code-fg:#e4e4e8;--radius:10px;--shadow:0 1px 2px #0000000a, 0 4px 16px #0000000a;--mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;--sans:-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial;--bg:#0e0e11;--panel:#16161a;--panel-2:#1c1c21;--line:#26262c;--line-strong:#33333b;--fg:#ededf0;--fg-2:#b4b4bd;--muted:#7c7c87;--accent:#8b8bf5;--accent-soft:#23234a;--ok:#4cc38a;--ok-soft:#12291d;--bad:#ff6369;--bad-soft:#3b1219;--warn:#f1a10d;--warn-soft:#2e2309;--active:#70b8ff;--active-soft:#0d2847;--code-bg:#0a0a0c;--shadow:0 1px 2px #0000004d, 0 4px 16px #0003}}*{box-sizing:border-box}body{font:14px/1.5 var(--sans);color:var(--fg);background:var(--bg);-webkit-font-smoothing:antialiased;margin:0}a{color:inherit}code,pre,kbd{font-family:var(--mono);font-size:12.5px}h1,h2,h3{letter-spacing:-.01em;margin:0}button,input{font:inherit;color:inherit}.shell{grid-template-columns:248px 1fr;min-height:100vh;display:grid}.sidebar{border-right:1px solid var(--line);background:var(--panel);flex-direction:column;gap:18px;height:100vh;padding:16px 12px;display:flex;position:sticky;top:0;overflow-y:auto}.brand{align-items:center;gap:10px;padding:4px 8px 8px;text-decoration:none;display:flex}.brand strong{font-size:15px;display:block}.brand-sub{color:var(--muted);font-size:12px;display:block}.logo{background:var(--accent);color:#fff;width:30px;height:30px;font-weight:700;font-family:var(--mono);border-radius:8px;place-items:center;display:grid}.nav-title{text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:0 10px 4px;font-size:11px;font-weight:600}.nav-item{color:var(--fg-2);border-radius:7px;align-items:center;gap:9px;padding:6px 10px;text-decoration:none;display:flex}.nav-item:hover{background:var(--panel-2);color:var(--fg)}.nav-item.current{background:var(--accent-soft);color:var(--fg);font-weight:550}.nav-meta{color:var(--muted);margin-left:auto;font-size:11px}.sidebar-foot{color:var(--muted);font-size:12px;font-family:var(--mono);margin-top:auto;padding:0 10px}.main{width:100%;max-width:1180px;padding:20px 36px 64px}@media (width<=860px){.shell{grid-template-columns:1fr}.sidebar{height:auto;position:static}.main{padding:16px}}.topbar{justify-content:flex-end;gap:10px;margin-bottom:18px;display:flex}.search{border:1px solid var(--line);background:var(--panel);min-width:260px;color:var(--muted);cursor:pointer;border-radius:8px;align-items:center;gap:24px;padding:6px 8px 6px 12px;display:flex}.search kbd{border:1px solid var(--line-strong);border-radius:5px;margin-left:auto;padding:1px 6px;font-size:11px}.page-header{justify-content:space-between;align-items:flex-end;gap:16px;margin:8px 0 22px;display:flex}.page-header h1{align-items:center;gap:10px;font-size:24px;font-weight:650;display:flex}.page-header .sub,.sub{color:var(--muted);margin-top:4px}.actions,.inline{align-items:center;gap:8px;display:flex}.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);margin-bottom:16px;padding:16px 18px}.card h2{color:var(--fg-2);margin-bottom:10px;font-size:13px;font-weight:600}.cards{grid-template-columns:repeat(auto-fill,minmax(310px,1fr));gap:16px;display:grid}.columns{grid-template-columns:1fr 1fr;gap:16px;display:grid}@media (width<=860px){.columns{grid-template-columns:1fr}}.card-head{align-items:center;gap:8px;margin-bottom:6px;display:flex}.card-head h2{color:var(--fg);margin:0;font-size:16px}.server-card{text-decoration:none;transition:border-color .15s,transform .15s;display:block}.server-card:hover{border-color:var(--line-strong);transform:translateY(-1px)}.domain{font-family:var(--mono);color:var(--muted);margin-bottom:12px;font-size:12.5px}.facts{gap:6px;margin:0;display:grid}.fact{grid-template-columns:72px 1fr;align-items:center;display:grid}.fact dt{color:var(--muted);font-size:12.5px}.fact dd{font-family:var(--mono);align-items:center;gap:7px;margin:0;font-size:12.5px;display:flex}.chips{flex-wrap:wrap;gap:6px;margin-top:12px;display:flex}.grow{flex:1}.pill{background:var(--panel-2);color:var(--fg-2);border:1px solid var(--line);border-radius:999px;align-items:center;padding:1px 8px;font-size:11.5px;font-weight:550;display:inline-flex}.pill-ok{background:var(--ok-soft);color:var(--ok);border-color:#0000}.pill-bad{background:var(--bad-soft);color:var(--bad);border-color:#0000}.pill-warn{background:var(--warn-soft);color:var(--warn);border-color:#0000}.pill-active{background:var(--active-soft);color:var(--active);border-color:#0000}.pill-accent{background:var(--accent-soft);color:var(--accent);border-color:#0000}.pill-muted{color:var(--muted)}.dot{background:var(--muted);border-radius:50%;flex:none;width:8px;height:8px;display:inline-block}.dot-ok{background:var(--ok);box-shadow:0 0 0 3px var(--ok-soft)}.dot-bad{background:var(--bad);box-shadow:0 0 0 3px var(--bad-soft)}.dot-warn{background:var(--warn);box-shadow:0 0 0 3px var(--warn-soft)}.dot-active,.dot-accent{background:var(--active)}.dot-waiting{background:var(--active);animation:1.2s ease-in-out infinite breathe}@keyframes breathe{50%{opacity:.25}}.tone-ok{color:var(--ok)}.tone-bad{color:var(--bad)}.tone-warn{color:var(--warn)}.tone-active{color:var(--active)}.tone-muted{color:var(--muted)}.tone-strong{font-weight:600}.tone-accent{color:var(--accent);font-weight:600}.button{border:1px solid var(--line-strong);background:var(--panel);cursor:pointer;border-radius:7px;padding:6px 12px;font-weight:550}.button:hover{background:var(--panel-2)}.button:disabled{opacity:.5;cursor:default}.button.primary{background:var(--accent);border-color:var(--accent);color:#fff}.button.danger{background:var(--bad);border-color:var(--bad);color:#fff}.button.small{padding:2px 8px;font-size:12.5px}.link{cursor:pointer;background:0 0;border:none;padding:0;text-decoration:underline}.danger-link{color:var(--bad)}input{border:1px solid var(--line-strong);background:var(--panel);border-radius:7px;padding:6px 10px}input:focus,button:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.action-grid{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:10px;display:grid}.action{text-align:left;border:1px solid var(--line);background:var(--panel-2);cursor:pointer;border-radius:9px;gap:2px;padding:10px 12px;display:grid}.action strong{font-family:var(--mono);font-size:13px}.action span{color:var(--muted);font-size:12.5px}.action:hover{border-color:var(--accent)}.action.primary{border-color:var(--accent);background:var(--accent-soft)}.action.danger strong{color:var(--bad)}.action:disabled{opacity:.45;cursor:default}.table{border-collapse:collapse;width:100%}.table th{text-align:left;color:var(--muted);border-bottom:1px solid var(--line);padding:6px 8px;font-size:12px;font-weight:550}.table td{border-bottom:1px solid var(--line);padding:8px}.table tr:last-child td{border-bottom:none}.table .narrow{width:20px}.right{text-align:right}.clickable{cursor:pointer}.clickable:hover td{background:var(--panel-2)}.links{gap:4px;margin:0;padding:0;list-style:none;display:grid}.releases{margin:0;padding:0;list-style:none}.releases li{border-bottom:1px solid var(--line);align-items:center;gap:14px;padding:8px 0;display:flex}.findings{gap:6px;margin:8px 0 0;padding:0;list-style:none;display:grid}.finding{grid-template-columns:18px 1fr;display:grid}.hint{color:var(--muted);font-size:12.5px;display:block}.empty,.waiting{color:var(--muted)}.waiting{align-items:center;gap:8px;padding:6px 0;display:flex}.small{font-size:12.5px}.notice{background:var(--warn-soft);color:var(--warn);border-radius:8px;margin-bottom:16px;padding:10px 14px}.problem{background:var(--bad-soft);color:var(--bad);border-radius:8px;margin:8px 0;padding:12px 14px}.problem pre{white-space:pre-wrap;color:var(--fg);margin:6px 0 0}.tabs{gap:4px;margin-bottom:10px;display:flex}.tab{cursor:pointer;color:var(--muted);background:0 0;border:none;border-radius:7px;padding:6px 12px;font-weight:550}.tab.current{background:var(--panel);color:var(--fg);box-shadow:var(--shadow)}.log{background:var(--code-bg);max-height:70vh;color:var(--code-fg);border-radius:8px;margin:0;padding:12px;overflow:auto}.spinner{border:2px solid var(--line-strong);border-top-color:var(--active);border-radius:50%;width:12px;height:12px;animation:.7s linear infinite spin;display:inline-block}@keyframes spin{to{transform:rotate(360deg)}}.overlay{z-index:10;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background:#00000059;justify-content:center;align-items:flex-start;padding:8vh 16px;display:flex;position:fixed;inset:0}.sheet{background:var(--panel);border:1px solid var(--line);border-radius:14px;flex-direction:column;width:min(760px,100%);max-height:84vh;display:flex;box-shadow:0 24px 64px #00000040}.sheet-head{border-bottom:1px solid var(--line);padding:18px 20px 12px}.sheet-body{padding:6px 20px 12px;overflow-y:auto}.sheet-foot{border-top:1px solid var(--line);gap:12px;padding:14px 20px;display:grid}.command{font-size:15px;font-weight:600}.part{text-transform:uppercase;letter-spacing:.06em;color:var(--accent);margin:14px 0 6px;font-size:11px;font-weight:650}.plan{gap:8px;margin:0;padding:0;list-style:none;display:grid}.plan-step{grid-template-columns:26px 1fr;display:grid}.plan-index{color:var(--muted);font-family:var(--mono);padding-top:2px;font-size:12px}.plan-title{align-items:center;gap:8px;display:flex}.plan-command{color:var(--muted);word-break:break-all;margin-top:3px;font-size:12px;display:block}.confirm{gap:6px;display:grid}.buttons{justify-content:flex-end;gap:8px;display:flex}.timeline{gap:6px;display:grid}.step{border:1px solid var(--line);background:var(--panel);border-radius:9px}.step summary{cursor:pointer;grid-template-columns:22px 1fr auto auto;align-items:center;gap:10px;padding:9px 12px;list-style:none;display:grid}.step summary::-webkit-details-marker{display:none}.step-icon{place-items:center;font-weight:700;display:grid}.step-passed .step-icon{color:var(--ok)}.step-failed .step-icon{color:var(--bad)}.step-stopped .step-icon{color:var(--warn)}.step-waiting,.step-skipped{opacity:.55}.step-failed{border-color:var(--bad)}.step-running{border-color:var(--active)}.step-kind{color:var(--muted);font-size:11px;font-family:var(--mono)}.step-time{font-family:var(--mono);color:var(--muted);text-align:right;min-width:64px;font-size:12px}.output{background:var(--code-bg);max-height:60vh;color:var(--code-fg);font-family:var(--mono);white-space:pre-wrap;word-break:break-word;border-radius:8px;margin:0 12px 12px;padding:10px 12px;font-size:12.5px;overflow:auto}.output .stderr{color:#f0b3b3}.said{color:var(--code-fg)}.said-err{color:#ffb4b4}.run-footer{background:var(--panel);border:1px solid var(--line);font-family:var(--mono);border-radius:10px;margin-top:16px;padding:14px 16px}.tone-border-ok{border-left:4px solid var(--ok)}.tone-border-bad{border-left:4px solid var(--bad)}.tone-border-warn{border-left:4px solid var(--warn)}.tone-border-active{border-left:4px solid var(--active)}.lines div{white-space:pre-wrap}.ask{background:var(--bad-soft);border-radius:10px;flex-wrap:wrap;align-items:center;gap:10px;margin-bottom:14px;padding:14px 16px;display:flex}.sgr-red{color:#ff7b72}.sgr-green{color:#7ee787}.sgr-yellow{color:#f2cc60}.sgr-blue{color:#79c0ff}.sgr-magenta{color:#d2a8ff}.sgr-cyan{color:#76e3ea}.sgr-white,.sgr-bright-white{color:#fff}.sgr-black{color:#8b949e}.sgr-bright-red{color:#ffa198}.sgr-bright-green{color:#56d364}.sgr-bright-yellow{color:#e3b341}.sgr-bright-blue{color:#a5d6ff}.sgr-bright-magenta{color:#e2c5ff}.sgr-bright-cyan{color:#b3f0ff}.sgr-bright-black{color:#8b949e}.sgr-bold{font-weight:700}.sgr-dim{opacity:.6}.palette{background:var(--panel);border:1px solid var(--line);border-radius:14px;width:min(620px,100%);overflow:hidden;box-shadow:0 24px 64px #00000040}.palette input{border:none;border-bottom:1px solid var(--line);background:0 0;border-radius:0;outline:none;width:100%;padding:14px 16px;font-size:15px}.palette ul{max-height:50vh;margin:0;padding:6px;list-style:none;overflow-y:auto}.palette li{cursor:pointer;border-radius:8px;justify-content:space-between;padding:8px 10px;display:flex}.palette li .hint{display:inline}.palette li.selected{background:var(--accent-soft)}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function te(e,t){this.props=e,this.context=t}function C(e,t){if(t==null)return e.__?C(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?C(e):null}function w(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=y({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),oe(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??C(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,ce(i,o,a),n.__e=n.__=null,o.__e!=r&&T(o)}}function T(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),T(e)}function E(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!D.__r++||a!=t.debounceRendering)&&((a=t.debounceRendering)||o)(D)}function D(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,w(e)}finally{i.length=D.__r=0}}function ne(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,ee=t.length;for(c=O(n,t,y,c,ee),d=0;d<ee;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=oe(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&de(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=re(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function O(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):v(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=k(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=C(s)),fe(s,s));return r}function re(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=re(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=C(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function k(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ie(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function A(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ie(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ie(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ae(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[l]==null)n[l]=f++;else if(n[l]<r[u])return;return r(t.event?t.event(n):n)}}}function oe(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,b,x,w,T,E,D,O,re,k,ie,A=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=n.__e=r.__e]),(d=t.__b)&&d(n);n:if(typeof A==`function`){f=s.length;try{if(w=n.props,T=A.prototype&&A.prototype.render,E=(d=A.contextType)&&i[d.__c],D=d?E?E.props.value:d.__:i,r.__c?x=(p=n.__c=r.__c).__=p.__E:(T?n.__c=p=new A(w,D):(n.__c=p=new te(w,D),p.constructor=A,p.render=pe),E&&E.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),T&&p.__s==null&&(p.__s=p.state),T&&A.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,A.getDerivedStateFromProps(w,p.__s))),h=p.props,_=p.state,p.__v=n,m)T&&A.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),T&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(T&&A.getDerivedStateFromProps==null&&w!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(w,D),n.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(w,p.__s,D)){n.__v!=r.__v&&(p.props=w,p.state=p.__s,p.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=C(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(w,p.__s,D),T&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,b)})}if(p.context=D,p.props=w,p.__P=e,p.__e=!1,O=t.__r,re=0,T)p.state=p.__s,p.__d=!1,O&&O(n),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,O&&O(n),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++re<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),T&&!m&&p.getSnapshotBeforeUpdate!=null&&(b=p.getSnapshotBeforeUpdate(h,_)),k=d!=null&&d.type===S&&d.key==null?le(d.props.children):d,c=ne(e,v(k)?k:[k],n,r,i,a,o,s,c,l,u),p.base=n.__e,n.__u&=-161,p.__h.length&&s.push(p),x&&(p.__E=p.__=null)}catch(e){if(s.length=f,n.__v=null,l||o!=null){if(e.then){for(n.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),n.__e=c}else if(o!=null)for(ie=o.length;ie--;)ee(o[ie])}else n.__e=r.__e;n.__k??=r.__k||[],e.then||se(n),t.__e(e,n,r)}}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=ue(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function se(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(se))}function ce(e,n,r){for(var i=0;i<r.length;i++)de(r[i],r[++i],r[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function le(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(le):e.constructor===void 0?y({},e):null}function ue(n,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,b=i.props||h,x=r.props,S=r.type;if(S==`svg`?o=`http://www.w3.org/2000/svg`:S==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!S&&(S?g.localName==S:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(S==null)return document.createTextNode(x);n=document.createElementNS(o,S,x.is&&x),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(S==null)b===x||l&&n.data==x||(n.data=x);else{if(s=S==`textarea`&&x.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(b={},d=0;d<n.attributes.length;d++)b[(g=n.attributes[d]).name]=g.value;for(d in b)g=b[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in x||d==`value`&&`defaultValue`in x||d==`checked`&&`defaultChecked`in x||A(n,d,null,g,o);for(d in x)g=x[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||b[d]===g||A(n,d,g,b[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),r.__k=[];else if(p&&(n.innerHTML=``),ne(r.type==`template`?n.content:n,v(m)?m:[m],r,i,a,S==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&C(i,0),l,u),s!=null)for(d=s.length;d--;)ee(s[d]);l&&S!=`textarea`||(d=`value`,S==`progress`&&_==null?n.removeAttribute(`value`):_!=null&&(_!==n[d]||S==`progress`&&!_||S==`option`&&_!=b[d])&&A(n,d,_,b[d],o),d=`checked`,y!=null&&y!=n[d]&&A(n,d,y,b[d],o))}return n}function de(e,n,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&n==null||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,r)}}function fe(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||de(i,null,n)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){t.__e(e,n)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&fe(i[a],n,r||typeof e.type!=`function`);r||ee(e.__e),e.__c=e.__=e.__e=void 0}function pe(e,t,n){return this.constructor(e,n)}function me(n,r,i){var a,o,s,c;r==document&&(r=document.documentElement),t.__&&t.__(n,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],oe(r,n=(!a&&i||r).__k=b(S,null,[n]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?e.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),ce(s,n,c),n.props.children=null}e=g.slice,t={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},n=0,r=function(e){return e!=null&&e.constructor===void 0},te.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),E(this))},te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),E(this))},te.prototype.render=S,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},D.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=ae(!1),m=ae(!0);var he,j,ge,_e,ve=0,ye=[],M=t,be=M.__b,xe=M.__r,Se=M.diffed,Ce=M.__c,we=M.unmount,Te=M.__;function Ee(e,t){M.__h&&M.__h(j,e,ve||t),ve=0;var n=j.__H||(j.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function N(e){return ve=1,De(Ie,e)}function De(e,t,n){var r=Ee(he++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ie(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=j,!j.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};j.__f=!0;var a=j.shouldComponentUpdate,o=j.componentWillUpdate;j.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},j.shouldComponentUpdate=i}return r.__N||r.__}function P(e,t){var n=Ee(he++,3);!M.__s&&Fe(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function Oe(e){return ve=5,ke(function(){return{current:e}},[])}function ke(e,t){var n=Ee(he++,7);return Fe(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ae(){for(var e;e=ye.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ne),t.__h.some(Pe),t.__h=[]}catch(n){t.__h=[],M.__e(n,e.__v)}}}M.__b=function(e){j=null,be&&be(e)},M.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Te&&Te(e,t)},M.__r=function(e){xe&&xe(e),he=0;var t=(j=e.__c).__H;t&&(ge===j?(t.__h=[],j.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ne),t.__h.some(Pe),t.__h=[],he=0)),ge=j},M.diffed=function(e){Se&&Se(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ye.push(t)!==1&&_e===M.requestAnimationFrame||((_e=M.requestAnimationFrame)||Me)(Ae)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ge=j=null},M.__c=function(e,t){t.some(function(e){try{e.__h.some(Ne),e.__h=e.__h.filter(function(e){return!e.__||Pe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],M.__e(n,e.__v)}}),Ce&&Ce(e,t)},M.unmount=function(e){we&&we(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ne(e)}catch(e){t=e}}),n.__H=void 0,t&&M.__e(t,n.__v))};var je=typeof requestAnimationFrame==`function`;function Me(e){var t,n=function(){clearTimeout(r),je&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);je&&(t=requestAnimationFrame(n))}function Ne(e){var t=j,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),j=t}function Pe(e){var t=j;e.__c=e.__(),j=t}function Fe(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ie(e,t){return typeof t==`function`?t(e):t}var Le=Symbol.for(`preact-signals`);function Re(){if(I>1)I--;else{var e,t=!1;for((function(){var e=Ke;for(Ke=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();He!==void 0;){var n=He;for(He=void 0,Ue++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ye(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Ue=0,I--,t)throw e}}function ze(e){if(I>0)return e();Ge=++We,I++;try{return e()}finally{Re()}}var Be,F=void 0;function Ve(e){var t=F,n=Be;F=void 0,Be=void 0;try{return e()}finally{F=t,Be=n}}var He=void 0,I=0,Ue=0,We=0,Ge=0,Ke=void 0,qe=0;function Je(e){if(F!==void 0){var t=e.n;if(t===void 0||t.t!==F)return t={i:0,S:e,p:F.s,n:void 0,t:F,e:void 0,x:void 0,r:t},F.s!==void 0&&(F.s.n=t),F.s=t,e.n=t,32&F.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=F.s,t.n=void 0,F.s.n=t,F.s=t),t}}function L(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}L.prototype.brand=Le,L.prototype.h=function(){return!0},L.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?Ve(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},L.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&Ve(function(){var e;(e=t.Z)==null||e.call(t)}))}},L.prototype.subscribe=function(e){var t=this;return nt(function(){var n=t.value;Ve(function(){return e(n)})},{name:`sub`})},L.prototype.valueOf=function(){return this.value},L.prototype.toString=function(){return this.value+``},L.prototype.toJSON=function(){return this.value},L.prototype.peek=function(){var e=this;return Ve(function(){return e.value})},Object.defineProperty(L.prototype,"value",{get:function(){var e=Je(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ue>100)throw Error(`Cycle detected`);(function(e){I!==0&&Ue===0&&e.l!==Ge&&(e.l=Ge,Ke={S:e,v:e.v,i:e.i,o:Ke})})(this),this.v=e,this.i++,qe++,I++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Re()}}}});function R(e,t){return new L(e,t)}function Ye(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Xe(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Ze(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function z(e,t){L.call(this,void 0,t),this.x=e,this.s=void 0,this.g=qe-1,this.f=4}z.prototype=new L,z.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===qe))return!0;if(this.g=qe,this.f|=1,this.i>0&&!Ye(this))return this.f&=-2,!0;var e=F;try{Xe(this),F=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return F=e,Ze(this),this.f&=-2,!0},z.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}L.prototype.S.call(this,e)},z.prototype.U=function(e){if(this.t!==void 0&&(L.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},z.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(z.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Je(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Qe(e,t){return new z(e,t)}function $e(e){var t=e.m;if(e.m=void 0,typeof t==`function`){I++;var n=F;F=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,et(e),t}finally{F=n,Re()}}}function et(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,$e(e)}function tt(e){if(F!==this)throw Error(`Out-of-order effect`);Ze(this),F=e,this.f&=-2,8&this.f&&et(this),Re()}function B(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Be&&Be.push(this)}B.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},B.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,$e(this),Xe(this),I++;var e=F;return F=this,tt.bind(this,e)},B.prototype.N=function(){2&this.f||(this.f|=2,this.u=He,He=this)},B.prototype.d=function(){this.f|=8,1&this.f||et(this)},B.prototype.dispose=function(){this.d()};function nt(e,t){var n=new B(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var rt,it,at=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,ot=[];nt(function(){rt=this.N})();function V(e,n){t[e]=n.bind(null,t[e]||function(){})}function st(e){if(it){var t=it;it=void 0,t()}it=e&&e.S()}function ct(e){var t=this,n=e.data,i=ut(n);i.name=`ReactiveDom`,i.value=n;var a=ke(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var a=Qe(function(){var e=i.value.value;return e===0?0:!0===e?``:e||``}),o=Qe(function(){return!Array.isArray(a.value)&&!r(a.value)}),s=nt(function(){if(this.N=pt,o.value){var t=a.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),c=t.__$u.d;return t.__$u.d=function(){s(),c.call(this)},[o,a]},[]),o=a[0],s=a[1];return o.value?s.peek():s.value}ct.displayName=`ReactiveTextNode`,Object.defineProperties(L.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:ct},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),V(`__b`,function(e,t){if(st(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof L&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),V(`__r`,function(e,t){if(e(t),t.type!==S){st();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return nt(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;at&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),st(n)}}),V(`__e`,function(e,t,n,r){st(),e(t,n,r)}),V(`diffed`,function(e,t){st();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=lt(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function lt(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=R(n);return{o:function(e,t){a.value=e,r=t},d:nt(function(){this.N=pt;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}V(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),V(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),te.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function ut(e,t){return ke(function(){return R(e,t)},[])}var dt=function(e){queueMicrotask(function(){queueMicrotask(e)})};function ft(){ze(function(){for(var e;e=ot.shift();)rt.call(e)})}function pt(){ot.push(this)===1&&(t.requestAnimationFrame||dt)(ft)}var mt=(e,t)=>{let n=t.toLowerCase().replace(/\s+/g,``);if(n===``)return 0;let r=e.toLowerCase(),i=Array.from(n).reduce((e,t)=>{if(e===void 0)return;let n=r.indexOf(t,e.at);return n===-1?void 0:{at:n+1,gaps:e.gaps+(e.first===-1?0:n-e.at),first:e.first===-1?n:e.first}},{at:0,gaps:0,first:-1});return i===void 0?void 0:i.gaps*2+i.first+(r.startsWith(n)?-10:0)},ht=(e,t)=>e.flatMap(e=>{let n=mt(`${e.label} ${e.hint}`,t);return n===void 0?[]:[{choice:e,scored:n}]}).toSorted((e,t)=>e.scored-t.scored).map(e=>e.choice),gt=e=>e,_t=async(e,t)=>e.ok?{ok:!0,value:gt(await t(e))}:{ok:!1,failure:{status:e.status,message:(await e.text()).trim()}},vt=async e=>_t(await fetch(e),e=>e.json()),yt=async e=>_t(await fetch(e),e=>e.text()),bt=async(e,t)=>_t(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),async e=>e.status===204||e.status===202?void 0:e.json()),xt=e=>bt(`/api/plan`,e),St=(e,t)=>bt(`/api/runs`,{command:e,...t===void 0?{}:{confirm:t}}),Ct=(e,t)=>bt(`/api/runs/${encodeURIComponent(e)}/answer`,{text:t}),wt=e=>bt(`/api/runs/${encodeURIComponent(e)}/cancel`,{}),Tt=()=>vt(`/api/runs`),Et=(e,t,n)=>{let r=new EventSource(e),i=()=>{r.close()};return r.addEventListener(`message`,e=>{t(gt(JSON.parse(e.data)))}),r.addEventListener(`end`,()=>{i(),n()}),r.addEventListener(`error`,()=>{i(),n()}),i},Dt=/^[A-Za-z0-9._-]+$/,Ot=e=>{let t=e.split(`/`).filter(e=>e!==``).map(decodeURIComponent);if(!t.every(e=>Dt.test(e)))return{page:`missing`,path:e};let[n,r,i,a]=t;return n===void 0?{page:`fleet`}:n===`runs`&&r===void 0?{page:`runs`}:n===`runs`&&r!==void 0&&i===void 0?{page:`run`,id:r}:n===`validate`&&r===void 0?{page:`validate`}:n===`servers`&&r!==void 0&&i===void 0?{page:`server`,server:r}:n===`servers`&&r!==void 0&&i===`apps`&&a!==void 0&&t.length===4?{page:`app`,server:r,app:a}:{page:`missing`,path:e}},kt=e=>{switch(e.page){case`fleet`:return`/`;case`server`:return`/servers/${encodeURIComponent(e.server)}`;case`app`:return`/servers/${encodeURIComponent(e.server)}/apps/${encodeURIComponent(e.app)}`;case`runs`:return`/runs`;case`run`:return`/runs/${encodeURIComponent(e.id)}`;case`validate`:return`/validate`;case`missing`:return e.path}},At=R(Ot(location.pathname)),jt=e=>{history.pushState(null,``,kt(e)),At.value=e,scrollTo({top:0})};addEventListener(`popstate`,()=>{At.value=Ot(location.pathname)});var H=R({state:`loading`}),U=R({value:void 0,live:!1}),Mt=R({state:`loading`}),Nt=async()=>{let e=await vt(`/api/fleet`);H.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Pt=()=>{U.value={value:U.value.value,live:!0},Et(`/api/status`,e=>{U.value={value:e,live:!0}},()=>{U.value={value:U.value.value,live:!1}})},Ft=async()=>{Mt.value={state:`loading`};let e=await vt(`/api/validate`);Mt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},It=0;Array.isArray;function W(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--It,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var Lt=(e,t)=>{if(typeof e==`string`)return e;let n=e.tone===void 0?void 0:`tone-${e.tone}`;return e.href===void 0?W(`span`,{class:n,children:e.text},t):W(`a`,{class:n,href:e.href,target:`_blank`,rel:`noreferrer`,children:e.text},t)},Rt=({text:e})=>W(S,{children:(typeof e==`string`?[e]:e).map(Lt)}),zt=({lines:e})=>W(`div`,{class:`lines`,children:e.map((e,t)=>W(`div`,{children:W(Rt,{text:e})},t))}),G=({tone:e,label:t})=>W(`span`,{class:`dot dot-${e}`,title:t,"aria-label":t,role:t===void 0?void 0:`img`}),K=({children:e,tone:t})=>W(`span`,{class:`pill${t===void 0?``:` pill-${t}`}`,children:e}),q=({label:e,cell:t})=>t===void 0?null:W(`div`,{class:`fact`,children:[W(`dt`,{children:e}),W(`dd`,{title:t.title,children:[W(G,{tone:t.tone}),W(`span`,{class:t.tone===`waiting`?`tone-muted`:`tone-${t.tone}`,children:t.text})]})]}),J=({failure:e})=>W(`div`,{class:`problem`,role:`alert`,children:[W(`strong`,{children:[`kayra ui answered `,e.status]}),W(`pre`,{children:e.message})]}),Y=({what:e})=>W(`div`,{class:`waiting`,children:[W(`span`,{class:`spinner`,"aria-hidden":`true`}),` `,e]}),X=({title:e,sub:t,children:n})=>W(`header`,{class:`page-header`,children:[W(`div`,{children:[W(`h1`,{children:e}),t===void 0?null:W(`div`,{class:`sub`,children:t})]}),n===void 0?null:W(`div`,{class:`actions`,children:n})]}),Bt=R(void 0),Z=e=>{Bt.value=e},Vt=()=>{Bt.value=void 0},Ht=e=>e===`guard`?`warn`:e===`confirm`?`bad`:e===`note`?`muted`:`active`,Ut=({step:e})=>W(`li`,{class:`plan-step`,children:[W(`span`,{class:`plan-index`,children:e.index+1}),W(`div`,{children:[W(`div`,{class:`plan-title`,children:[W(K,{tone:Ht(e.kind),children:e.kind}),` `,e.title]}),e.command===void 0?null:W(`code`,{class:`plan-command`,children:e.command})]})]}),Wt=e=>{if(e.name===`doctor`)return;let t=H.value,n=t.state===`ready`?t.value.servers.find(t=>t.name===e.server):void 0;return n===void 0||n.target===`multipass`?void 0:n.name},Gt=({command:e})=>{let[t,n]=N(void 0),[r,i]=N(``),[a,o]=N(void 0),s=Oe(null),c=t?.ok===!0;if(P(()=>{c&&s.current?.focus()},[c]),P(()=>{xt(e).then(n)},[e]),t===void 0)return W(Y,{what:`Planning`});if(!t.ok)return W(J,{failure:t.failure});let{invocation:l,steps:u,changes:d}=t.value,f=d?Wt(e):void 0,p=f===void 0||r===f,m=async()=>{o(`starting`);let t=await St(e,f===void 0?void 0:r);t.ok?(Vt(),jt({page:`run`,id:t.value.id})):o(t.failure)},h=u.reduce((e,t)=>{let n=e.at(-1);return t.opens!==void 0||n===void 0?[...e,{part:t.opens,steps:[t]}]:[...e.slice(0,-1),{...n,steps:[...n.steps,t]}]},[]);return W(S,{children:[W(`div`,{class:`sheet-head`,children:[W(`code`,{class:`command`,children:l.command}),W(`div`,{class:`sub`,children:[l.about.join(` · `),` · `,u.length,` steps · `,d?`changes things`:`reads only`]})]}),W(`div`,{class:`sheet-body`,children:h.map((e,t)=>W(`section`,{children:[e.part===void 0?null:W(`h3`,{class:`part`,children:e.part}),W(`ol`,{class:`plan`,children:e.steps.map(e=>W(Ut,{step:e},e.index))})]},t))}),W(`form`,{class:`sheet-foot`,onSubmit:e=>{e.preventDefault(),p&&m()},children:[f===void 0?null:W(`label`,{class:`confirm`,children:[W(`span`,{children:[`This changes `,W(`strong`,{children:f}),`, a real server. Type its name to go on:`]}),W(`input`,{ref:s,value:r,onInput:e=>{i(e.currentTarget.value)},placeholder:f,spellcheck:!1})]}),a===void 0||a===`starting`?null:W(J,{failure:a}),W(`div`,{class:`buttons`,children:[W(`button`,{type:`button`,class:`button`,onClick:Vt,children:`Cancel`}),W(`button`,{type:`submit`,class:f===void 0?`button primary`:`button danger`,disabled:!p||a===`starting`,children:a===`starting`?`Starting…`:`Run ${l.command}`})]})]})]})},Kt=()=>{let e=Bt.value;return P(()=>{let e=e=>{e.key===`Escape`&&Vt()};return addEventListener(`keydown`,e),()=>{removeEventListener(`keydown`,e)}},[]),e===void 0?null:W(`div`,{class:`overlay`,onClick:Vt,children:W(`div`,{class:`sheet`,role:`dialog`,"aria-modal":`true`,onClick:e=>{e.stopPropagation()},children:W(Gt,{command:e})})})},Q=R(!1),qt=()=>{let e=H.value;return[{label:`Fleet`,hint:`every server`,go:{page:`fleet`}},{label:`Runs`,hint:`what ran from here`,go:{page:`runs`}},{label:`Validate`,hint:`the fleet beyond its schemas`,go:{page:`validate`}},{label:`doctor`,hint:`can this Mac run everything`,run:{name:`doctor`}},...(e.state===`ready`?e.value.servers:[]).flatMap(e=>[{label:e.name,hint:`${e.kind} on ${e.target}`,go:{page:`server`,server:e.name}},...e.apps.map(t=>({label:`${e.name}/${t}`,hint:`app`,go:{page:`app`,server:e.name,app:t}})),...e.commands.flatMap(t=>t===`job`?[]:[{label:`${t} ${e.name}`,hint:`run`,run:{name:t,server:e.name}}])])]},Jt=e=>{Q.value=!1,`go`in e?jt(e.go):Z(e.run)},Yt=()=>{let[e,t]=N(``),[n,r]=N(0),i=Oe(null),a=Q.value;if(P(()=>{a&&i.current?.focus()},[a]),P(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),Q.value=!Q.value,t(``),r(0)):e.key===`Escape`&&(Q.value=!1)};return addEventListener(`keydown`,e),()=>{removeEventListener(`keydown`,e)}},[]),!Q.value)return null;let o=ht(qt(),e).slice(0,12);return W(`div`,{class:`overlay`,onClick:()=>{Q.value=!1},children:W(`div`,{class:`palette`,role:`dialog`,"aria-modal":`true`,onClick:e=>{e.stopPropagation()},children:[W(`input`,{ref:i,value:e,placeholder:`Go to, or run…`,spellcheck:!1,onInput:e=>{t(e.currentTarget.value),r(0)},onKeyDown:e=>{if(e.key===`ArrowDown`)r(Math.min(n+1,o.length-1));else if(e.key===`ArrowUp`)r(Math.max(n-1,0));else if(e.key===`Enter`){let e=o[n];e!==void 0&&Jt(e)}else return;e.preventDefault()}}),W(`ul`,{children:o.map((e,t)=>W(`li`,{class:t===n?`selected`:void 0,onMouseEnter:()=>{r(t)},onClick:()=>{Jt(e)},children:[W(`span`,{children:e.label}),W(`span`,{class:`hint`,children:e.hint})]},e.label))})]})})},Xt=()=>{Q.value=!0},Zt=e=>e===null?``:` · ${String(e)} ms`,Qt={pending:`asking`,open:`open`,answered:`answered`,refused:`refused`,"no-answer":`no answer`,unreachable:`unreachable`,"unknown-host":`unknown host`,"bad-certificate":`bad certificate`,failed:`failed`,skipped:`not asked`},$t=e=>{let{state:t,address:n,reason:r}=e.machine;switch(t){case`pending`:return{text:`asking OpenTofu`,tone:`waiting`};case`found`:return{text:n??`an address OpenTofu does not give`,tone:n===null?`warn`:`strong`};case`not-provisioned`:return{text:`not provisioned`,tone:`muted`};case`no-machine`:return{text:`no machine in its state`,tone:`muted`};case`unreadable`:return{text:`state unreadable`,tone:`bad`,...r===null?{}:{title:r}}}},en=e=>{let{state:t,error:n}=e.ssh;switch(t){case`pending`:return{text:`connecting`,tone:`waiting`};case`open`:return{text:`port ${String(e.ssh.port)} open${Zt(e.ssh.ms)}`,tone:`ok`};case`refused`:return{text:`off (refused)`,tone:`warn`,title:`Nothing listens: SSH may be on only on demand.`};case`skipped`:return{text:`not asked`,tone:`muted`};case`answered`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return{text:Qt[t],tone:`bad`,...n===null?{}:{title:n}}}},tn=e=>{let{https:t}=e;if(t!==null)switch(t.state){case`pending`:return{text:`asking`,tone:`waiting`};case`answered`:return{text:`HTTP ${String(t.status??`?`)}${Zt(t.ms)}`,tone:t.status!==null&&t.status<400?`ok`:`bad`};case`skipped`:return{text:`not asked`,tone:`muted`};case`open`:case`refused`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return{text:Qt[t.state],tone:`bad`,...t.error===null?{}:{title:t.error}}}},nn=e=>{if(e===void 0)return`waiting`;let t=[$t(e),en(e),tn(e)].flatMap(e=>e===void 0?[]:[e.tone]);return t.includes(`waiting`)?`waiting`:t.includes(`bad`)?`bad`:t.includes(`warn`)?`warn`:t.includes(`ok`)?`ok`:`muted`},$=({to:e,children:t,class:n})=>W(`a`,{href:kt(e),class:n,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),jt(e))},children:t}),rn=(e,t)=>kt(e)===kt(t),an=({to:e,label:t})=>W($,{to:e,class:rn(At.value,e)?`nav-item current`:`nav-item`,children:t}),on=()=>{let e=H.value;if(e.state!==`ready`)return null;let t=At.value;return W(`nav`,{class:`servers`,"aria-label":`Servers`,children:[W(`div`,{class:`nav-title`,children:`Servers`}),e.value.servers.map(e=>W($,{to:{page:`server`,server:e.name},class:`server`in t&&t.server===e.name?`nav-item current`:`nav-item`,children:[W(G,{tone:nn(U.value.value?.servers.find(t=>t.name===e.name))}),W(`span`,{children:e.name}),W(`span`,{class:`nav-meta`,children:e.kind})]},e.name))]})},sn=({children:e})=>{let t=H.value;return W(`div`,{class:`shell`,children:[W(`aside`,{class:`sidebar`,children:[W($,{to:{page:`fleet`},class:`brand`,children:[W(`span`,{class:`logo`,"aria-hidden":`true`,children:`k`}),W(`span`,{children:[W(`strong`,{children:`kayra`}),W(`span`,{class:`brand-sub`,children:t.state===`ready`?t.value.fleet:`…`})]})]}),W(`nav`,{"aria-label":`Pages`,children:[W(an,{to:{page:`fleet`},label:`Fleet`}),W(an,{to:{page:`runs`},label:`Runs`}),W(an,{to:{page:`validate`},label:`Validate`})]}),W(on,{}),W(`div`,{class:`sidebar-foot`,children:t.state===`ready`?`kayra ${t.value.version}`:``})]}),W(`main`,{class:`main`,children:e})]})},cn=e=>{let t=Math.max(0,e)/1e3;if(t<10)return`${(Math.floor(t*10)/10).toFixed(1)}s`;if(t<60)return`${String(Math.floor(t))}s`;let n=Math.floor(t/60);return n<60?`${String(n)}m${String(Math.floor(t%60)).padStart(2,`0`)}s`:`${String(Math.floor(n/60))}h${String(n%60).padStart(2,`0`)}m`},ln=e=>{let t=Math.floor(Math.max(0,e)/1e3);if(t<10)return`just now`;if(t<60)return`${String(t)}s ago`;let n=Math.floor(t/60);if(n<60)return`${String(n)}m ago`;let r=Math.floor(n/60);return r<48?`${String(r)}h ago`:`${String(Math.floor(r/24))}d ago`},un=e=>Date.parse(e),dn=(e,t,n)=>`/api/servers/${encodeURIComponent(e)}/apps/${encodeURIComponent(t)}/${n}`,fn=(e,t)=>{let[n,r]=N(void 0),i=()=>{r(void 0),e().then(r)};return P(i,[t]),[n,i]},pn=e=>e===`success`?`ok`:e===`failure`?`bad`:`waiting`,mn=({server:e,app:t,open:n})=>{let[r]=fn(()=>vt(dn(e,t,`runs`)),`${e}/${t}`);if(r===void 0)return W(Y,{what:`Asking the deployer`});if(!r.ok)return W(J,{failure:r.failure});let i=Date.now(),{live:a,runs:o}=r.value;return W(S,{children:[W(`p`,{class:`sub`,children:a===void 0?`Not deployed yet.`:`Live: ${a.sha.slice(0,7)} since ${ln(i-Date.parse(a.time))}`}),W(`table`,{class:`table`,children:[W(`thead`,{children:W(`tr`,{children:[W(`th`,{}),W(`th`,{children:`Commit`}),W(`th`,{children:`Why`}),W(`th`,{children:`What`}),W(`th`,{class:`right`,children:`When`}),W(`th`,{class:`right`,children:`Took`})]})}),W(`tbody`,{children:o.map(e=>W(`tr`,{class:`clickable`,onClick:()=>{n(e.id)},children:[W(`td`,{class:`narrow`,children:W(G,{tone:pn(e.state),label:e.state})}),W(`td`,{children:W(`code`,{children:e.sha?.slice(0,7)??``})}),W(`td`,{children:e.why}),W(`td`,{children:e.what}),W(`td`,{class:`right tone-muted`,children:ln(i-Date.parse(e.started))}),W(`td`,{class:`right tone-muted`,children:e.finished===void 0?``:cn(Date.parse(e.finished)-Date.parse(e.started))})]},e.id))})]})]})},hn=({server:e,app:t})=>{let[n]=fn(()=>vt(dn(e,t,`releases`)),`${e}/${t}`);if(n===void 0)return W(Y,{what:`Asking the deployer`});if(!n.ok)return W(J,{failure:n.failure});let r=Date.now();return W(`ul`,{class:`releases`,children:n.value.releases.map(n=>W(`li`,{children:[W(`code`,{children:n.sha.slice(0,12)}),W(`span`,{class:`tone-muted`,children:ln(r-Date.parse(n.time))}),n.live?W(K,{tone:`ok`,children:`live`}):W(`button`,{class:`button small`,onClick:()=>{Z({name:`app rollback`,server:e,app:t,sha:n.sha})},children:`Roll back to it`})]},n.sha))})},gn=e=>{if(/\b(error|failed|fatal|refused)\b/i.test(e))return`tone-bad`;if(/\bwarn(ing)?\b/i.test(e))return`tone-warn`},_n=({server:e,app:t,run:n})=>{let[r]=fn(()=>yt(dn(e,t,n===void 0?`logs`:`logs/${encodeURIComponent(n)}`)),`${e}/${t}/${n??``}`);return r===void 0?W(Y,{what:`Fetching the log`}):r.ok?W(`pre`,{class:`log`,children:r.value.split(`
|
|
2
|
+
`).map((e,t)=>W(`div`,{class:gn(e),children:e===``?` `:e},t))}):W(J,{failure:r.failure})},vn=({server:e,app:t})=>{let[n,r]=N(`runs`),[i,a]=N(void 0),[o,s]=N(``);return W(S,{children:[W(X,{title:t,sub:`on ${e}`,children:W(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),Z({name:`app deploy`,server:e,app:t,...o.trim()===``?{}:{ref:o.trim()}})},children:[W(`input`,{value:o,onInput:e=>{s(e.currentTarget.value)},placeholder:`its ref`,spellcheck:!1,"aria-label":`Branch, tag or commit`}),W(`button`,{type:`submit`,class:`button primary`,children:`Deploy`})]})}),W(`nav`,{class:`tabs`,role:`tablist`,children:[`runs`,`releases`,`log`].map(e=>W(`button`,{role:`tab`,"aria-selected":n===e,class:n===e?`tab current`:`tab`,onClick:()=>{r(e)},children:[e,e===`log`&&i!==void 0?` · ${i}`:``]},e))}),W(`section`,{class:`card`,children:n===`runs`?W(mn,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?W(hn,{server:e,app:t}):W(_n,{server:e,app:t,run:i})}),W(`p`,{class:`tone-muted small`,children:[`Purging an app's data is irreversible:`,` `,W(`button`,{class:`link danger-link`,onClick:()=>{Z({name:`app purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},yn=({facts:e,seen:t})=>W($,{to:{page:`server`,server:e.name},class:`card server-card`,children:[W(`div`,{class:`card-head`,children:[W(G,{tone:nn(t)}),W(`h2`,{children:e.name}),W(K,{children:e.kind}),W(K,{tone:e.target===`multipass`?`muted`:e.target===`hetzner`?`accent`:`active`,children:e.target})]}),W(`div`,{class:`domain`,children:e.domain}),t===void 0?W(Y,{what:`asking`}):W(`dl`,{class:`facts`,children:[W(q,{label:`Address`,cell:$t(t)}),W(q,{label:`SSH`,cell:en(t)}),W(q,{label:`Login`,cell:tn(t)})]}),e.apps.length===0?null:W(`div`,{class:`chips`,children:e.apps.map(e=>W(K,{children:e},e))})]}),bn=()=>{let e=H.value;if(e.state===`loading`)return W(Y,{what:`Reading the fleet`});if(e.state===`failed`)return W(J,{failure:e.failure});let{value:t,live:n}=U.value,{servers:r}=e.value,i=r.filter(e=>nn(t?.servers.find(t=>t.name===e.name))===`ok`).length;return W(S,{children:[W(X,{title:`Fleet`,sub:W(S,{children:[r.length,` servers · `,t===void 0?`asking each`:`${String(i)} answering everything they were asked`]}),children:W(`button`,{class:`button`,onClick:Pt,disabled:n,children:n?`Asking…`:`Ask again`})}),W(`div`,{class:`cards`,children:r.map(e=>W(yn,{facts:e,seen:t?.servers.find(t=>t.name===e.name)},e.name))})]})},xn={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Sn=(e,t,n)=>t===void 0?e:{...e,steps:e.steps.map((e,r)=>r===t?n(e):e)},Cn=(e,t)=>Sn(e,e.current,e=>({...e,said:[...e.said,t]})),wn=(e,t,n)=>{switch(t.kind){case`plan`:return{...e,invocation:t.invocation,steps:t.steps.map(e=>({listed:e,state:`waiting`,said:[]}))};case`started`:return Sn({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Sn(e,t.index,e=>({...e,state:t.failed?`failed`:t.stopped?`stopped`:`passed`,ms:t.ms,...t.why===void 0?{}:{why:t.why}}));case`ended`:{let n={failures:t.failures,ms:t.ms,footer:t.footer,...t.stop===void 0?{}:{stop:t.stop}};return{...e,asking:void 0,ended:n,steps:e.steps.map((e,n)=>e.state===`running`||t.stop?.why===`interrupted`&&t.stop.index===n?{...e,state:`stopped`}:e.state===`waiting`?{...e,state:`skipped`}:e)}}case`output`:return Cn(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Cn(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return{...e,asking:t.prompt};case`answered`:return{...e,asking:void 0}}},Tn=e=>{let{ended:t}=e;return t===void 0?`running`:t.stop?.why===`interrupted`?`interrupted`:t.stop?.why===`declined`?`declined`:t.failures===0?`passed`:`failed`},En={fg:void 0,bold:!1,dim:!1},Dn=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],On=(e,t)=>{let n=t===``?[0]:t.split(`;`).map(Number),r=(e,t)=>{let[n,...i]=t;return n===void 0?e:n===38||n===48?r(e,i[0]===5?i.slice(2):i[0]===2?i.slice(4):i):r(n===0?En:n===1?{...e,bold:!0}:n===2?{...e,dim:!0}:n===22?{...e,bold:!1,dim:!1}:n===39?{...e,fg:void 0}:n>=30&&n<=37?{...e,fg:Dn[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${Dn[n-90]??`white`}`}:e,i)};return r(e,n)},kn=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),An=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,jn=e=>{let t=[...e.matchAll(An)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:kn(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:On(t.look,a),at:n.index+n[0].length}},{out:[],look:En,at:0}),n=e.slice(t.at);return n===``?t.out:[...t.out,{text:n,classes:kn(t.look)}]},Mn={running:`active`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},Nn={waiting:`○`,running:``,passed:`✓`,failed:`✗`,stopped:`■`,skipped:`–`},Pn=({step:e})=>W(`div`,{class:`output`,children:e.said.map((e,t)=>e.kind===`output`?W(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:jn(e.chunk).map((e,t)=>W(`span`,{class:e.classes===``?void 0:e.classes,children:e.text},t))},t):W(`div`,{class:e.stream===`err`?`said said-err`:`said`,children:W(Rt,{text:e.text})},t))}),Fn=({step:e,now:t})=>{let n=e.state===`running`||e.state===`failed`,r=e.ms??(e.started===void 0?void 0:t-e.started),i=e.said.length===0?null:W(Pn,{step:e});return W(`details`,{class:`step step-${e.state}`,open:n,children:[W(`summary`,{children:[W(`span`,{class:`step-icon`,children:e.state===`running`?W(`span`,{class:`spinner`}):Nn[e.state]}),W(`span`,{class:`step-title`,children:e.listed.title}),W(`span`,{class:`step-kind`,children:e.listed.kind}),W(`span`,{class:`step-time`,children:[e.why===void 0?``:`${e.why} · `,r===void 0?``:cn(r)]})]}),i]})},In=({id:e,prompt:t})=>{let[n,r]=N(``);return W(`form`,{class:`ask`,onSubmit:t=>{t.preventDefault(),Ct(e,n)},children:[W(Rt,{text:t}),W(`input`,{value:n,onInput:e=>{r(e.currentTarget.value)},autoFocus:!0,spellcheck:!1}),W(`button`,{type:`submit`,class:`button danger`,children:`Answer`}),W(`button`,{type:`button`,class:`button`,onClick:()=>void Ct(e,``),children:`Don't`})]})},Ln=({id:e})=>{let[t,n]=De((e,t)=>wn(e,t,Date.now()),xn),[r,i]=N(Date.now());P(()=>Et(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0),[e]);let a=Tn(t)===`running`;P(()=>{if(!a)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[a]);let{invocation:o,steps:s,ended:c,asking:l}=t;if(o===void 0)return W(Y,{what:`Starting`});let u=Tn(t);return W(S,{children:[W(X,{title:W(`code`,{class:`command`,children:o.command}),sub:`${o.about.join(` · `)} · ${String(s.length)} steps`,children:[W(K,{tone:Mn[u],children:u}),a?W(`button`,{class:`button danger`,onClick:()=>void wt(e),children:`Stop`}):null]}),l===void 0?null:W(In,{id:e,prompt:l}),W(`div`,{class:`timeline`,children:s.map(e=>W(`div`,{children:[e.listed.opens===void 0?null:W(`h3`,{class:`part`,children:e.listed.opens}),W(Fn,{step:e,now:r})]},e.listed.index))}),c===void 0?null:W(`footer`,{class:`run-footer tone-border-${Mn[u]}`,children:W(zt,{lines:c.footer})})]})},Rn={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},zn=({server:e})=>{let[t,n]=N(void 0);if(P(()=>{let e=()=>{Tt().then(n)};e();let t=setInterval(e,3e3);return()=>{clearInterval(t)}},[]),t===void 0)return W(Y,{what:`Reading the runs`});if(!t.ok)return W(J,{failure:t.failure});let r=t.value.filter(t=>e===void 0||t.server===e);if(r.length===0)return W(`p`,{class:`empty`,children:`Nothing run from here yet.`});let i=Date.now();return W(`table`,{class:`table`,children:W(`tbody`,{children:r.map(e=>W(`tr`,{children:[W(`td`,{class:`narrow`,children:W(G,{tone:Rn[e.state],label:e.state})}),W(`td`,{children:W($,{to:{page:`run`,id:e.id},children:W(`code`,{children:e.command})})}),W(`td`,{class:`tone-${Rn[e.state]===`waiting`?`active`:Rn[e.state]}`,children:e.state}),W(`td`,{class:`tone-muted right`,children:ln(i-un(e.started))})]},e.id))})})},Bn=()=>W(S,{children:[W(X,{title:`Runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs`}),W(`section`,{class:`card`,children:W(zn,{})})]}),Vn={deploy:`Host setup and every app, then verify`,apps:`Register every app in server.yml, remove the rest`,verify:`Check it as its users see it`,setup:`The host layer: the playbook for its kind`,plan:`What provision and setup would change, changing nothing`,up:`Provision, set up, every app, /etc/hosts`,provision:`Create or update the machine`,"backup test":`Restore the latest backup to a scratch dir and check it`,adopt:`Once, for a server kayra did not create`,down:`Destroy the machine`},Hn=[`down`,`adopt`,`provision`],Un=({facts:e})=>W(`div`,{class:`action-grid`,children:[e.commands.filter(e=>e!==`job`).map((t,n)=>W(`button`,{class:`action${n===0?` primary`:``}${Hn.includes(t)?` danger`:``}`,disabled:e.needsTerminal&&t!==`plan`&&t!==`verify`,onClick:()=>{Z({name:t,server:e.name})},children:[W(`strong`,{children:t}),W(`span`,{children:Vn[t]})]},t)),e.commands.includes(`job`)?W(S,{children:[W(`button`,{class:`action`,onClick:()=>{Z({name:`job`,server:e.name,job:`gc`,noPrs:!1})},children:[W(`strong`,{children:`job gc`}),W(`span`,{children:`The registry's garbage collection, now`})]}),W(`button`,{class:`action`,onClick:()=>{Z({name:`job`,server:e.name,job:`renovate`,noPrs:!0})},children:[W(`strong`,{children:`job renovate`}),W(`span`,{children:`Renovate now, logging what it would change`})]})]}):null]}),Wn=({name:e})=>{let t=H.value;if(t.state!==`ready`)return W(Y,{what:`Reading the fleet`});let n=t.value.servers.find(t=>t.name===e);if(n===void 0)return W(`p`,{class:`empty`,children:[`No server `,e,` in this fleet.`]});let r=U.value.value?.servers.find(t=>t.name===e);return W(S,{children:[W(X,{title:W(S,{children:[W(G,{tone:nn(r)}),` `,n.name]}),sub:W(S,{children:[W(K,{children:n.kind}),` `,W(K,{children:n.target}),` `,W(`a`,{href:`https://${n.domain}`,target:`_blank`,rel:`noreferrer`,children:n.domain})]})}),n.needsTerminal?W(`div`,{class:`notice`,children:`Its vault password is asked on a terminal: what opens its secrets runs from the command line, or give it a vault_password_file.`}):null,W(`div`,{class:`columns`,children:[W(`section`,{class:`card`,children:[W(`h2`,{children:`Now`}),r===void 0?W(Y,{what:`asking`}):W(`dl`,{class:`facts`,children:[W(q,{label:`Address`,cell:$t(r)}),W(q,{label:`SSH`,cell:en(r)}),W(q,{label:`Login`,cell:tn(r)})]})]}),W(`section`,{class:`card`,children:[W(`h2`,{children:`Apps`}),n.apps.length===0?W(`p`,{class:`empty`,children:n.kind===`platform`?`None in server.yml.`:`A ${n.kind} server runs no apps.`}):W(`ul`,{class:`links`,children:n.apps.map(e=>W(`li`,{children:W($,{to:{page:`app`,server:n.name,app:e},children:e})},e))})]})]}),W(`section`,{class:`card`,children:[W(`h2`,{children:`Commands`}),W(Un,{facts:n})]}),W(`section`,{class:`card`,children:[W(`h2`,{children:`Runs from here`}),W(zn,{server:n.name})]})]})},Gn=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,Kn=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,qn={problem:`problems`,unchecked:`partly checked`,passed:`holds`},Jn=()=>{P(()=>{Ft()},[]);let e=Mt.value;if(e.state===`loading`)return W(Y,{what:`Checking the fleet beyond its schemas`});if(e.state===`failed`)return W(J,{failure:e.failure});let{result:t,servers:n}=e.value,r=e=>n.flatMap(e=>e.findings).filter(t=>t.result===e).length;return W(S,{children:[W(X,{title:`Validate`,sub:`Secrets, apps against their contract, stacks, routes · ${String(r(`problem`))} problems · ${String(r(`unchecked`))} not checked`,children:[W(K,{tone:Gn(t),children:qn[t]}),W(`button`,{class:`button`,onClick:()=>void Ft(),children:`Check again`})]}),n.map(e=>W(`section`,{class:`card`,children:[W(`div`,{class:`card-head`,children:[W(G,{tone:Gn(e.result)}),W(`h2`,{children:e.name}),W(K,{children:e.kind}),W(K,{children:e.target}),W(`span`,{class:`grow`}),W(K,{tone:Gn(e.result),children:qn[e.result]})]}),W(`ul`,{class:`findings`,children:e.findings.map((e,t)=>W(`li`,{class:`finding finding-${e.result}`,children:[W(`span`,{class:`glyph tone-${Gn(e.result)}`,children:Kn(e.result)}),W(`span`,{children:[e.text,e.hint===null?null:W(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},Yn=()=>{let e=At.value;switch(e.page){case`fleet`:return W(bn,{});case`server`:return W(Wn,{name:e.server});case`app`:return W(vn,{server:e.server,app:e.app});case`runs`:return W(Bn,{});case`run`:return W(Ln,{id:e.id});case`validate`:return W(Jn,{});case`missing`:return W(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},Xn=()=>(P(()=>{Nt(),Pt()},[]),W(S,{children:[W(sn,{children:[W(`div`,{class:`topbar`,children:[W(`button`,{class:`search`,onClick:Xt,children:[W(`span`,{children:`Go to, or run…`}),W(`kbd`,{children:`⌘K`})]}),W(`button`,{class:`button`,onClick:()=>{Z({name:`doctor`})},children:`Doctor`})]}),W(Yn,{})]}),W(Kt,{}),W(Yt,{})]})),Zn=document.getElementById(`app`);Zn!==null&&me(W(Xn,{}),Zn);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="color-scheme" content="light dark" />
|
|
7
|
+
<title>kayra</title>
|
|
8
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%235b5bd6'/%3E%3Cpath d='M11 8v16M11 16l9-8M14 13l7 11' stroke='white' stroke-width='3' stroke-linecap='round' fill='none'/%3E%3C/svg%3E" />
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-DRFX9Q77.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/assets/index-3W_NFATj.css">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div id="app"></div>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yunuseon/kayra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A self-hosted app platform and the CLI that runs it: Traefik, Authelia, a registry, rootless BuildKit and a small deployer per server, set up with OpenTofu and Ansible.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yunus Öztürk",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"kayra": "node cli/src/main.ts",
|
|
36
36
|
"build": "tsc -p cli/tsconfig.build.json",
|
|
37
|
-
"
|
|
37
|
+
"build:web": "npm --prefix web ci --silent && npm --prefix web run build -- --outDir ../cli/dist/web --emptyOutDir",
|
|
38
|
+
"prepack": "npm run build && npm run build:web",
|
|
38
39
|
"typecheck": "tsc -p cli --noEmit",
|
|
39
40
|
"lint": "cd cli && eslint --flag unstable_native_nodejs_ts_config .",
|
|
40
41
|
"test": "node --test 'cli/test/**/*.test.ts'",
|
package/scripts/agent/guard.sh
CHANGED
|
@@ -57,6 +57,8 @@ if has "${kayra} +(--[a-z-]+ +)*${verbs}( |$)" && ! has '--dry-run'; then
|
|
|
57
57
|
|| target="$(sed -n 's/^target: *\([a-z]*\).*/\1/p' "${project}/servers/${server}/server.yml")"
|
|
58
58
|
[ "$target" = multipass ] || ask "kayra changes ${server:-a server}${target:+ (target ${target})}"
|
|
59
59
|
fi
|
|
60
|
+
# kayra ui runs any command on any server from a browser, where this guard sees none of them.
|
|
61
|
+
has "${kayra} +(--[a-z-]+ +)*ui( |$)" && ask "kayra ui runs commands on every server from a browser, out of this guard's sight"
|
|
60
62
|
|
|
61
63
|
# ── Ansible and the vaults ──────────────────────────────────────────────────
|
|
62
64
|
has '(^|[;&|( ])ansible-vault +(decrypt|view|edit|encrypt|encrypt_string|rekey|create)( |$)' \
|
package/scripts/local/verify.sh
CHANGED
|
@@ -28,8 +28,8 @@ dir="${FLEET_ROOT}/servers/${name}"
|
|
|
28
28
|
wait="${VERIFY_WAIT:-150}"
|
|
29
29
|
failed=0
|
|
30
30
|
|
|
31
|
-
fail() { echo "✗ $*"; failed=1; }
|
|
32
|
-
pass() { echo "✓ $*"; }
|
|
31
|
+
fail() { echo " ✗ $*"; failed=1; }
|
|
32
|
+
pass() { echo " ✓ $*"; }
|
|
33
33
|
|
|
34
34
|
domain="$(yq -r '.domain' "${dir}/server.yml")"
|
|
35
35
|
inventory="${dir}/inventory.ini"
|