@wasit-dev/cli 0.6.0 → 0.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/live.js ADDED
@@ -0,0 +1,255 @@
1
+ /**
2
+ * The coloured, live text output of a check run (Najmi, 2026-11-19), in
3
+ * Wasit's own look: a header, the checks in two blocks (challenge, payment),
4
+ * one line per check with its mark (✓ pass, ✗ fail, ○ skip, ! error) and its
5
+ * duration flush right, a spinner line saying what the check in flight is doing,
6
+ * and the verdict, the counts and the run's duration at the end.
7
+ *
8
+ * It only arranges what the plain output says: the same checks, details, fixes
9
+ * and notes, in the same order. It is used only when colour is on
10
+ * (`colorEnabled`); `live` adds the spinner line, rewritten in place, on a real
11
+ * terminal. That line is cut to the terminal's width so it never wraps: a
12
+ * wrapped line cannot be rewritten in place. Every text passes through `clean`
13
+ * (the sanitiser, with the secrets redacted) before it is styled.
14
+ */
15
+ import { checkStatus, fixFor, summarize } from "@wasit-dev/core";
16
+ import { MARKS, SPINNER_FRAMES, SPINNER_MS, duration, lineWidth, spread, styler, truncate, visibleLength, wrap, } from "./style.js";
17
+ /** What a check does while it runs, for its spinner line. */
18
+ const DOING = {
19
+ "X402-01..05": "reading the challenge, no payment",
20
+ "X402-06": "paying once, then reading the transfer on chain",
21
+ "X402-07": "sending a payment with a corrupted signature",
22
+ "X402-08": "sending the same payment again",
23
+ "X402-09": "sending a validly signed payment for half the price",
24
+ "X402-10": "waiting for an authorization to expire, then sending it",
25
+ "X402-11": "sending a payment with the request the service must refuse",
26
+ };
27
+ /** The indent of a check's detail lines, under its ID. */
28
+ const DETAIL = " ";
29
+ /** The indent of the lines after the first of a fix. */
30
+ const FIX = " ";
31
+ const STATUS_ROLE = { PASS: "dim", FAIL: "danger", SKIP: "warning", ERROR: "error" };
32
+ /**
33
+ * The lines of one check: its line (mark, ID, name, duration, badge), then its
34
+ * detail, its fix and its docs. `withDetail` false leaves the detail out: a
35
+ * skip whose reason the skip just above it already gave.
36
+ */
37
+ export function resultLines(result, style, width, clean, ms, withDetail = true) {
38
+ const status = checkStatus(result);
39
+ const marks = MARKS[status];
40
+ const flag = result.destructive ? style.paint(" [destructive]", "warning") : "";
41
+ const left = ` ${style.paint(marks.mark, "bold", marks.markRole)} ${style.paint(clean(result.id), "bold")} ${clean(result.name)}${flag}`;
42
+ const time = ms === undefined ? "" : style.paint(duration(ms), "muted");
43
+ const right = [time, style.badge(marks.badge, marks.badgeRole)].filter((part) => part !== "").join(" ");
44
+ const lines = [spread(left, right, width)];
45
+ if (withDetail) {
46
+ for (const line of wrap(clean(result.detail), width, DETAIL))
47
+ lines.push(style.paint(line, STATUS_ROLE[status] ?? "dim"));
48
+ }
49
+ const guidance = fixFor(result);
50
+ if (guidance !== undefined) {
51
+ const fix = wrap(clean(guidance.fix), width, FIX);
52
+ fix[0] = `${DETAIL}${style.paint("fix", "bold")} ${fix[0]?.trimStart() ?? ""}`;
53
+ lines.push(...fix);
54
+ if (guidance.docs !== undefined)
55
+ lines.push(`${DETAIL}${style.paint(`docs ${clean(guidance.docs)}`, "muted")}`);
56
+ }
57
+ return lines;
58
+ }
59
+ /** "10 passed", "1 failed", "1 could not run", "1 skipped": each count in its colour. */
60
+ export function countsParts(results, style) {
61
+ const counts = summarize([...results]);
62
+ const parts = [style.paint(`${counts.passed} passed`, "bold", "success")];
63
+ if (counts.failed > 0)
64
+ parts.push(style.paint(`${counts.failed} failed`, "bold", "danger"));
65
+ if (counts.errored > 0)
66
+ parts.push(style.paint(`${counts.errored} could not run`, "bold", "error"));
67
+ if (counts.skipped > 0)
68
+ parts.push(style.paint(`${counts.skipped} skipped`, "bold", "warning"));
69
+ return parts;
70
+ }
71
+ /** "10 passed · 1 failed · 1 could not run · 1 skipped". */
72
+ export function countsLine(results, style) {
73
+ return countsParts(results, style).join(style.paint(" · ", "muted"));
74
+ }
75
+ /** Parts joined by " · " into lines of at most `width` columns, each after `indent`. */
76
+ function packParts(parts, width, indent, style) {
77
+ const separator = style.paint(" · ", "muted");
78
+ const lines = [];
79
+ let current = "";
80
+ for (const part of parts) {
81
+ const next = current === "" ? `${indent}${part}` : `${current}${separator}${part}`;
82
+ if (current !== "" && visibleLength(next) > width) {
83
+ lines.push(current);
84
+ current = `${indent}${part}`;
85
+ }
86
+ else {
87
+ current = next;
88
+ }
89
+ }
90
+ if (current !== "")
91
+ lines.push(current);
92
+ return lines;
93
+ }
94
+ const VERDICT = {
95
+ conformant: { text: "CONFORMANT", role: "success" },
96
+ "non-conformant": { text: "NOT CONFORMANT", role: "danger" },
97
+ "no-verdict": { text: "NO VERDICT", role: "error" },
98
+ unsupported: { text: "UNSUPPORTED", role: "warning" },
99
+ };
100
+ export class LiveReport {
101
+ #stream;
102
+ #live;
103
+ #clean;
104
+ #now;
105
+ #tickMs;
106
+ #style;
107
+ #startedAt;
108
+ #running;
109
+ #drawn = false;
110
+ #timer;
111
+ /** The reason of the skip printed just before, so the next skip with the same reason does not repeat it. */
112
+ #lastSkip;
113
+ constructor(options) {
114
+ this.#stream = options.stream;
115
+ this.#live = options.live;
116
+ this.#clean = options.clean;
117
+ this.#now = options.now ?? Date.now;
118
+ this.#tickMs = options.tickMs ?? SPINNER_MS;
119
+ this.#style = styler(true, options.depth ?? (options.truecolor === true ? 24 : 16));
120
+ this.#startedAt = this.#now();
121
+ }
122
+ get #width() {
123
+ return lineWidth(this.#stream);
124
+ }
125
+ #line(text = "") {
126
+ this.#stream.write(`${text}\n`);
127
+ }
128
+ /** Clears the spinner line from the screen, if one is drawn. */
129
+ #clearRunning() {
130
+ if (this.#drawn)
131
+ this.#stream.write("\r\u001b[2K");
132
+ this.#drawn = false;
133
+ }
134
+ /** The spinner line: the frame, the ID, what the check is doing, the time so far; never wider than the terminal. */
135
+ #drawRunning() {
136
+ const running = this.#running;
137
+ if (!this.#live || running === undefined)
138
+ return;
139
+ const elapsed = this.#now() - running.startedAt;
140
+ const frame = SPINNER_FRAMES[Math.floor(elapsed / SPINNER_MS) % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];
141
+ const id = this.#clean(running.id);
142
+ const time = duration(elapsed);
143
+ const max = this.#width;
144
+ const fixed = 3 + 2 + [...id].length + 2 + 2 + [...time].length;
145
+ const doing = truncate(this.#clean(DOING[running.id] ?? running.name), Math.max(1, max - fixed));
146
+ const left = ` ${this.#style.paint(frame, "accent")} ${this.#style.paint(id, "bold")} ${this.#style.paint(doing, "muted")}`;
147
+ let line = spread(left, this.#style.paint(time, "muted"), max);
148
+ if (visibleLength(line) > max)
149
+ line = left;
150
+ this.#stream.write(`\r\u001b[2K${line}`);
151
+ this.#drawn = true;
152
+ }
153
+ #stopTimer() {
154
+ if (this.#timer !== undefined)
155
+ clearInterval(this.#timer);
156
+ this.#timer = undefined;
157
+ }
158
+ /** ` ◆ wasit <version> · x402 conformance`, then `label value` rows. */
159
+ header(version, subject, rows = []) {
160
+ const s = this.#style;
161
+ this.#line(` ${s.paint("◆", "accent")} ${s.paint("wasit", "bold")} ${s.paint(`${this.#clean(version)} · ${this.#clean(subject)}`, "muted")}`);
162
+ const pad = Math.max(0, ...rows.map(([label]) => label.length));
163
+ for (const [label, value] of rows)
164
+ this.#line(` ${s.paint(label.padEnd(pad), "muted")} ${this.#clean(value)}`);
165
+ this.#line();
166
+ }
167
+ /** A block heading: ` payment · stellar:testnet · testnet funds move`. */
168
+ phase(name, parts = []) {
169
+ this.#clearRunning();
170
+ const s = this.#style;
171
+ const rest = parts.map(([text, role]) => `${s.paint("·", "muted")} ${s.paint(this.#clean(text), role ?? "muted")}`).join(" ");
172
+ this.#line(` ${s.paint(this.#clean(name), "bold", "accent")}${rest === "" ? "" : ` ${rest}`}`);
173
+ this.#drawRunning();
174
+ }
175
+ /** A note under a block: why checks were left out, or that money moves. */
176
+ note(text) {
177
+ this.#clearRunning();
178
+ for (const line of wrap(this.#clean(text), this.#width, " "))
179
+ this.#line(this.#style.paint(line, "warning"));
180
+ this.#drawRunning();
181
+ }
182
+ /** A check (or a group of checks) starts: its spinner line, on a real terminal. */
183
+ running(id, name) {
184
+ this.#clearRunning();
185
+ this.#stopTimer();
186
+ this.#running = { id, name, startedAt: this.#now() };
187
+ this.#drawRunning();
188
+ if (this.#live) {
189
+ this.#timer = setInterval(() => this.#drawRunning(), this.#tickMs);
190
+ this.#timer.unref?.();
191
+ }
192
+ }
193
+ /** A progress line from the check in flight, dimmed, above its spinner line. */
194
+ progress(text) {
195
+ this.#clearRunning();
196
+ for (const line of wrap(`↳ ${this.#clean(text)}`, this.#width, DETAIL))
197
+ this.#line(this.#style.paint(line, "dim"));
198
+ this.#drawRunning();
199
+ }
200
+ /**
201
+ * A check's result replaces its spinner line and carries the time since it
202
+ * started. Results computed together with an earlier one (the challenge
203
+ * checks, or the checks skipped after a failed payment) carry none, and a
204
+ * skipped check never does.
205
+ */
206
+ result(result) {
207
+ let ms;
208
+ if (this.#running !== undefined) {
209
+ ms = this.#now() - this.#running.startedAt;
210
+ this.#clearRunning();
211
+ this.#stopTimer();
212
+ this.#running = undefined;
213
+ }
214
+ const skip = checkStatus(result) === "SKIP";
215
+ if (skip)
216
+ ms = undefined;
217
+ const repeated = skip && this.#lastSkip === result.detail;
218
+ this.#lastSkip = skip ? result.detail : undefined;
219
+ for (const line of resultLines(result, this.#style, this.#width, this.#clean, ms, !repeated))
220
+ this.#line(line);
221
+ }
222
+ /** A blank line between blocks. */
223
+ gap() {
224
+ this.#clearRunning();
225
+ this.#line();
226
+ this.#drawRunning();
227
+ }
228
+ /** The verdict, the counts, the run's duration, and the plain output's closing notes. */
229
+ finish(results, outcome, notes) {
230
+ this.#clearRunning();
231
+ this.#stopTimer();
232
+ this.#running = undefined;
233
+ const s = this.#style;
234
+ const verdict = outcome === undefined ? "" : `${s.badge(VERDICT[outcome].text, VERDICT[outcome].role)} `;
235
+ this.#line();
236
+ const parts = [...countsParts(results, s), s.paint(duration(this.#now() - this.#startedAt), "bold")];
237
+ const oneLine = ` ${verdict}${parts.join(s.paint(" · ", "muted"))}`;
238
+ if (visibleLength(oneLine) <= this.#width) {
239
+ this.#line(oneLine);
240
+ }
241
+ else {
242
+ if (verdict !== "")
243
+ this.#line(` ${verdict.trimEnd()}`);
244
+ for (const line of packParts(parts, this.#width, " ", s))
245
+ this.#line(line);
246
+ }
247
+ for (const note of notes) {
248
+ this.#line();
249
+ const lines = wrap(this.#clean(note), this.#width, " ");
250
+ lines[0] = ` ${s.paint("note", "bold", "warning")} ${lines[0]?.trimStart() ?? ""}`;
251
+ for (const line of lines)
252
+ this.#line(line);
253
+ }
254
+ }
255
+ }
@@ -0,0 +1,46 @@
1
+ import { type CheckResult, type ProtocolId } from "@wasit-dev/core";
2
+ import { type Styler } from "./style.js";
3
+ /**
4
+ * Prints an advisory/status line meant for a human watching the terminal,
5
+ * never part of the run's actual result. Routed to stderr when --json is
6
+ * set, so stdout stays parseable JSON and a script piping it (jq, etc.)
7
+ * never has to skip past prose first.
8
+ */
9
+ export declare function note(json: boolean, message: string): void;
10
+ export interface ReportOptions {
11
+ /**
12
+ * The protocol of the one endpoint these results belong to. Given, the exit
13
+ * code follows the rule for a graded endpoint (spec A8 #3, D-021): a service
14
+ * that was never graded exits 2. Left out, the exit code is the counts' (the
15
+ * MPP commands keep today's).
16
+ */
17
+ readonly protocol?: ProtocolId;
18
+ /** Where lines go. Default `console.log`. */
19
+ readonly emit?: (line: string) => void;
20
+ /** Values no output may carry. Default: the keys and header values in the environment. */
21
+ readonly secrets?: readonly string[];
22
+ /** Colours for a person at a terminal (`colorEnabled`). Absent or off: the plain text, unchanged. */
23
+ readonly style?: Styler;
24
+ /** The width coloured lines are laid out to. Default 80. */
25
+ readonly width?: number;
26
+ }
27
+ /** The exit code of a run, by the same rule `report` uses. */
28
+ export declare function exitCodeFor(results: CheckResult[], protocol?: ProtocolId): number;
29
+ /** The notes that close a run's text output, when it has no verdict. */
30
+ export declare function verdictNotes(results: CheckResult[], protocol?: ProtocolId): string[];
31
+ /**
32
+ * Prints results and returns the process exit code.
33
+ *
34
+ * A skipped check carries `pass: false` so it can never be counted as
35
+ * conformance, but it is not a failure and must not fail the run. An errored
36
+ * check produced no verdict at all and is reported separately again.
37
+ *
38
+ * Everything printed passes through the sanitiser: a detail can quote what a
39
+ * service answered, and a terminal or a CI log reads control characters and a
40
+ * leading `::` as commands (spec A8 #6).
41
+ *
42
+ * `--json` reuses `toStructuredRun()` from core, the same reshape the MCP
43
+ * server calls for its own structured output, rather than defining a
44
+ * second JSON shape here that could drift from it.
45
+ */
46
+ export declare function report(results: CheckResult[], json: boolean, options?: ReportOptions): number;
package/dist/output.js ADDED
@@ -0,0 +1,115 @@
1
+ import { checkStatus, deniedEnvValues, exitCodeForEndpoint, fixFor, redactValue, sanitizeText, summarize, toGradedRun, toStructuredRun, endpointOutcome, paymentGroupUnsupported, } from "@wasit-dev/core";
2
+ import { countsLine, resultLines } from "./live.js";
3
+ import { lineWidth } from "./style.js";
4
+ /**
5
+ * Prints an advisory/status line meant for a human watching the terminal,
6
+ * never part of the run's actual result. Routed to stderr when --json is
7
+ * set, so stdout stays parseable JSON and a script piping it (jq, etc.)
8
+ * never has to skip past prose first.
9
+ */
10
+ export function note(json, message) {
11
+ if (json) {
12
+ console.error(message);
13
+ }
14
+ else {
15
+ console.log(message);
16
+ }
17
+ }
18
+ /** The exit code of a run, by the same rule `report` uses. */
19
+ export function exitCodeFor(results, protocol) {
20
+ return protocol === undefined ? summarize(results).exitCode : exitCodeForEndpoint(results, protocol);
21
+ }
22
+ /** The notes that close a run's text output, when it has no verdict. */
23
+ export function verdictNotes(results, protocol) {
24
+ const counts = summarize(results);
25
+ const exitCode = exitCodeFor(results, protocol);
26
+ if (counts.errored > 0 && counts.failed === 0) {
27
+ return [
28
+ "No verdict: some checks never reached the target or the run is " +
29
+ "misconfigured. This is not a statement about the target's conformance.",
30
+ ];
31
+ }
32
+ if (protocol !== undefined && exitCode === 2 && paymentGroupUnsupported(results, protocol)) {
33
+ return [
34
+ "No verdict: the payment checks were asked for and Wasit cannot pay on this network " +
35
+ "(unsupported; the skipped checks say why), so nothing was signed. This is not a failure " +
36
+ "of the service, and not a pass.",
37
+ ];
38
+ }
39
+ if (protocol !== undefined && exitCode === 2 && endpointOutcome(results, protocol) === "unsupported") {
40
+ return [
41
+ "No verdict: Wasit could not grade this service (unsupported; the skipped checks say why). " +
42
+ "This is not a failure of the service, and not a pass.",
43
+ ];
44
+ }
45
+ return [];
46
+ }
47
+ /**
48
+ * Prints results and returns the process exit code.
49
+ *
50
+ * A skipped check carries `pass: false` so it can never be counted as
51
+ * conformance, but it is not a failure and must not fail the run. An errored
52
+ * check produced no verdict at all and is reported separately again.
53
+ *
54
+ * Everything printed passes through the sanitiser: a detail can quote what a
55
+ * service answered, and a terminal or a CI log reads control characters and a
56
+ * leading `::` as commands (spec A8 #6).
57
+ *
58
+ * `--json` reuses `toStructuredRun()` from core, the same reshape the MCP
59
+ * server calls for its own structured output, rather than defining a
60
+ * second JSON shape here that could drift from it.
61
+ */
62
+ export function report(results, json, options = {}) {
63
+ const emit = options.emit ?? ((line) => console.log(line));
64
+ const secrets = options.secrets ?? deniedEnvValues(process.env);
65
+ const clean = (text) => sanitizeText(text, { redact: secrets });
66
+ const counts = summarize(results);
67
+ const exitCode = exitCodeFor(results, options.protocol);
68
+ if (json) {
69
+ const run = options.protocol === undefined ? toStructuredRun(results) : toGradedRun(results, options.protocol);
70
+ emit(JSON.stringify(redactValue(run, secrets), null, 2));
71
+ return exitCode;
72
+ }
73
+ // Coloured, for a person at a terminal: the same checks, details, fixes and
74
+ // notes, laid out like a test runner.
75
+ const style = options.style;
76
+ if (style !== undefined && style.enabled) {
77
+ const width = options.width ?? lineWidth({});
78
+ let lastSkip;
79
+ for (const result of results) {
80
+ const skip = checkStatus(result) === "SKIP";
81
+ const repeated = skip && lastSkip === result.detail;
82
+ lastSkip = skip ? result.detail : undefined;
83
+ for (const line of resultLines(result, style, width, clean, undefined, !repeated))
84
+ emit(line);
85
+ }
86
+ emit("");
87
+ emit(` ${countsLine(results, style)}`);
88
+ for (const message of verdictNotes(results, options.protocol))
89
+ emit(`\n ${style.paint("note", "bold", "warning")} ${clean(message)}`);
90
+ return exitCode;
91
+ }
92
+ for (const result of results) {
93
+ const flag = result.destructive ? " [destructive]" : "";
94
+ emit(clean(`${checkStatus(result)} ${result.id} ${result.name}${flag}`));
95
+ emit(clean(` ${result.detail}`));
96
+ const guidance = fixFor(result);
97
+ if (guidance !== undefined) {
98
+ emit(clean(` Fix: ${guidance.fix}`));
99
+ if (guidance.docs !== undefined)
100
+ emit(clean(` Docs: ${guidance.docs}`));
101
+ }
102
+ emit("");
103
+ }
104
+ const line = [`${counts.passed} passed`];
105
+ if (counts.failed > 0)
106
+ line.push(`${counts.failed} failed`);
107
+ if (counts.errored > 0)
108
+ line.push(`${counts.errored} could not run`);
109
+ if (counts.skipped > 0)
110
+ line.push(`${counts.skipped} skipped`);
111
+ emit(`${line.join(", ")}.`);
112
+ for (const message of verdictNotes(results, options.protocol))
113
+ emit(`\n${message}`);
114
+ return exitCode;
115
+ }
@@ -0,0 +1,7 @@
1
+ import { type ResolvedRun, type RunReport, type RunVerdict } from "@wasit-dev/core";
2
+ /**
3
+ * The text `wasit run` prints without `--json`: the run, then each endpoint with
4
+ * its checks, then the summary line and the exit reason. Lines only; the caller
5
+ * passes them through the sanitiser (they hold text a service sent).
6
+ */
7
+ export declare function formatRun(resolved: ResolvedRun, report: RunReport, verdict: RunVerdict): string[];
@@ -0,0 +1,55 @@
1
+ import { describeRun, describeTotals, } from "@wasit-dev/core";
2
+ /** Consecutive skipped checks with the same reason are one block: five payment checks, one reason. */
3
+ function blocks(endpoint) {
4
+ const out = [];
5
+ for (const result of endpoint.results) {
6
+ const last = out[out.length - 1];
7
+ if (last !== undefined &&
8
+ result.status === "SKIP" &&
9
+ last.first.status === "SKIP" &&
10
+ last.first.detail === result.detail &&
11
+ last.first.skipKind === result.skipKind) {
12
+ last.ids.push(result.id);
13
+ }
14
+ else {
15
+ out.push({ ids: [result.id], first: result });
16
+ }
17
+ }
18
+ return out;
19
+ }
20
+ /**
21
+ * The text `wasit run` prints without `--json`: the run, then each endpoint with
22
+ * its checks, then the summary line and the exit reason. Lines only; the caller
23
+ * passes them through the sanitiser (they hold text a service sent).
24
+ */
25
+ export function formatRun(resolved, report, verdict) {
26
+ // The first note is the tier: what the run paid, or why it did not.
27
+ const tier = report.notes[0];
28
+ const lines = [describeRun(resolved), ...(tier === undefined ? [] : [tier]), ""];
29
+ for (const endpoint of report.endpoints) {
30
+ lines.push(`${endpoint.name} ${endpoint.protocol} ${endpoint.method} ${endpoint.path}: ${endpoint.outcome}`);
31
+ if (endpoint.reason !== undefined)
32
+ lines.push(` Not graded: ${endpoint.reason}`);
33
+ for (const { ids, first } of blocks(endpoint)) {
34
+ lines.push(` ${first.status} ${ids.join(", ")}${ids.length === 1 ? ` ${first.name}` : ""}`);
35
+ lines.push(` ${first.detail}`);
36
+ if (first.expected !== undefined)
37
+ lines.push(` Expected: ${first.expected}`);
38
+ if (first.actual !== undefined)
39
+ lines.push(` Actual: ${first.actual}`);
40
+ if (first.fix !== undefined)
41
+ lines.push(` Fix: ${first.fix}`);
42
+ if (first.docs !== undefined)
43
+ lines.push(` Docs: ${first.docs}`);
44
+ }
45
+ lines.push("");
46
+ }
47
+ lines.push(`Summary: ${describeTotals(report.totals)}.`);
48
+ for (const note of report.notes.slice(1))
49
+ lines.push(`Note: ${note}`);
50
+ lines.push(`Result: ${verdict.reason} (exit ${verdict.code}).`);
51
+ if (verdict.code === 2) {
52
+ lines.push("No verdict is neither a pass nor a failure of the service: see the endpoints that were not graded.");
53
+ }
54
+ return lines;
55
+ }
package/dist/run.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * `wasit run`: the endpoints of a `wasit.config.json`, one after another, with
3
+ * one report (spec A2, A8).
4
+ *
5
+ * Three tiers. `--read-only`: an x402 endpoint gets its unpaid challenge checks
6
+ * (X402-01..05); its payment checks, and every MPP check, are reported as
7
+ * skipped for the tier, so the report says which checks need a payer.
8
+ * `--dry-run` (spec B5): L0 and L1 only, the plan of the payment checks
9
+ * printed; no key, no payment, no signature. Neither flag: the payment tier.
10
+ *
11
+ * The payment tier pays only when every one of these holds (D-022a, B3, A1):
12
+ * the GitHub event may pay (push to the default branch, schedule,
13
+ * workflow_dispatch on it; outside GitHub Actions always), the network is a
14
+ * test network (L0; the mainnet opt-in is not part of this version), the
15
+ * environment has `operatedByMe: true`, the chain's key variable is set, and
16
+ * the plan (L1) fits the caps. Then one budget is shared by every endpoint, each
17
+ * endpoint's checks get its entry of the plan, and the pin and `maxRunUsd` come
18
+ * from the config; L2 and L3 hold every signature in core. On a pull request the
19
+ * run is the read-only tier and says so. A key variable that is set on a run that
20
+ * may not pay is refused before the service starts (Najmi, 2026-11-16).
21
+ *
22
+ * `--mainnet` asks for the mainnet opt-in, which this version does not have:
23
+ * the run is refused at once, exit 2, before the config is read (spec B12).
24
+ *
25
+ * `executeRun` does not call `process.exit` and does not read the process: the
26
+ * environment and the output are passed in, so it can be tested in-process.
27
+ */
28
+ export interface RunCommandOptions {
29
+ readonly config: string;
30
+ readonly env?: string;
31
+ readonly endpoint?: readonly string[];
32
+ readonly readOnly: boolean;
33
+ /** L0 and L1 only: print the plan of the payment checks and exit. No key, no payment, no signature. */
34
+ readonly dryRun?: boolean;
35
+ readonly json: boolean;
36
+ readonly out?: string;
37
+ readonly start: boolean;
38
+ /**
39
+ * Start `service.start` only when it is set and the selected environment is on
40
+ * this machine; otherwise read the configured baseUrl as it is. What the Action
41
+ * passes, so a deployed endpoint (even on mainnet) is read without a service.
42
+ */
43
+ readonly startIfLocal?: boolean;
44
+ readonly baseline?: string;
45
+ /**
46
+ * `--mainnet`: the switch of the mainnet opt-in (spec B5). This version has no
47
+ * opt-in, so it always refuses, exit 2, before anything else is done (B12).
48
+ * Never read from the config or the environment.
49
+ */
50
+ readonly mainnet?: boolean;
51
+ }
52
+ export interface RunContext {
53
+ /** The environment of the run: the header variables, the RPC url, and what `--start` derives the service's from. */
54
+ readonly env: Readonly<Record<string, string | undefined>>;
55
+ /** One line at a time, the line break added by the caller. */
56
+ readonly stdout: (line: string) => void;
57
+ readonly stderr: (line: string) => void;
58
+ readonly now?: () => Date;
59
+ /** Where `service.start` runs. Default: the working directory. */
60
+ readonly cwd?: string;
61
+ /** Tests only: the sudo `--start` uses for a separate service user. Index never sets it; no flag or variable reaches it. */
62
+ readonly sudo?: string;
63
+ }
64
+ export declare function executeRun(options: RunCommandOptions, context: RunContext): Promise<number>;