@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/README.md +57 -14
- package/dist/ci-report-command.d.ts +40 -0
- package/dist/ci-report-command.js +123 -0
- package/dist/dashboard/RunView.js +6 -5
- package/dist/dashboard/environment.d.ts +4 -1
- package/dist/dashboard/environment.js +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +320 -65
- package/dist/live.d.ts +68 -0
- package/dist/live.js +255 -0
- package/dist/output.d.ts +46 -0
- package/dist/output.js +115 -0
- package/dist/run-format.d.ts +7 -0
- package/dist/run-format.js +55 -0
- package/dist/run.d.ts +64 -0
- package/dist/run.js +443 -0
- package/dist/serve.d.ts +114 -0
- package/dist/serve.js +386 -0
- package/dist/service.d.ts +78 -0
- package/dist/service.js +392 -0
- package/dist/style.d.ts +107 -0
- package/dist/style.js +195 -0
- package/dist/wallet-command.d.ts +20 -4
- package/dist/wallet-command.js +160 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@ Protocol-compliance testing for **x402** and **MPP** on Stellar, from your termi
|
|
|
6
6
|
|
|
7
7
|
For both MPP charge payments and x402 payments it verifies the settlement independently — via Stellar RPC and the token contract's own on-chain transfer event, rather than the response the service returns.
|
|
8
8
|
|
|
9
|
-
**Testnet only.** Several checks settle real transactions
|
|
9
|
+
**Testnet only.** Several checks settle real transactions. The payment checks pay on test networks only: any other network, `stellar:pubnet` included, is refused before a key is read. Do not use production keys.
|
|
10
|
+
|
|
11
|
+
**This README describes 0.8.0-beta.1**, a pre-release on npm under the `beta` tag (`npm install -g @wasit-dev/cli@beta`). `latest` is still 0.7.0. New in the beta: `wasit run` for a whole service from a `wasit.config.json`, `wasit ci-report`, the GitHub Action, a seventeenth check (`X402-11`), and a cap on every payment Wasit signs.
|
|
10
12
|
|
|
11
13
|
## Install
|
|
12
14
|
|
|
@@ -22,7 +24,7 @@ wasit test --target <your-service-url> --read-only
|
|
|
22
24
|
Requires Node.js `>=22`.
|
|
23
25
|
|
|
24
26
|
Both lines carry `--read-only` deliberately: without it the payment checks
|
|
25
|
-
`X402-06
|
|
27
|
+
`X402-06`–`10` run as soon as a `STELLAR_PRIVATE_KEY` is available, and the CLI
|
|
26
28
|
reads `.env` from the directory you run it in — so on a machine already set up
|
|
27
29
|
for a later suite, the first command in this README would settle a real testnet
|
|
28
30
|
payment.
|
|
@@ -35,7 +37,7 @@ The default posture costs nothing — no keys required:
|
|
|
35
37
|
wasit test --target https://your-service.example.com/paid --read-only
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
That runs the read-only x402 checks (`X402-01`–`05`): whether the service issues a well-formed 402 challenge. Drop `--read-only` and set `STELLAR_PRIVATE_KEY` to also exercise the payment flow — `X402-06
|
|
40
|
+
That runs the read-only x402 checks (`X402-01`–`05`): whether the service issues a well-formed 402 challenge. Drop `--read-only` and set `STELLAR_PRIVATE_KEY` to also exercise the payment flow — `X402-06` settles a real testnet payment, and `X402-07`–`10` send payments the service must refuse.
|
|
39
41
|
|
|
40
42
|
## Commands
|
|
41
43
|
|
|
@@ -48,15 +50,15 @@ wasit test --target <url> [options]
|
|
|
48
50
|
| Option | Default | Notes |
|
|
49
51
|
|---|---|---|
|
|
50
52
|
| `--target <url>` | required | Must include the scheme |
|
|
51
|
-
| `--network <id>` | `stellar:testnet` |
|
|
52
|
-
| `--payer-key <key>` | `STELLAR_PRIVATE_KEY`
|
|
53
|
+
| `--network <id>` | `stellar:testnet` | Network the payment checks pay on: `stellar:testnet`, `eip155:84532` (Base Sepolia), `eip155:11155111` (Ethereum Sepolia) or `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` (Solana devnet). Any other network is refused before a key is read. `X402-01`–`05` apply on any chain |
|
|
54
|
+
| `--payer-key <key>` | `STELLAR_PRIVATE_KEY`, `EVM_PRIVATE_KEY` on Base or Ethereum Sepolia, or `SVM_PRIVATE_KEY` on Solana devnet | A Stellar secret (`S...`), an EVM private key (`0x` + 64 hex), or a Solana keypair (base58 of its 64 bytes) |
|
|
53
55
|
| `--rpc-url <url>` | testnet default | Soroban RPC used to verify `X402-06`'s settlement |
|
|
54
56
|
| `--method <verb>` | `GET` | HTTP method the paid endpoint uses |
|
|
55
57
|
| `--body <json>` | — | Request body; implies `Content-Type: application/json` |
|
|
56
58
|
| `--header <name:value>` | — | Extra request header, repeatable |
|
|
57
59
|
| `--read-only` | off | Restricts the run to `X402-01`–`05` (no payment) |
|
|
58
60
|
|
|
59
|
-
Without a payer key, the payment checks are skipped automatically. When they run: **`X402-06` settles a real payment, `X402-07` attempts one with a corrupted signature
|
|
61
|
+
Without a payer key, the payment checks are skipped automatically. When they run: **`X402-06` settles a real payment, `X402-07` attempts one with a corrupted signature**, so testnet funds move on every call. A price above $1.00 is not paid: `X402-06` gets no verdict (`ERROR (setup)`) and nothing is signed. `X402-11` needs a request the service must refuse, which only `wasit run` reads from the config, so `wasit test` skips it.
|
|
60
62
|
|
|
61
63
|
### `wasit mpp-charge` — MPP, charge mode
|
|
62
64
|
|
|
@@ -68,8 +70,8 @@ wasit mpp-charge --target <url> [options]
|
|
|
68
70
|
|---|---|---|
|
|
69
71
|
| `--target <url>` | required | The paid resource |
|
|
70
72
|
| `--payer-key <key>` | `MPP_PAYER_SECRET` | Secret key, `S...` |
|
|
71
|
-
| `--network <id>` | `MPP_STELLAR_NETWORK` | CAIP-2 |
|
|
72
|
-
| `--rpc-url <url>` | testnet default |
|
|
73
|
+
| `--network <id>` | `MPP_STELLAR_NETWORK` | CAIP-2. Only a challenge on this network is paid; `stellar:testnet` only, any other network is refused |
|
|
74
|
+
| `--rpc-url <url>` | testnet default | Used for the payment and the settlement read; https only |
|
|
73
75
|
|
|
74
76
|
**Every run settles a real payment.** Charge mode has no dry run — a settlement that never happened cannot be verified on-chain.
|
|
75
77
|
|
|
@@ -97,6 +99,28 @@ wasit mpp-channel --target <url> [options]
|
|
|
97
99
|
|
|
98
100
|
`--channel` **asserts**, it does not select: the channel under test is resolved from the target's own 402 challenge, so every check in a run reports on the same contract. When `--channel` differs from what the target advertises, `MPP-10` fails and inspects nothing.
|
|
99
101
|
|
|
102
|
+
### `wasit run`: a whole service from `wasit.config.json` (new in 0.8.0-beta.1)
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
wasit run --read-only --start # the free checks, X402-01 to 05, with the service started from the config
|
|
106
|
+
wasit run --dry-run --start # what the payment checks would sign; no key, nothing sent
|
|
107
|
+
wasit run --start # the payment tier, on a test network
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`wasit.config.json` (version 1) holds a service's endpoints, methods, request bodies and environments. The loader is strict: an unknown key is an error, and secrets, the mainnet opt-in and per-payment caps have no place in it. `wasit run` runs every endpoint (`--env`, `--endpoint`) and writes one report (`--json`, `--out`); it can start the service itself (`--start`, `--start-if-local`) and compare with the report of the default branch (`--baseline`).
|
|
111
|
+
|
|
112
|
+
Without `--read-only` or `--dry-run` the run is the payment tier. It pays on test networks only, when the environment has `operatedByMe: true` and the chain's key variable is set: at most $1.00 a payment and $5.00 a run (`maxRunUsd` can only lower it), only to the `payTo` and asset the config pins. In GitHub Actions it pays only on a push to the default branch, a schedule and `workflow_dispatch`; a pull request runs the read-only checks. In another CI the payment tier is refused with exit 2: use `--read-only` there. `--mainnet` is refused in this version. `wasit run --help` lists every option.
|
|
113
|
+
|
|
114
|
+
For an endpoint with a `reject` case in the config, on Stellar, the payment tier also runs `X402-11`: a valid payment is sent with the request the service must refuse, and the chain is read until that payment's authorization has expired, up to six minutes.
|
|
115
|
+
|
|
116
|
+
### `wasit ci-report`: the pull request comment and the job summary (new in 0.8.0-beta.1)
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
wasit ci-report --report wasit-report.json --comment comment.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Turns the report of `wasit run --json --out` into the pull request comment and the job summary, compared with the default branch's report (`--baseline`). `--check-run <file>` also writes the title, summary and conclusion of a GitHub check run. The GitHub Action in the repository's `action/` directory runs `wasit run` and `wasit ci-report` in a workflow and comments on the pull request; pin it by full commit SHA.
|
|
123
|
+
|
|
100
124
|
### `wasit checks` — the catalogue
|
|
101
125
|
|
|
102
126
|
```bash
|
|
@@ -108,17 +132,32 @@ Lists every check by ID with the subcommand that runs it, and flags the ones tha
|
|
|
108
132
|
### `wasit wallet` — testnet keys
|
|
109
133
|
|
|
110
134
|
```bash
|
|
111
|
-
wasit wallet status [--role x402|mpp-charge] [--json]
|
|
112
|
-
wasit wallet create --role x402|mpp-charge|mpp-channel [--fund]
|
|
113
|
-
wasit wallet fund --role x402|mpp-charge [--asset xlm|usdc] [--amount <n>]
|
|
135
|
+
wasit wallet status [--role x402|mpp-charge] [--network <testnet>] [--json]
|
|
136
|
+
wasit wallet create --role x402|mpp-charge|mpp-channel [--network <testnet>] [--fund]
|
|
137
|
+
wasit wallet fund --role x402|mpp-charge [--network <testnet>] [--asset xlm|usdc] [--amount <n>]
|
|
114
138
|
```
|
|
115
139
|
|
|
116
|
-
Testnet-only helpers for the keys the subcommands above read from `.env`.
|
|
140
|
+
Testnet-only helpers for the keys the subcommands above read from `.env`. `--network` takes testnets only: `stellar:testnet` (default), `eip155:84532`, `eip155:11155111` or `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`, where `create --role x402` prints an `EVM_PRIVATE_KEY` or `SVM_PRIVATE_KEY` line and the address to fund at [faucet.circle.com](https://faucet.circle.com); that payer needs USDC and no ETH or SOL. `create` prints the exact `.env` lines to paste and never writes the file itself; `fund --asset xlm` uses Stellar's public Friendbot and is fully automatic.
|
|
117
141
|
|
|
118
142
|
`fund --asset usdc` opens the Circle testnet USDC trustline automatically, but **receiving a balance always needs one human step**: there is no scriptable USDC faucet for Stellar. Visit [faucet.circle.com](https://faucet.circle.com) once, or set `WASIT_USDC_DISTRIBUTOR_SECRET` to an account you funded that way and every later run sends from it automatically.
|
|
119
143
|
|
|
120
144
|
`create` prints a secret key to stdout — don't run it on a screen you're recording.
|
|
121
145
|
|
|
146
|
+
### `wasit serve` — a paywall that misbehaves, for testing an agent that pays
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
wasit serve --mode no-settle # also: wrong-settlement, wrong-network, overprice,
|
|
150
|
+
# v1-challenge, malformed-header
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Runs a local x402 paywall that lies in one chosen way: serves without settling,
|
|
154
|
+
cites someone else's settlement, asks for mainnet, asks for one million USDC, issues
|
|
155
|
+
only an x402 v1 challenge, or sends a challenge header that does not decode.
|
|
156
|
+
Point your agent at `http://127.0.0.1:4020/` and the server reports what the
|
|
157
|
+
agent did. Nothing is settled or forwarded, so no funds move; the agent still
|
|
158
|
+
needs a funded testnet wallet, and `--pay-to` (default `STELLAR_PAYEE_ADDRESS`)
|
|
159
|
+
must be a testnet account with a USDC trustline. See `wasit serve --help`.
|
|
160
|
+
|
|
122
161
|
### The interactive dashboard
|
|
123
162
|
|
|
124
163
|
Running `wasit` with no arguments in a terminal opens a menu: the same three check runners, a catalogue browser, and a wallet screen, driven by arrow keys. A run shows a live elapsed timer and per-check progress, and `s` saves the finished run to `wasit-<protocol>-<timestamp>.json` — the same shape `--json` prints. Piped or in CI it prints help instead, so nothing that scripts Wasit today changes behaviour. See [`docs/guides/cli.md`](https://github.com/wasit-dev/wasit/blob/main/docs/guides/cli.md).
|
|
@@ -139,6 +178,8 @@ SKIP X402-02 Payment Header Present
|
|
|
139
178
|
7 passed.
|
|
140
179
|
```
|
|
141
180
|
|
|
181
|
+
At a terminal, `wasit test` shows the checks live and in colour, in two blocks (challenge and payment). A pipe, CI, `--json` and `NO_COLOR` get the plain text above.
|
|
182
|
+
|
|
142
183
|
`PREFLIGHT` appears in place of the checks when the target URL or network identifier itself is invalid — both are wrong for every check in the suite, so it's reported once rather than repeated identically.
|
|
143
184
|
|
|
144
185
|
## Exit codes
|
|
@@ -155,7 +196,9 @@ A run with both a failure and an error exits `1` — a real finding outranks a m
|
|
|
155
196
|
|
|
156
197
|
| Env var | Used by |
|
|
157
198
|
|---|---|
|
|
158
|
-
| `STELLAR_PRIVATE_KEY` | `test` (x402 payment checks) |
|
|
199
|
+
| `STELLAR_PRIVATE_KEY` | `test` (x402 payment checks on Stellar) |
|
|
200
|
+
| `EVM_PRIVATE_KEY` | `test --network eip155:84532` or `eip155:11155111` (x402 payment checks on Base or Ethereum Sepolia) |
|
|
201
|
+
| `SVM_PRIVATE_KEY` | `test --network solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` (x402 payment checks on Solana devnet) |
|
|
159
202
|
| `MPP_PAYER_SECRET` | `mpp-charge` |
|
|
160
203
|
| `MPP_STELLAR_NETWORK` | `mpp-charge`, `mpp-channel` |
|
|
161
204
|
| `COMMITMENT_SECRET_HEX` | `mpp-channel` |
|
|
@@ -167,7 +210,7 @@ All keys are **testnet only**. `wasit` also reads a `.env` file in the current w
|
|
|
167
210
|
|
|
168
211
|
## What's checked
|
|
169
212
|
|
|
170
|
-
|
|
213
|
+
Seventeen checks across x402 and MPP (`X402-11` is new in 0.8.0-beta.1), each traced to a written spec clause — the full catalogue, with pass criteria and spec references, is in [`docs/CHECKS.md`](https://github.com/wasit-dev/wasit/blob/main/docs/CHECKS.md).
|
|
171
214
|
|
|
172
215
|
## Related
|
|
173
216
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wasit ci-report`: the run report (and the baseline of the default branch, if
|
|
3
|
+
* there is one) in; `comment.md`, the job summary and, when asked, the next
|
|
4
|
+
* baseline out (spec A4, A5).
|
|
5
|
+
*
|
|
6
|
+
* It is a pure function over files. It decides nothing about the job: the job's
|
|
7
|
+
* result is the exit code of `wasit run`. When the run left no usable report (the
|
|
8
|
+
* service never started, never answered, or the config was unusable) it still
|
|
9
|
+
* writes a fixed "no verdict" comment and summary, so the comment of the push
|
|
10
|
+
* before does not stay next to a red check, and it writes no baseline. It exits 2
|
|
11
|
+
* when the report is there but unusable, or when it cannot write what it was asked.
|
|
12
|
+
*/
|
|
13
|
+
export interface CiReportOptions {
|
|
14
|
+
/** The `wasit run --json --out` file. */
|
|
15
|
+
readonly report: string;
|
|
16
|
+
/** The baseline file of the default branch: absent or unusable, the comment says so. */
|
|
17
|
+
readonly baseline?: string;
|
|
18
|
+
/** Where the pull request comment goes. */
|
|
19
|
+
readonly comment: string;
|
|
20
|
+
/** The job summary file, appended to. Default: `$GITHUB_STEP_SUMMARY`, if set. */
|
|
21
|
+
readonly summary?: string;
|
|
22
|
+
/** Where the next baseline goes: the report with its history. The caller uploads it on a run on the default branch. */
|
|
23
|
+
readonly baselineOut?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The baseline file of the newest completed run on the default branch, failed
|
|
26
|
+
* or not (D-022b): its history is the one the recent-failures line counts and
|
|
27
|
+
* the next baseline carries on. Absent or unusable: the baseline's own.
|
|
28
|
+
*/
|
|
29
|
+
readonly history?: string;
|
|
30
|
+
/** The id of the run the baseline came from, named in the comment. Only a whole number above 0 is used. */
|
|
31
|
+
readonly baselineRun?: string;
|
|
32
|
+
/** Where the check run's title, summary and conclusion go, as JSON, for the step that completes it. */
|
|
33
|
+
readonly checkRun?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CiReportContext {
|
|
36
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
37
|
+
readonly stdout: (line: string) => void;
|
|
38
|
+
readonly stderr: (line: string) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare function executeCiReport(options: CiReportOptions, context: CiReportContext): Promise<number>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wasit ci-report`: the run report (and the baseline of the default branch, if
|
|
3
|
+
* there is one) in; `comment.md`, the job summary and, when asked, the next
|
|
4
|
+
* baseline out (spec A4, A5).
|
|
5
|
+
*
|
|
6
|
+
* It is a pure function over files. It decides nothing about the job: the job's
|
|
7
|
+
* result is the exit code of `wasit run`. When the run left no usable report (the
|
|
8
|
+
* service never started, never answered, or the config was unusable) it still
|
|
9
|
+
* writes a fixed "no verdict" comment and summary, so the comment of the push
|
|
10
|
+
* before does not stay next to a red check, and it writes no baseline. It exits 2
|
|
11
|
+
* when the report is there but unusable, or when it cannot write what it was asked.
|
|
12
|
+
*/
|
|
13
|
+
import { appendFileSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { MAX_BASELINE_BYTES, ReportFormatError, baselineProblem, deniedEnvValues, parseRunReport, readBaseline, readBuildCommit, readToolVersions, renderCheckRun, renderComment, renderNoReportCheckRun, renderNoReportComment, renderNoReportSummary, renderSummary, sanitizeText, selectBaseline, serializeBaseline, updateHistory, } from "@wasit-dev/core";
|
|
15
|
+
import { CLI_VERSION } from "./version.js";
|
|
16
|
+
function readFileText(path, max) {
|
|
17
|
+
if (statSync(path).size > max)
|
|
18
|
+
throw Object.assign(new Error("too large"), { code: "E2BIG" });
|
|
19
|
+
return readFileSync(path, "utf-8");
|
|
20
|
+
}
|
|
21
|
+
function readBaselineFile(path) {
|
|
22
|
+
try {
|
|
23
|
+
return readBaseline(readFileText(path, MAX_BASELINE_BYTES));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const code = error.code;
|
|
27
|
+
return { ok: false, reason: `the baseline file cannot be read${typeof code === "string" ? ` (${code})` : ""}` };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function executeCiReport(options, context) {
|
|
31
|
+
const secrets = deniedEnvValues(context.env);
|
|
32
|
+
const fail = (message) => {
|
|
33
|
+
context.stderr(sanitizeText(message, { redact: secrets }));
|
|
34
|
+
return 2;
|
|
35
|
+
};
|
|
36
|
+
/** The run left nothing to render: say so in the comment and the summary, and write no baseline. */
|
|
37
|
+
const writeNoReport = (message, code) => {
|
|
38
|
+
context.stderr(sanitizeText(message, { redact: secrets }));
|
|
39
|
+
try {
|
|
40
|
+
const versions = readToolVersions(CLI_VERSION, readBuildCommit(context.env));
|
|
41
|
+
writeFileSync(options.comment, renderNoReportComment(versions));
|
|
42
|
+
context.stdout(`Wrote ${options.comment}`);
|
|
43
|
+
const summary = options.summary ?? context.env["GITHUB_STEP_SUMMARY"];
|
|
44
|
+
if (summary !== undefined && summary !== "") {
|
|
45
|
+
appendFileSync(summary, renderNoReportSummary(versions));
|
|
46
|
+
context.stdout(`Appended the summary to ${summary}`);
|
|
47
|
+
}
|
|
48
|
+
if (options.checkRun !== undefined) {
|
|
49
|
+
writeFileSync(options.checkRun, JSON.stringify(renderNoReportCheckRun(versions)));
|
|
50
|
+
context.stdout(`Wrote ${options.checkRun}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const errno = error.code;
|
|
55
|
+
return fail(`wasit ci-report: cannot write a file${typeof errno === "string" ? ` (${errno})` : ""}`);
|
|
56
|
+
}
|
|
57
|
+
return code;
|
|
58
|
+
};
|
|
59
|
+
let report;
|
|
60
|
+
try {
|
|
61
|
+
report = parseRunReport(JSON.parse(readFileText(options.report, MAX_BASELINE_BYTES)));
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Nothing from the file is quoted: it is data, and it may be broken or hostile.
|
|
65
|
+
if (error instanceof ReportFormatError)
|
|
66
|
+
return writeNoReport("wasit ci-report: the report is not a Wasit report", 2);
|
|
67
|
+
if (error instanceof SyntaxError)
|
|
68
|
+
return writeNoReport("wasit ci-report: the report is not valid JSON", 2);
|
|
69
|
+
const code = error.code;
|
|
70
|
+
if (code === "ENOENT") {
|
|
71
|
+
return writeNoReport("wasit ci-report: wasit run wrote no report, so the comment says no verdict (the reason is in the log of the run step)", 0);
|
|
72
|
+
}
|
|
73
|
+
return writeNoReport(`wasit ci-report: cannot read the report${typeof code === "string" ? ` (${code})` : ""}`, 2);
|
|
74
|
+
}
|
|
75
|
+
const selected = selectBaseline(report, options.baseline === undefined ? undefined : readBaselineFile(options.baseline));
|
|
76
|
+
// D-022b: the history of every completed run on main, when the newest one is given.
|
|
77
|
+
let history = selected.baseline?.history;
|
|
78
|
+
let historyGiven = false;
|
|
79
|
+
if (options.history !== undefined) {
|
|
80
|
+
const read = readBaselineFile(options.history);
|
|
81
|
+
const problem = read.ok ? baselineProblem(report, read.baseline.report) : read.reason;
|
|
82
|
+
if (read.ok && problem === undefined) {
|
|
83
|
+
history = read.baseline.history;
|
|
84
|
+
historyGiven = true;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
context.stderr(sanitizeText(`wasit ci-report: the history file is not used (${problem ?? "unknown"}); the history of the baseline is used`, {
|
|
88
|
+
redact: secrets,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const run = options.baselineRun !== undefined && /^[1-9][0-9]{0,15}$/.test(options.baselineRun) ? Number(options.baselineRun) : undefined;
|
|
93
|
+
const input = {
|
|
94
|
+
report,
|
|
95
|
+
...(selected.baseline === undefined ? {} : { baseline: selected.baseline }),
|
|
96
|
+
...(selected.note === undefined ? {} : { baselineNote: selected.note }),
|
|
97
|
+
...(run === undefined || !Number.isSafeInteger(run) ? {} : { baselineRun: run }),
|
|
98
|
+
...(historyGiven && history !== undefined ? { history } : {}),
|
|
99
|
+
secrets,
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
writeFileSync(options.comment, renderComment(input));
|
|
103
|
+
context.stdout(`Wrote ${options.comment}`);
|
|
104
|
+
const summary = options.summary ?? context.env["GITHUB_STEP_SUMMARY"];
|
|
105
|
+
if (summary !== undefined && summary !== "") {
|
|
106
|
+
appendFileSync(summary, `${renderSummary(input)}\n`);
|
|
107
|
+
context.stdout(`Appended the summary to ${summary}`);
|
|
108
|
+
}
|
|
109
|
+
if (options.baselineOut !== undefined) {
|
|
110
|
+
writeFileSync(options.baselineOut, serializeBaseline(report, updateHistory(history, report)));
|
|
111
|
+
context.stdout(`Wrote ${options.baselineOut}`);
|
|
112
|
+
}
|
|
113
|
+
if (options.checkRun !== undefined) {
|
|
114
|
+
writeFileSync(options.checkRun, JSON.stringify(renderCheckRun(input)));
|
|
115
|
+
context.stdout(`Wrote ${options.checkRun}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
const code = error.code;
|
|
120
|
+
return fail(`wasit ci-report: cannot write a file${typeof code === "string" ? ` (${code})` : ""}`);
|
|
121
|
+
}
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { writeFile } from "node:fs/promises";
|
|
4
4
|
import { Box, Text, useApp, useInput } from "ink";
|
|
5
|
-
import { CHECK_CATALOGUE, checkStatus, summarize, toStructuredRun, } from "@wasit-dev/core";
|
|
5
|
+
import { CHECK_CATALOGUE, checkStatus, summarize, toStructuredRun, X402_PAYMENT_CHECK_IDS, } from "@wasit-dev/core";
|
|
6
6
|
import { runAction } from "./runners.js";
|
|
7
7
|
import { THEME } from "./theme.js";
|
|
8
8
|
import { formatDuration } from "./format.js";
|
|
@@ -38,10 +38,11 @@ function colorFor(status) {
|
|
|
38
38
|
return THEME.muted;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
//
|
|
42
|
-
// read-only x402 action — listing them as "pending" would leave
|
|
43
|
-
// spinning forever after the run has already finished.
|
|
44
|
-
|
|
41
|
+
// The payment checks need a payer key and are never touched by the
|
|
42
|
+
// read-only x402 action — listing them as "pending" would leave their rows
|
|
43
|
+
// spinning forever after the run has already finished. Core owns the list,
|
|
44
|
+
// so a new payment check cannot be missed here.
|
|
45
|
+
const READ_ONLY_EXCLUDED_IDS = new Set(X402_PAYMENT_CHECK_IDS);
|
|
45
46
|
export function RunView({ protocol, action, target, onBack }) {
|
|
46
47
|
const { exit } = useApp();
|
|
47
48
|
const initialEntries = useMemo(() => {
|
|
@@ -9,6 +9,9 @@ export interface EnvironmentCheck {
|
|
|
9
9
|
*
|
|
10
10
|
* All three payer roles are listed, including x402's: the wallet screen can
|
|
11
11
|
* create and fund a key for every one of them, and showing only two of the
|
|
12
|
-
* three made the third look like it was not a role the tool knew about.
|
|
12
|
+
* three made the third look like it was not a role the tool knew about. The
|
|
13
|
+
* x402 payer keys for Base Sepolia and Solana devnet are listed too: `wasit
|
|
14
|
+
* test --network` pays with them, and `wasit wallet create --network` makes
|
|
15
|
+
* them.
|
|
13
16
|
*/
|
|
14
17
|
export declare function getEnvironmentStatus(): readonly EnvironmentCheck[];
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* All three payer roles are listed, including x402's: the wallet screen can
|
|
7
7
|
* create and fund a key for every one of them, and showing only two of the
|
|
8
|
-
* three made the third look like it was not a role the tool knew about.
|
|
8
|
+
* three made the third look like it was not a role the tool knew about. The
|
|
9
|
+
* x402 payer keys for Base Sepolia and Solana devnet are listed too: `wasit
|
|
10
|
+
* test --network` pays with them, and `wasit wallet create --network` makes
|
|
11
|
+
* them.
|
|
9
12
|
*/
|
|
10
13
|
export function getEnvironmentStatus() {
|
|
11
14
|
return [
|
|
@@ -13,6 +16,14 @@ export function getEnvironmentStatus() {
|
|
|
13
16
|
label: "STELLAR_PRIVATE_KEY (x402 payment)",
|
|
14
17
|
ready: Boolean(process.env.STELLAR_PRIVATE_KEY),
|
|
15
18
|
},
|
|
19
|
+
{
|
|
20
|
+
label: "EVM_PRIVATE_KEY (x402 payment, Base Sepolia)",
|
|
21
|
+
ready: Boolean(process.env.EVM_PRIVATE_KEY),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "SVM_PRIVATE_KEY (x402 payment, Solana devnet)",
|
|
25
|
+
ready: Boolean(process.env.SVM_PRIVATE_KEY),
|
|
26
|
+
},
|
|
16
27
|
{
|
|
17
28
|
label: "MPP_PAYER_SECRET (MPP charge)",
|
|
18
29
|
ready: Boolean(process.env.MPP_PAYER_SECRET),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
export {};
|