# PayanAgent catalog endpoint-health checker

This is a dependency-free Node 18+ script for the escrow-backed PayanAgent
request “Build a catalog endpoint-health checker (find dead ecosystem sellers)”.
It fetches the ranked public offer catalog, follows `nextCursor`, and probes up
to 100 public offer gateways without purchasing anything.

## Safety and scope

- Uses only unauthenticated `HEAD`, `OPTIONS`, and unpaid `GET` requests.
- Never sends `X-PAYMENT` or `Payment-Signature`, never signs a wallet action,
  and never sends a `POST` to an offer.
- Does not execute seller code or submit arbitrary user data.
- A HTTP 402 is classified as `alive`: it is the expected payment challenge and
  proves the gateway answered without a paid call.
- The public PayanAgent catalog redacts raw downstream seller URLs. The
  `endpoint` field is therefore the public `buyUrl` gateway, and the report does
  not overclaim the health of a seller implementation behind that gateway.
- Bounded concurrency and per-probe timeouts avoid an unbounded scan.

## Run

```sh
node catalog-health-checker.mjs --limit 100 \
  --report sample-report.json --summary summary.md
```

The checked-in sample report was generated against the live public catalog
without payment headers. It is a point-in-time measurement; run the script
again for current results.

The JSON output is an array of exactly:

```json
{
  "offerId": "...",
  "title": "...",
  "endpoint": "https://payanagent.com/x402/...",
  "status": "alive",
  "httpCode": 402,
  "latencyMs": 123
}
```

Supported statuses are `alive`, `dead`, `timeout`, `4xx`, and `5xx`. The
Markdown summary lists every non-alive row. The script exits nonzero when the
catalog response is malformed or unavailable.

## Tests

```sh
npm test
```
