@yunuseon/kayra 0.16.0 → 0.17.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/README.md +4 -0
- package/agent/skills/kayra-release/SKILL.md +8 -0
- package/cli/dist/browser/assets/index-9a-SE2rU.js +7 -0
- package/cli/dist/{web/assets/index-3W_NFATj.css → browser/assets/index-Ct0Eudk4.css} +1 -1
- package/cli/dist/browser/assets/xterm-CerOhKYV.js +16 -0
- package/cli/dist/{web → browser}/index.html +2 -2
- package/cli/dist/clients/api/api.js +269 -0
- package/cli/dist/clients/api/auth.js +36 -0
- package/cli/dist/clients/api/commands.js +27 -0
- package/cli/dist/clients/api/contract.gen.js +1 -0
- package/cli/dist/clients/api/contract.js +89 -0
- package/cli/dist/clients/api/directories.js +20 -0
- package/cli/dist/clients/api/discovery.js +38 -0
- package/cli/dist/clients/api/protocol.js +61 -0
- package/cli/dist/clients/api/queries.js +20 -0
- package/cli/dist/clients/api/runs.js +51 -0
- package/cli/dist/{ui → clients/cli}/explain.js +5 -5
- package/cli/dist/clients/cli/framed.js +64 -0
- package/cli/dist/clients/cli/invocation.js +83 -0
- package/cli/dist/clients/cli/paint.js +23 -0
- package/cli/dist/{cli.js → clients/cli/parser.js} +31 -25
- package/cli/dist/clients/cli/questions.js +88 -0
- package/cli/dist/{ui → clients/cli}/terminal.js +1 -13
- package/cli/dist/clients/ui/assets.js +36 -0
- package/cli/dist/clients/ui/opener.js +9 -0
- package/cli/dist/{brand.js → core/brand.js} +1 -1
- package/cli/dist/{commands → core/commands}/app-check.js +1 -1
- package/cli/dist/{commands → core/commands}/server.js +26 -17
- package/cli/dist/{commands → core/commands}/status.js +3 -3
- package/cli/dist/{commands → core/commands}/validate.js +1 -1
- package/cli/dist/{fleet.js → core/fleet.js} +1 -1
- package/cli/dist/core/interpret.js +276 -0
- package/cli/dist/{load.js → core/load.js} +1 -1
- package/cli/dist/core/operations/catalog.js +152 -0
- package/cli/dist/core/operations/run.js +139 -0
- package/cli/dist/{plan.js → core/plan.js} +11 -4
- package/cli/dist/core/present/line.js +17 -0
- package/cli/dist/{ui → core/present}/progress.js +2 -61
- package/cli/dist/{schemas.js → core/schemas.js} +1 -1
- package/cli/dist/core/updates.js +13 -0
- package/cli/dist/{validate.js → core/validate.js} +1 -1
- package/cli/dist/main.js +92 -93
- package/cli/dist/serve.js +77 -0
- package/package.json +4 -3
- package/scripts/agent/guard.sh +9 -2
- package/scripts/local/packed-runs.sh +43 -0
- package/scripts/local/setup-hosts.sh +9 -2
- package/cli/dist/commands/index.js +0 -52
- package/cli/dist/interpret.js +0 -141
- package/cli/dist/ui/line.js +0 -39
- package/cli/dist/web/assets/index-DRFX9Q77.js +0 -2
- /package/cli/dist/{commands → core/commands}/doctor.js +0 -0
- /package/cli/dist/{gather.js → core/gather.js} +0 -0
- /package/cli/dist/{net.js → core/net.js} +0 -0
- /package/cli/dist/{ui → core/present}/text.js +0 -0
- /package/cli/dist/{ui → core/present}/views.js +0 -0
- /package/cli/dist/{settings.js → core/settings.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { within } from "../brand.js";
|
|
2
2
|
import { capture } from "../interpret.js";
|
|
3
|
-
import { err, ok } from "
|
|
4
|
-
import { active, bad, link, muted, ok as fine, strong, warn } from "../
|
|
5
|
-
import { fit, table } from "../
|
|
3
|
+
import { err, ok } from "../../result.js";
|
|
4
|
+
import { active, bad, link, muted, ok as fine, strong, warn } from "../present/line.js";
|
|
5
|
+
import { fit, table } from "../present/text.js";
|
|
6
6
|
/** Why a connection failed, by Node's error code. */
|
|
7
7
|
export const failure = (code) => {
|
|
8
8
|
if (code === "ECONNREFUSED")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { appManifestSchema, secretsSchema, settings } from "../settings.js";
|
|
2
|
-
import { active, bad, muted, ok, strong } from "../
|
|
2
|
+
import { active, bad, muted, ok, strong } from "../present/line.js";
|
|
3
3
|
import { closest } from "../validate.js";
|
|
4
4
|
const finding = (result, text, hint) => ({ result, text, ...(hint === undefined ? {} : { hint }) });
|
|
5
5
|
const problem = (text, hint) => finding("problem", text, hint);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseDocument } from "yaml";
|
|
2
2
|
import { absolutePath, appName, domain, vaultPasswordFile, } from "./brand.js";
|
|
3
|
-
import { all, err, map, ok } from "
|
|
3
|
+
import { all, err, map, ok } from "../result.js";
|
|
4
4
|
import { serverKinds, serverSchema, varsSchema } from "./settings.js";
|
|
5
5
|
import { checkSettings, checkShape, knownSettings } from "./validate.js";
|
|
6
6
|
export { serverKinds };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { text } from "node:stream/consumers";
|
|
6
|
+
import { all, err, flatMap, ok } from "../result.js";
|
|
7
|
+
import { active, bad, muted, ok as fine, strong } from "./present/line.js";
|
|
8
|
+
import { position, silent } from "./present/progress.js";
|
|
9
|
+
import { draw } from "./present/views.js";
|
|
10
|
+
const terminal = {};
|
|
11
|
+
const isStopped = (signal) => signal?.aborted === true;
|
|
12
|
+
/** A program that ignores SIGINT this long gets SIGTERM. */
|
|
13
|
+
const patience = 10_000;
|
|
14
|
+
const spawned = async (argv, streams, env = {}, plumbing = terminal) => {
|
|
15
|
+
const [program, ...args] = argv;
|
|
16
|
+
const { output, signal } = plumbing;
|
|
17
|
+
if (isStopped(signal))
|
|
18
|
+
return { code: 130, stdout: "", stderr: "", started: false };
|
|
19
|
+
const shown = (stream) => stream === "show" ? (output === undefined ? "inherit" : "pipe") : stream === "capture" ? "pipe" : "ignore";
|
|
20
|
+
const stdin = streams.stdin ?? (output === undefined ? { kind: "inherit" } : { kind: "none" });
|
|
21
|
+
const child = spawn(program, args, {
|
|
22
|
+
env: { ...process.env, ...env },
|
|
23
|
+
detached: output !== undefined,
|
|
24
|
+
stdio: [stdin.kind === "inherit" ? "inherit" : stdin.kind === "none" ? "ignore" : "pipe", shown(streams.stdout), shown(streams.stderr)],
|
|
25
|
+
});
|
|
26
|
+
const forward = (from, sink) => {
|
|
27
|
+
child[from]?.setEncoding("utf8").on("data", (chunk) => {
|
|
28
|
+
sink(chunk, from);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
if (output !== undefined && streams.stdout === "show")
|
|
32
|
+
forward("stdout", output);
|
|
33
|
+
if (output !== undefined && streams.stderr === "show")
|
|
34
|
+
forward("stderr", output);
|
|
35
|
+
// A program that exits before reading all it was given must not take kayra down with EPIPE.
|
|
36
|
+
child.stdin?.on("error", () => undefined);
|
|
37
|
+
if (stdin.kind === "given")
|
|
38
|
+
child.stdin?.end(stdin.text);
|
|
39
|
+
const unsubscribe = stdin.kind === "typed"
|
|
40
|
+
? stdin.input((chunk) => {
|
|
41
|
+
child.stdin?.write(chunk);
|
|
42
|
+
})
|
|
43
|
+
: () => undefined;
|
|
44
|
+
const read = (from, stream) => {
|
|
45
|
+
const piped = child[from];
|
|
46
|
+
return piped === null || stream !== "capture" ? Promise.resolve("") : text(piped);
|
|
47
|
+
};
|
|
48
|
+
const stdout = read("stdout", streams.stdout);
|
|
49
|
+
const stderr = read("stderr", streams.stderr);
|
|
50
|
+
const kill = (withSignal) => {
|
|
51
|
+
if (child.pid === undefined)
|
|
52
|
+
return;
|
|
53
|
+
try {
|
|
54
|
+
if (output === undefined)
|
|
55
|
+
child.kill(withSignal);
|
|
56
|
+
else
|
|
57
|
+
process.kill(-child.pid, withSignal);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (!(error instanceof Error && "code" in error && error.code === "ESRCH"))
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// eslint-disable-next-line functional/prefer-immutable-types -- the escalation belongs to this child, cleared when it exits
|
|
65
|
+
const stopping = {};
|
|
66
|
+
const stop = () => {
|
|
67
|
+
if (stopping.timer !== undefined)
|
|
68
|
+
return;
|
|
69
|
+
if (stdin.kind === "typed")
|
|
70
|
+
child.stdin?.write("\u0003");
|
|
71
|
+
kill("SIGINT");
|
|
72
|
+
// eslint-disable-next-line functional/immutable-data -- see above
|
|
73
|
+
stopping.timer = setTimeout(() => { kill("SIGTERM"); }, patience);
|
|
74
|
+
stopping.timer.unref();
|
|
75
|
+
};
|
|
76
|
+
// The process group exists only once Node confirms the child has spawned.
|
|
77
|
+
child.once("spawn", () => {
|
|
78
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
79
|
+
if (isStopped(signal))
|
|
80
|
+
stop();
|
|
81
|
+
});
|
|
82
|
+
const exit = await new Promise((resolve) => {
|
|
83
|
+
child.on("error", resolve);
|
|
84
|
+
child.on("close", (code) => {
|
|
85
|
+
resolve(code ?? 1);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
signal?.removeEventListener("abort", stop);
|
|
89
|
+
clearTimeout(stopping.timer);
|
|
90
|
+
unsubscribe();
|
|
91
|
+
return exit instanceof Error
|
|
92
|
+
? { code: 127, stdout: "", stderr: exit.message, started: false }
|
|
93
|
+
: { code: exit, stdout: await stdout, stderr: await stderr, started: true };
|
|
94
|
+
};
|
|
95
|
+
/** A command's stdout, for kayra to read; its stderr reaches the operator unless captured too. */
|
|
96
|
+
export const capture = (argv, stderr = "show", env = {}, plumbing = terminal) => spawned(argv, { stdout: "capture", stderr }, env, plumbing);
|
|
97
|
+
const answer = (probe, plumbing) => spawned(probe.kind === "on-path" ? ["sh", "-c", 'command -v "$1"', "sh", probe.program] : probe.argv, { stdout: "discard", stderr: "capture", stdin: { kind: "none" } }, probe.kind === "exits-zero" ? probe.env : {}, plumbing);
|
|
98
|
+
/** Each query's answer in place of it, as `$(…)` would: one word, or split into many. */
|
|
99
|
+
const resolve = async (argv, plumbing) => {
|
|
100
|
+
const words = await Promise.all(argv.map(async (value) => {
|
|
101
|
+
if (typeof value === "string")
|
|
102
|
+
return ok([value]);
|
|
103
|
+
const exit = await capture(value.argv, "show", value.env, plumbing);
|
|
104
|
+
if (exit.code !== 0)
|
|
105
|
+
return err(`$(${value.argv.join(" ")}) failed: exit ${String(exit.code)}`);
|
|
106
|
+
const output = exit.stdout.replace(/\n+$/, "");
|
|
107
|
+
return ok(value.words === "one" ? [output] : output.split(/\s+/).filter((word) => word !== ""));
|
|
108
|
+
}));
|
|
109
|
+
return flatMap(all(words), (lists) => {
|
|
110
|
+
const [program, ...rest] = lists.flat();
|
|
111
|
+
return program === undefined ? err("the command is empty") : ok([program, ...rest]);
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const lines = (text) => text
|
|
115
|
+
.trimEnd()
|
|
116
|
+
.split("\n")
|
|
117
|
+
.filter((line) => line !== "");
|
|
118
|
+
/** Under the step's own line. */
|
|
119
|
+
const detail = (line) => [" ", line];
|
|
120
|
+
const aside = (line) => [" ", muted(line)];
|
|
121
|
+
const hint = (text) => (text === undefined ? [] : [[" ", active("→"), " ", text]]);
|
|
122
|
+
const goOn = { failed: false, stopped: false, out: [], err: [] };
|
|
123
|
+
const check = async (step, plumbing) => {
|
|
124
|
+
const exit = await answer(step.probe, plumbing);
|
|
125
|
+
const said = [...lines(exit.stderr).map(detail), ...hint(step.hint)];
|
|
126
|
+
if (step.onFailure === "stop")
|
|
127
|
+
return exit.code === 0 ? goOn : { failed: true, stopped: true, out: [], err: said };
|
|
128
|
+
return exit.code === 0
|
|
129
|
+
? { ...goOn, out: [[fine("✓"), " ", step.label]] }
|
|
130
|
+
: { failed: true, stopped: false, out: [[bad("✗"), " ", step.label], ...said], err: [] };
|
|
131
|
+
};
|
|
132
|
+
const keyOf = (need) => (need.kind === "vault" ? `vault:${need.server}` : "sudo");
|
|
133
|
+
const questionOf = (need) => need.kind === "vault"
|
|
134
|
+
? { kind: "secret", text: [" ", active("?"), " ", strong(`${need.server}'s vault password`), muted(" (asked once, kept for this run): ")] }
|
|
135
|
+
: { kind: "secret", text: [" ", active("?"), " ", strong("sudo's password"), muted(" (for this step only): ")] };
|
|
136
|
+
/** Whether sudo would run without a password: a cached one, or none needed. */
|
|
137
|
+
const sudoReady = async (plumbing) => (await spawned(["sudo", "-n", "true"], { stdout: "discard", stderr: "capture", stdin: { kind: "none" } }, {}, plumbing)).code === 0;
|
|
138
|
+
const scratch = () => {
|
|
139
|
+
// eslint-disable-next-line functional/prefer-immutable-types -- made on first need, removed when the run ends
|
|
140
|
+
const made = {};
|
|
141
|
+
const dir = () => {
|
|
142
|
+
// eslint-disable-next-line functional/immutable-data -- see above
|
|
143
|
+
made.dir ??= mkdtempSync(join(tmpdir(), "kayra-"));
|
|
144
|
+
return made.dir;
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
vaultScript: () => {
|
|
148
|
+
const script = join(dir(), "vault-password");
|
|
149
|
+
writeFileSync(script, '#!/bin/sh\nprintf \'%s\\n\' "$KAYRA_VAULT_PASSWORD"\n', { mode: 0o700 });
|
|
150
|
+
chmodSync(script, 0o700);
|
|
151
|
+
return script;
|
|
152
|
+
},
|
|
153
|
+
clean: () => {
|
|
154
|
+
if (made.dir !== undefined)
|
|
155
|
+
rmSync(made.dir, { recursive: true, force: true });
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/** Asks what a step needs and has not been given yet in this run; undefined if the operator gave nothing. */
|
|
160
|
+
const meet = async (needs, asked, io, made) => needs.reduce(async (previous, need) => {
|
|
161
|
+
const so = await previous;
|
|
162
|
+
if (so === undefined)
|
|
163
|
+
return undefined;
|
|
164
|
+
if (need.kind === "sudo" && (await sudoReady(io)))
|
|
165
|
+
return so;
|
|
166
|
+
const key = keyOf(need);
|
|
167
|
+
const given = so.asked[key] ?? (await ask(io, questionOf(need)));
|
|
168
|
+
if (given === "")
|
|
169
|
+
return undefined;
|
|
170
|
+
const now = need.kind === "vault" ? { ...so.asked, [key]: given } : so.asked;
|
|
171
|
+
return need.kind === "vault"
|
|
172
|
+
? { asked: now, met: { ...so.met, env: { ...so.met.env, ANSIBLE_VAULT_PASSWORD_FILE: made.vaultScript(), KAYRA_VAULT_PASSWORD: given } } }
|
|
173
|
+
: { asked: now, met: { env: { ...so.met.env, KAYRA_SUDO_STDIN: "1" }, stdin: { kind: "given", text: `${given}\n` } } };
|
|
174
|
+
}, Promise.resolve({ met: { env: {} }, asked }));
|
|
175
|
+
/** A step that talks with a person, given a pty: macOS's script, util-linux's elsewhere. */
|
|
176
|
+
const inPty = (argv, size) => {
|
|
177
|
+
const { columns, rows } = size ?? { columns: 120, rows: 32 };
|
|
178
|
+
const sized = ["sh", "-c", `stty rows ${String(rows)} cols ${String(columns)} 2>/dev/null; exec "$@"`, "sh", ...argv];
|
|
179
|
+
return process.platform === "darwin"
|
|
180
|
+
// BSD script accepts a pipe, but rejects Node's socket-backed stdin with ENOTSUP.
|
|
181
|
+
? ["bash", "-c", '"$@" < <(cat); code=$?; kill "$!" 2>/dev/null || :; exit "$code"', "bash", "script", "-q", "/dev/null", ...sized]
|
|
182
|
+
: ["script", "-q", "-e", "-c", sized.map((word) => `'${word.replaceAll("'", `'\\''`)}'`).join(" "), "/dev/null"];
|
|
183
|
+
};
|
|
184
|
+
const runStep = async (step, io, met) => {
|
|
185
|
+
const argv = await resolve(step.argv, io);
|
|
186
|
+
if (!argv.ok)
|
|
187
|
+
return { failed: true, stopped: true, why: "a query failed", out: [], err: [detail(argv.error)] };
|
|
188
|
+
const { stdout } = step;
|
|
189
|
+
const talks = step.kind === "session" && io.output !== undefined;
|
|
190
|
+
if (talks && io.input === undefined)
|
|
191
|
+
return { failed: true, stopped: true, why: "no terminal", out: [], err: [detail("it talks with a person, and this client gives it no keys")] };
|
|
192
|
+
// A quiet step's stderr waits until it is done, so it cannot tear through a spinner.
|
|
193
|
+
const quiet = stdout === "discard";
|
|
194
|
+
const exit = await spawned(talks ? inPty(argv.value, io.size) : argv.value, {
|
|
195
|
+
stdout: typeof stdout === "string" ? stdout : "capture",
|
|
196
|
+
stderr: quiet ? "capture" : "show",
|
|
197
|
+
...(talks && io.input !== undefined ? { stdin: { kind: "typed", input: io.input } } : met.stdin === undefined ? {} : { stdin: met.stdin }),
|
|
198
|
+
}, { ...step.env, ...met.env }, io);
|
|
199
|
+
if (!exit.started)
|
|
200
|
+
return { failed: true, stopped: true, why: "not started", out: [], err: [detail(`${argv.value[0]}: ${exit.stderr}`)] };
|
|
201
|
+
// Whatever it answered is shown, even when it failed: it may say why.
|
|
202
|
+
const out = typeof stdout === "string" ? [] : draw(stdout, exit.stdout, Date.now());
|
|
203
|
+
if (exit.code === 0)
|
|
204
|
+
return { ...goOn, out, err: lines(exit.stderr).map(aside) };
|
|
205
|
+
return { failed: true, stopped: true, why: `exit ${String(exit.code)}`, out, err: lines(exit.stderr).map(detail) };
|
|
206
|
+
};
|
|
207
|
+
const perform = async (step, io, met) => {
|
|
208
|
+
switch (step.kind) {
|
|
209
|
+
case "session":
|
|
210
|
+
case "run":
|
|
211
|
+
return runStep(step, io, met);
|
|
212
|
+
case "check":
|
|
213
|
+
return check(step, io);
|
|
214
|
+
case "confirm": {
|
|
215
|
+
io.err("");
|
|
216
|
+
io.err([" ", bad("▲"), " ", strong(step.warning)]);
|
|
217
|
+
const typed = await ask(io, { kind: "confirm", text: [" Type ", strong(step.expect), " to confirm: "], expect: step.expect });
|
|
218
|
+
return typed === step.expect ? goOn : { failed: false, stopped: true, out: ["Aborted."], err: [] };
|
|
219
|
+
}
|
|
220
|
+
case "note":
|
|
221
|
+
return { ...goOn, out: [step.text] };
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
/** Cancellation also ends a question; a late answer cannot restart the plan. */
|
|
225
|
+
const ask = async (io, question) => {
|
|
226
|
+
if (isStopped(io.signal))
|
|
227
|
+
return "";
|
|
228
|
+
return new Promise((resolve, reject) => {
|
|
229
|
+
const done = (answer) => {
|
|
230
|
+
io.signal?.removeEventListener("abort", stopped);
|
|
231
|
+
resolve(answer);
|
|
232
|
+
};
|
|
233
|
+
const stopped = () => { done(""); };
|
|
234
|
+
io.signal?.addEventListener("abort", stopped, { once: true });
|
|
235
|
+
void io.ask(question).then(done, (error) => {
|
|
236
|
+
io.signal?.removeEventListener("abort", stopped);
|
|
237
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Runs a plan step by step, until it ends or a step stops it, shown by `progress`.
|
|
243
|
+
* True if nothing failed and the operator did not interrupt it.
|
|
244
|
+
*/
|
|
245
|
+
export const interpret = async (plan, io, progress = silent, interrupted = () => false) => {
|
|
246
|
+
const made = scratch();
|
|
247
|
+
try {
|
|
248
|
+
const ended = await progress.plan(plan, () => plan.reduce(async (previous, step, index) => {
|
|
249
|
+
const so = await previous;
|
|
250
|
+
if (so.stop !== undefined)
|
|
251
|
+
return so;
|
|
252
|
+
if (interrupted() || isStopped(io.signal))
|
|
253
|
+
return { ...so, stop: { index, step, why: "interrupted" } };
|
|
254
|
+
// What a step needs is asked before its frame opens: a prompt, then the step.
|
|
255
|
+
const met = (step.kind === "run" || step.kind === "session") && step.needs !== undefined ? await meet(step.needs, so.asked, io, made) : { met: { env: {} }, asked: so.asked };
|
|
256
|
+
if (met === undefined) {
|
|
257
|
+
io.err([" ", muted("Nothing given: stopped before it ran.")]);
|
|
258
|
+
return { ...so, stop: { index, step, why: isStopped(io.signal) ? "interrupted" : "declined" } };
|
|
259
|
+
}
|
|
260
|
+
const done = await progress.step(step, position(plan, index), () => perform(step, io, met.met));
|
|
261
|
+
// Ctrl-C reached the step's program too: how it ended says nothing about the server.
|
|
262
|
+
if (interrupted() || isStopped(io.signal))
|
|
263
|
+
return { failures: so.failures, asked: met.asked, stop: { index, step, why: "interrupted" } };
|
|
264
|
+
done.out.forEach(io.out);
|
|
265
|
+
done.err.forEach(io.err);
|
|
266
|
+
const failures = so.failures + (done.failed ? 1 : 0);
|
|
267
|
+
if (done.stopped)
|
|
268
|
+
return { failures, asked: met.asked, stop: { index, step, why: done.failed ? "failed" : "declined" } };
|
|
269
|
+
return { failures, asked: met.asked };
|
|
270
|
+
}, Promise.resolve({ failures: 0, asked: {} })));
|
|
271
|
+
return ended.failures === 0 && ended.stop?.why !== "interrupted";
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
made.clean();
|
|
275
|
+
}
|
|
276
|
+
};
|
|
@@ -2,7 +2,7 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { fleetRoot, serverDir, serverName, within } from "./brand.js";
|
|
4
4
|
import { parseServer, yamlOf } from "./fleet.js";
|
|
5
|
-
import { all, err, flatMap, map, ok } from "
|
|
5
|
+
import { all, err, flatMap, map, ok } from "../result.js";
|
|
6
6
|
import { defaultsSchema } from "./settings.js";
|
|
7
7
|
import { checkSettings, knownSettings } from "./validate.js";
|
|
8
8
|
/** The fleet is the nearest directory, from `from` upwards, with a servers/defaults.yml. */
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const server = z.string().min(1).describe("A server of the fleet (servers/<name>/)");
|
|
3
|
+
const app = z.string().min(1).describe("An app name, including a removed app whose records or data remain");
|
|
4
|
+
const onServer = z.strictObject({ server });
|
|
5
|
+
const onApp = z.strictObject({ server, app });
|
|
6
|
+
export const operations = {
|
|
7
|
+
up: {
|
|
8
|
+
summary: "Provision, set up everything, point /etc/hosts at it.",
|
|
9
|
+
scope: "server",
|
|
10
|
+
effect: "changes",
|
|
11
|
+
kind: "plan",
|
|
12
|
+
input: onServer,
|
|
13
|
+
},
|
|
14
|
+
provision: {
|
|
15
|
+
summary: "Create or update the machine (target home: build the image to import).",
|
|
16
|
+
scope: "server",
|
|
17
|
+
effect: "changes",
|
|
18
|
+
kind: "plan",
|
|
19
|
+
input: onServer,
|
|
20
|
+
},
|
|
21
|
+
deploy: { summary: "Host setup and every app, no provisioning.", scope: "server", effect: "changes", kind: "plan", input: onServer },
|
|
22
|
+
setup: { summary: "The host layer only: the playbook for the server's kind.", scope: "server", effect: "changes", kind: "plan", input: onServer },
|
|
23
|
+
plan: {
|
|
24
|
+
summary: "What provision and setup would change, changing nothing (OpenTofu plan, Ansible check mode).",
|
|
25
|
+
scope: "server",
|
|
26
|
+
effect: "reads",
|
|
27
|
+
kind: "plan",
|
|
28
|
+
input: onServer,
|
|
29
|
+
},
|
|
30
|
+
verify: {
|
|
31
|
+
summary: "Whether a platform server works as its users see it: logins, certificates, webhooks, apps, runs, alerts.",
|
|
32
|
+
scope: "server",
|
|
33
|
+
effect: "reads",
|
|
34
|
+
kind: "plan",
|
|
35
|
+
input: onServer,
|
|
36
|
+
},
|
|
37
|
+
apps: {
|
|
38
|
+
summary: "Make the server's apps match server.yml: register each, remove the rest (data kept).",
|
|
39
|
+
scope: "server",
|
|
40
|
+
effect: "changes",
|
|
41
|
+
kind: "plan",
|
|
42
|
+
input: onServer,
|
|
43
|
+
},
|
|
44
|
+
hosts: { summary: "Point the domain at a multipass VM in /etc/hosts (sudo).", scope: "server", effect: "changes", kind: "plan", input: onServer },
|
|
45
|
+
ssh: { summary: "Open an interactive SSH session.", scope: "server", effect: "changes", kind: "session", bare: true, input: onServer },
|
|
46
|
+
"ssh.exec": {
|
|
47
|
+
summary: "Run a command over SSH.", scope: "server", effect: "changes", kind: "plan", bare: true,
|
|
48
|
+
input: z.strictObject({ server, command: z.array(z.string()).min(1).describe("The remote command and arguments") }),
|
|
49
|
+
},
|
|
50
|
+
down: { summary: "Destroy the machine.", scope: "server", effect: "destroys", kind: "plan", input: onServer },
|
|
51
|
+
adopt: {
|
|
52
|
+
summary: "Once, for a server we did not create: add the deploy user as root.",
|
|
53
|
+
scope: "server",
|
|
54
|
+
effect: "changes",
|
|
55
|
+
kind: "plan",
|
|
56
|
+
input: onServer,
|
|
57
|
+
},
|
|
58
|
+
"backup.test": {
|
|
59
|
+
summary: "Restore the latest backup to a scratch dir, check it, delete it.",
|
|
60
|
+
scope: "server",
|
|
61
|
+
effect: "changes",
|
|
62
|
+
kind: "plan",
|
|
63
|
+
input: onServer,
|
|
64
|
+
},
|
|
65
|
+
"app.check": {
|
|
66
|
+
summary: "What the platform checks at deploy (app.yml, images, compose policy), in an app's repository. No fleet needed.",
|
|
67
|
+
scope: "repo",
|
|
68
|
+
effect: "reads",
|
|
69
|
+
kind: "plan",
|
|
70
|
+
input: z.strictObject({ dir: z.string().min(1).default(".").describe("The app's repository") }),
|
|
71
|
+
},
|
|
72
|
+
"app.purge": { summary: "Delete a removed app's volumes: its data, irreversibly.", scope: "app", effect: "destroys", kind: "plan", input: onApp },
|
|
73
|
+
"app.runs": {
|
|
74
|
+
summary: "What runs now, and the app's latest runs: state, commit, why, when, how long.",
|
|
75
|
+
scope: "app",
|
|
76
|
+
effect: "reads",
|
|
77
|
+
kind: "query",
|
|
78
|
+
bare: true,
|
|
79
|
+
input: onApp,
|
|
80
|
+
},
|
|
81
|
+
"app.log": {
|
|
82
|
+
summary: "A run's log, the newest unless named; its errors and warnings marked.",
|
|
83
|
+
scope: "app",
|
|
84
|
+
effect: "reads",
|
|
85
|
+
kind: "query",
|
|
86
|
+
bare: true,
|
|
87
|
+
input: z.strictObject({ server, app, run: z.string().min(1).optional().describe("A run's id; the newest by default") }),
|
|
88
|
+
},
|
|
89
|
+
"app.deploy": {
|
|
90
|
+
summary: "Build and deploy a branch, tag or commit (default: the app's ref).",
|
|
91
|
+
scope: "app",
|
|
92
|
+
effect: "changes",
|
|
93
|
+
kind: "plan",
|
|
94
|
+
bare: true,
|
|
95
|
+
input: z.strictObject({ server, app, ref: z.string().min(1).optional().describe("A branch, tag or commit; the app's ref by default") }),
|
|
96
|
+
},
|
|
97
|
+
"app.releases": {
|
|
98
|
+
summary: "The app's releases: what runs now, and the earlier ones to roll back to.",
|
|
99
|
+
scope: "app",
|
|
100
|
+
effect: "reads",
|
|
101
|
+
kind: "query",
|
|
102
|
+
bare: true,
|
|
103
|
+
input: onApp,
|
|
104
|
+
},
|
|
105
|
+
"app.rollback": {
|
|
106
|
+
summary: "Deploy an earlier release again.",
|
|
107
|
+
scope: "app",
|
|
108
|
+
effect: "changes",
|
|
109
|
+
kind: "plan",
|
|
110
|
+
bare: true,
|
|
111
|
+
input: z.strictObject({ server, app, sha: z.string().regex(/^[0-9a-f]{7,40}$/).describe("An earlier release's commit") }),
|
|
112
|
+
},
|
|
113
|
+
job: {
|
|
114
|
+
summary: "Run a platform job now: the registry GC or Renovate.",
|
|
115
|
+
scope: "server",
|
|
116
|
+
effect: "changes",
|
|
117
|
+
kind: "plan",
|
|
118
|
+
bare: true,
|
|
119
|
+
input: z.strictObject({
|
|
120
|
+
server,
|
|
121
|
+
job: z.enum(["gc", "renovate"]),
|
|
122
|
+
noPrs: z.boolean().default(false).describe("Renovate: log what would change, open no PRs"),
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
status: {
|
|
126
|
+
summary: "Every server: where it is, whether SSH and its login answer.",
|
|
127
|
+
scope: "fleet",
|
|
128
|
+
effect: "reads",
|
|
129
|
+
kind: "stream",
|
|
130
|
+
input: z.strictObject({ offline: z.boolean().default(false).describe("Only what the fleet and OpenTofu's state say: reach no server") }),
|
|
131
|
+
},
|
|
132
|
+
validate: {
|
|
133
|
+
summary: "Check the fleet beyond its schemas: secrets, apps against their contract, stacks, routes.",
|
|
134
|
+
scope: "fleet",
|
|
135
|
+
effect: "reads",
|
|
136
|
+
kind: "query",
|
|
137
|
+
input: z.strictObject({ server: server.optional() }),
|
|
138
|
+
},
|
|
139
|
+
doctor: { summary: "Check that this Mac can run every command on every server.", scope: "fleet", effect: "reads", kind: "plan", input: z.strictObject({}) },
|
|
140
|
+
certs: {
|
|
141
|
+
summary: "mkcert certs for a domain and its subdomains (local dev, multipass).",
|
|
142
|
+
scope: "fleet",
|
|
143
|
+
effect: "changes",
|
|
144
|
+
kind: "plan",
|
|
145
|
+
input: z.strictObject({ domain: z.string().min(1), subdomains: z.array(z.string()).default([]) }),
|
|
146
|
+
},
|
|
147
|
+
version: { summary: "Which kayra this is.", scope: "fleet", effect: "reads", kind: "query", input: z.strictObject({}) },
|
|
148
|
+
};
|
|
149
|
+
export const operationNames = Object.keys(operations).filter((name) => Object.hasOwn(operations, name));
|
|
150
|
+
export const isOperation = (name) => Object.hasOwn(operations, name);
|
|
151
|
+
/** An operation as every client reads it, whatever its own entry spells out. */
|
|
152
|
+
export const operation = (name) => operations[name];
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { absolutePath, appName, domain, subdomain, within } from "../brand.js";
|
|
4
|
+
import { appCheck } from "../commands/app-check.js";
|
|
5
|
+
import { doctor } from "../commands/doctor.js";
|
|
6
|
+
import * as server from "../commands/server.js";
|
|
7
|
+
import { look } from "../commands/status.js";
|
|
8
|
+
import { findings } from "../commands/validate.js";
|
|
9
|
+
import { gather } from "../gather.js";
|
|
10
|
+
import { interpret } from "../interpret.js";
|
|
11
|
+
import { flat } from "../present/line.js";
|
|
12
|
+
import { all, err, flatMap, map, ok } from "../../result.js";
|
|
13
|
+
import { operations } from "./catalog.js";
|
|
14
|
+
/** Every operation with its input: what a client sends, parsed in one go. */
|
|
15
|
+
const invocations = z.discriminatedUnion("name", [
|
|
16
|
+
z.strictObject({ name: z.literal("up"), input: operations.up.input }),
|
|
17
|
+
z.strictObject({ name: z.literal("provision"), input: operations.provision.input }),
|
|
18
|
+
z.strictObject({ name: z.literal("deploy"), input: operations.deploy.input }),
|
|
19
|
+
z.strictObject({ name: z.literal("setup"), input: operations.setup.input }),
|
|
20
|
+
z.strictObject({ name: z.literal("plan"), input: operations.plan.input }),
|
|
21
|
+
z.strictObject({ name: z.literal("verify"), input: operations.verify.input }),
|
|
22
|
+
z.strictObject({ name: z.literal("apps"), input: operations.apps.input }),
|
|
23
|
+
z.strictObject({ name: z.literal("hosts"), input: operations.hosts.input }),
|
|
24
|
+
z.strictObject({ name: z.literal("ssh"), input: operations.ssh.input }),
|
|
25
|
+
z.strictObject({ name: z.literal("ssh.exec"), input: operations["ssh.exec"].input }),
|
|
26
|
+
z.strictObject({ name: z.literal("down"), input: operations.down.input }),
|
|
27
|
+
z.strictObject({ name: z.literal("adopt"), input: operations.adopt.input }),
|
|
28
|
+
z.strictObject({ name: z.literal("backup.test"), input: operations["backup.test"].input }),
|
|
29
|
+
z.strictObject({ name: z.literal("app.check"), input: operations["app.check"].input }),
|
|
30
|
+
z.strictObject({ name: z.literal("app.purge"), input: operations["app.purge"].input }),
|
|
31
|
+
z.strictObject({ name: z.literal("app.runs"), input: operations["app.runs"].input }),
|
|
32
|
+
z.strictObject({ name: z.literal("app.log"), input: operations["app.log"].input }),
|
|
33
|
+
z.strictObject({ name: z.literal("app.deploy"), input: operations["app.deploy"].input }),
|
|
34
|
+
z.strictObject({ name: z.literal("app.releases"), input: operations["app.releases"].input }),
|
|
35
|
+
z.strictObject({ name: z.literal("app.rollback"), input: operations["app.rollback"].input }),
|
|
36
|
+
z.strictObject({ name: z.literal("job"), input: operations.job.input }),
|
|
37
|
+
z.strictObject({ name: z.literal("status"), input: operations.status.input }),
|
|
38
|
+
z.strictObject({ name: z.literal("validate"), input: operations.validate.input }),
|
|
39
|
+
z.strictObject({ name: z.literal("doctor"), input: operations.doctor.input }),
|
|
40
|
+
z.strictObject({ name: z.literal("certs"), input: operations.certs.input }),
|
|
41
|
+
z.strictObject({ name: z.literal("version"), input: operations.version.input }),
|
|
42
|
+
]);
|
|
43
|
+
/** An operation and input from any client, checked against its schema: the one gate into the core. */
|
|
44
|
+
export const invocation = (name, input) => {
|
|
45
|
+
const parsed = invocations.safeParse({ name, input: input ?? {} });
|
|
46
|
+
if (parsed.success)
|
|
47
|
+
return ok(parsed.data);
|
|
48
|
+
const issue = parsed.error.issues[0];
|
|
49
|
+
const where = issue?.path.slice(1).join(".") ?? "";
|
|
50
|
+
return err(name in operations ? `${name}: ${where === "" ? "input" : where}: ${issue?.message ?? "invalid"}` : `no operation '${name}'`);
|
|
51
|
+
};
|
|
52
|
+
const onServer = (ctx, name) => {
|
|
53
|
+
const found = ctx.fleet.servers.find((each) => each.name === name);
|
|
54
|
+
return found === undefined ? err(`no server '${name}' in this fleet`) : ok(found);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A server and an app's name. The app need not be in server.yml: a removed
|
|
58
|
+
* app's runs, logs and volumes stay the deployer's to answer for and purge.
|
|
59
|
+
*/
|
|
60
|
+
const onApp = (ctx, input) => flatMap(onServer(ctx, input.server), (target) => map(appName(input.app), (app) => [target, app]));
|
|
61
|
+
const withServer = (make) => (ctx, input) => flatMap(onServer(ctx, input.server), (target) => make(ctx.engine, target));
|
|
62
|
+
const onDeployer = (command) => (ctx, input) => flatMap(onApp(ctx, input), ([target, app]) => server.deployer(target, command(app, input)));
|
|
63
|
+
const optional = (value) => (typeof value === "string" ? value : undefined);
|
|
64
|
+
/** Each plan operation, as the plan that does it: the compiler refuses one that has none. */
|
|
65
|
+
const plans = {
|
|
66
|
+
up: withServer(server.up),
|
|
67
|
+
provision: withServer(server.provision),
|
|
68
|
+
deploy: withServer(server.deploy),
|
|
69
|
+
setup: withServer(server.setup),
|
|
70
|
+
plan: withServer(server.preview),
|
|
71
|
+
verify: withServer(server.verify),
|
|
72
|
+
apps: withServer(server.apps),
|
|
73
|
+
hosts: withServer(server.hosts),
|
|
74
|
+
down: withServer(server.down),
|
|
75
|
+
adopt: withServer(server.adopt),
|
|
76
|
+
"backup.test": withServer(server.backupTest),
|
|
77
|
+
ssh: (ctx, input) => flatMap(onServer(ctx, input.server), (target) => server.ssh(target, [])),
|
|
78
|
+
"ssh.exec": (ctx, input) => flatMap(onServer(ctx, input.server), (target) => server.ssh(target, input.command)),
|
|
79
|
+
"app.check": (ctx, input) => flatMap(absolutePath(resolve(ctx.here, input.dir)), (dir) => appCheck(ctx.engine.kayra, dir, ctx.read(within(dir, "app.yml")))),
|
|
80
|
+
"app.purge": (ctx, input) => flatMap(onApp(ctx, input), ([target, app]) => server.appPurge(ctx.engine, target, app)),
|
|
81
|
+
"app.runs": onDeployer((app) => ({ kind: "runs", app, more: undefined })),
|
|
82
|
+
"app.log": onDeployer((app, input) => ({ kind: "logs", app, more: optional(input["run"]) })),
|
|
83
|
+
"app.deploy": onDeployer((app, input) => ({ kind: "deploy", app, more: optional(input["ref"]) })),
|
|
84
|
+
"app.releases": onDeployer((app) => ({ kind: "rollback", app, more: undefined })),
|
|
85
|
+
"app.rollback": onDeployer((app, input) => ({ kind: "rollback", app, more: optional(input["sha"]) })),
|
|
86
|
+
job: (ctx, input) => flatMap(onServer(ctx, input.server), (target) => server.deployer(target, { kind: "job", job: input.job, noPrs: input.noPrs })),
|
|
87
|
+
doctor: (ctx) => ok(doctor(ctx.fleet, ctx.engine.kayra)),
|
|
88
|
+
certs: (ctx, input) => flatMap(domain(input.domain), (named) => flatMap(all(input.subdomains.map(subdomain)), (subdomains) => server.certsFor(ctx.engine, named, subdomains))),
|
|
89
|
+
};
|
|
90
|
+
export const planOf = (ctx, call) => plans[call.name](ctx, call.input);
|
|
91
|
+
export const hasPlan = (call) => Object.hasOwn(plans, call.name);
|
|
92
|
+
const deployerAnswer = async (ctx, name, input) => {
|
|
93
|
+
const plan = planOf(ctx, { name, input });
|
|
94
|
+
if (!plan.ok)
|
|
95
|
+
return plan;
|
|
96
|
+
// eslint-disable-next-line functional/prefer-immutable-types -- the interpreter's captured streams
|
|
97
|
+
const said = { stdout: "", stderr: "" };
|
|
98
|
+
const passed = await interpret(plan.value.map((step) => step.kind === "run" ? { ...step, stdout: "show" } : step), {
|
|
99
|
+
out: () => undefined,
|
|
100
|
+
// eslint-disable-next-line functional/immutable-data -- capturing interpreter diagnostics
|
|
101
|
+
err: (text) => { said.stderr += flat(text); },
|
|
102
|
+
ask: () => Promise.resolve(""),
|
|
103
|
+
...(ctx.signal === undefined ? {} : { signal: ctx.signal }),
|
|
104
|
+
output: (chunk, stream) => {
|
|
105
|
+
// eslint-disable-next-line functional/immutable-data -- capturing program output
|
|
106
|
+
if (stream === "stdout")
|
|
107
|
+
said.stdout += chunk;
|
|
108
|
+
// eslint-disable-next-line functional/immutable-data -- capturing program errors
|
|
109
|
+
else
|
|
110
|
+
said.stderr += chunk;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
return passed ? ok(said.stdout) : err(said.stderr.trim() || "the deployer query failed");
|
|
114
|
+
};
|
|
115
|
+
const queries = {
|
|
116
|
+
"app.runs": (ctx, input) => deployerAnswer(ctx, "app.runs", input),
|
|
117
|
+
"app.releases": (ctx, input) => deployerAnswer(ctx, "app.releases", input),
|
|
118
|
+
"app.log": (ctx, input) => deployerAnswer(ctx, "app.log", input),
|
|
119
|
+
validate: async (ctx, input) => {
|
|
120
|
+
const chosen = input.server === undefined ? ok(ctx.fleet.servers) : map(onServer(ctx, input.server), (one) => [one]);
|
|
121
|
+
if (!chosen.ok)
|
|
122
|
+
return chosen;
|
|
123
|
+
return ok(await Promise.all(chosen.value.map(async (each) => ({ server: each, findings: findings(await gather(ctx.fleet.root, each)) }))));
|
|
124
|
+
},
|
|
125
|
+
version: (ctx) => Promise.resolve(ok(ctx.version)),
|
|
126
|
+
};
|
|
127
|
+
export const query = (ctx, name, input) => queries[name](ctx, input);
|
|
128
|
+
const streams = {
|
|
129
|
+
status: (ctx, input) => look(ctx.fleet, ctx.tofu, input.offline ? undefined : ctx.network),
|
|
130
|
+
};
|
|
131
|
+
/** A stream's first state and the updates still to land. */
|
|
132
|
+
export const stream = (ctx, name, input) => streams[name](ctx, input);
|
|
133
|
+
/** The server an invocation acts on, if one: what its heading names, what a real server's confirmation asks for. */
|
|
134
|
+
export const serverOf = (ctx, invocation) => {
|
|
135
|
+
const named = "server" in invocation.input ? invocation.input.server : undefined;
|
|
136
|
+
return typeof named === "string" ? ctx.fleet.servers.find((each) => each.name === named) : undefined;
|
|
137
|
+
};
|
|
138
|
+
export const isQuery = (call) => operations[call.name].kind === "query";
|
|
139
|
+
export const isStream = (call) => operations[call.name].kind === "stream";
|
|
@@ -24,6 +24,7 @@ export const kindOf = (step) => (step.kind === "check" ? (step.onFailure === "st
|
|
|
24
24
|
/** What it is called while it runs; a confirmation and a note say what they say. */
|
|
25
25
|
export const titleOf = (step) => {
|
|
26
26
|
switch (step.kind) {
|
|
27
|
+
case "session":
|
|
27
28
|
case "run":
|
|
28
29
|
return step.title;
|
|
29
30
|
case "check":
|
|
@@ -34,11 +35,16 @@ export const titleOf = (step) => {
|
|
|
34
35
|
return step.text;
|
|
35
36
|
}
|
|
36
37
|
};
|
|
38
|
+
/** What --dry-run says a step will ask for: kayra asks it when the step runs. */
|
|
39
|
+
const asks = (needs = []) => needs.length === 0
|
|
40
|
+
? ""
|
|
41
|
+
: ` # asks for ${needs.map((need) => (need.kind === "vault" ? `${need.server}'s vault password` : "sudo's password, unless cached")).join(" and ")}`;
|
|
37
42
|
/** The shell command a step runs, or undefined if it runs none. */
|
|
38
43
|
export const commandOf = (step) => {
|
|
39
44
|
switch (step.kind) {
|
|
45
|
+
case "session":
|
|
40
46
|
case "run":
|
|
41
|
-
return `${assignments(step.env)}${step.argv.map(arg).join(" ")}${step.stdout === "discard" ? " >/dev/null" : ""}`;
|
|
47
|
+
return `${assignments(step.env)}${step.argv.map(arg).join(" ")}${step.stdout === "discard" ? " >/dev/null" : ""}${asks(step.needs)}`;
|
|
42
48
|
case "check":
|
|
43
49
|
return describeProbe(step.probe);
|
|
44
50
|
case "confirm":
|
|
@@ -48,8 +54,9 @@ export const commandOf = (step) => {
|
|
|
48
54
|
};
|
|
49
55
|
const describe = (step) => {
|
|
50
56
|
switch (step.kind) {
|
|
57
|
+
case "session":
|
|
51
58
|
case "run":
|
|
52
|
-
return
|
|
59
|
+
return `${step.kind.padEnd(8)} ${commandOf(step) ?? ""}`;
|
|
53
60
|
case "check":
|
|
54
61
|
return `${kindOf(step).padEnd(8)} ${step.label}: ${commandOf(step) ?? ""}`;
|
|
55
62
|
case "confirm":
|
|
@@ -60,5 +67,5 @@ const describe = (step) => {
|
|
|
60
67
|
};
|
|
61
68
|
/** The plan as plain lines: --dry-run's output where it is read by a program. */
|
|
62
69
|
export const render = (plan) => plan.map(describe);
|
|
63
|
-
/** A plan with a step that
|
|
64
|
-
export const needsTerminal = (plan) => plan.some((step) => step.kind === "
|
|
70
|
+
/** A plan with a step that talks with a person: a client without a terminal gives it a pty and the person's keys. */
|
|
71
|
+
export const needsTerminal = (plan) => plan.some((step) => step.kind === "session");
|