callx402 1.0.0 → 1.0.2
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/.github/npm-publish.yml.staged +27 -0
- package/.github/workflows/npm-publish.yml +29 -0
- package/README.md +164 -11
- package/bin/callx402.js +296 -13
- package/core/index.js +35 -6
- package/core/rail.js +233 -0
- package/core/veyline.js +240 -0
- package/docs/README.md +11 -9
- package/docs/action-reference.md +2 -2
- package/docs/cli-help-verified-2026-10-06.txt +36 -0
- package/docs/problem-map.md +30 -15
- package/docs/troubleshooting/cx402-duppay-001-duplicate-payment-risk.md +135 -0
- package/docs/troubleshooting/cx402-paidnores-001-paid-no-result.md +3 -1
- package/docs/troubleshooting/cx402-safretry-001-retry-after-payment.md +13 -1
- package/docs/what-is-callx402.md +5 -4
- package/logo-400.png +0 -0
- package/mcp/README.md +5 -0
- package/mcp/index.js +1 -1
- package/mcp-publisher +0 -0
- package/package.json +9 -18
- package/server.json +23 -1
- package/test/cli-dispatch.test.js +38 -19
- package/test/helpers.js +20 -0
- package/test/integrity.test.js +2 -1
- package/test/intent-pipeline.test.js +2 -3
- package/test/remote.test.js +2 -3
- package/test/safety.test.js +4 -5
- package/test/sdk.test.js +3 -4
- package/test/server.test.js +4 -5
- package/test/subsystems.test.js +7 -8
- package/test/veyline-commands.test.js +193 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Publish to npm (Trusted Publishing)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: '20'
|
|
21
|
+
registry-url: 'https://registry.npmjs.org'
|
|
22
|
+
|
|
23
|
+
- run: npm install
|
|
24
|
+
- run: npm test
|
|
25
|
+
|
|
26
|
+
- name: Publish to npm via Trusted Publishing (OIDC, no token)
|
|
27
|
+
run: npm publish --provenance --access public
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish to npm (Trusted Publishing)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- run: npm install -g npm@latest
|
|
19
|
+
- uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: '20'
|
|
22
|
+
registry-url: 'https://registry.npmjs.org'
|
|
23
|
+
|
|
24
|
+
- run: npm install
|
|
25
|
+
- run: npm test
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
- name: Publish to npm via Trusted Publishing (OIDC, no token)
|
|
29
|
+
run: npm publish --provenance --access public
|
package/README.md
CHANGED
|
@@ -15,13 +15,31 @@ callx402 is the universal action layer into Veyline's x402 infrastructure. Say w
|
|
|
15
15
|
|
|
16
16
|
**Why it exists:** x402 failures are expensive and opaque. A settlement attempt ends in `settlement_pending` and nobody knows whether the money moved. A 402 response your wallet misreads. A retry that signs a second authorization for the same intent and pays twice. callx402 exists for exactly those moments: `diagnose` pins the failure to a stage, `rescue` triages the incident, `resolve` settles the question from evidence, `route` finds the cheapest viable path, `execute` runs under a hard budget.
|
|
17
17
|
|
|
18
|
-
**Try it (
|
|
18
|
+
**Try it (two minutes, no setup, no account):**
|
|
19
19
|
```sh
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
callx402
|
|
20
|
+
npm install -g callx402
|
|
21
|
+
callx402 status
|
|
22
|
+
callx402 'complete this job for under $1'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`status` prints an honest per-subsystem reachability report, no credentials
|
|
26
|
+
needed. The intent line parses and plans your request, then stops before
|
|
27
|
+
executing anything: with no live tool endpoint wired it reports "no
|
|
28
|
+
executable route available", so no money moves. (Use single quotes: in
|
|
29
|
+
double quotes your shell would eat the `$1`.)
|
|
30
|
+
|
|
31
|
+
Free read-only checks against the live Payload rail:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
curl https://payload-rail.fly.dev/v1/callx402/actions
|
|
35
|
+
curl 'https://payload-rail.fly.dev/v1/callx402/quote?action=diagnose'
|
|
23
36
|
```
|
|
24
37
|
|
|
38
|
+
The first returns the paid action catalog with prices; the second returns a
|
|
39
|
+
free price quote for one action. Invoking a rail action is paid per action
|
|
40
|
+
via checkout (see https://payloadhq.github.io/agents.json); these commands
|
|
41
|
+
never pay anything.
|
|
42
|
+
|
|
25
43
|
If it saves you one debugging session, star the repo and read on.
|
|
26
44
|
|
|
27
45
|
## MCP server: connect in 60 seconds
|
|
@@ -59,6 +77,11 @@ Ask the client to list its MCP tools: the six `x402_*` tools should appear.
|
|
|
59
77
|
Per-client notes and the raw stdio test handshake:
|
|
60
78
|
[`integrations/mcp-clients/`](integrations/mcp-clients/).
|
|
61
79
|
|
|
80
|
+
Note: `x402_status` works with zero setup. The other five tools dispatch
|
|
81
|
+
into the v2.0.0 subsystem tree, so they report `subsystem_unreachable`
|
|
82
|
+
until `CALLX402_V2_ROOT` points at the tree (see "Full subsystem commands"
|
|
83
|
+
above) and the matching flag is enabled.
|
|
84
|
+
|
|
62
85
|
## The relationship
|
|
63
86
|
|
|
64
87
|
- **PAYLOAD** = the parent company.
|
|
@@ -88,15 +111,22 @@ Behavioral usage language (not trademark claims):
|
|
|
88
111
|
|
|
89
112
|
## Quickstart
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
### 1. Install
|
|
92
115
|
|
|
93
116
|
```sh
|
|
94
|
-
npm install
|
|
117
|
+
npm install -g callx402
|
|
95
118
|
```
|
|
96
119
|
|
|
97
|
-
|
|
120
|
+
Or locally in a project: `npm install callx402` (the binary is then at
|
|
121
|
+
`node_modules/.bin/callx402`).
|
|
122
|
+
|
|
123
|
+
Fallback, install direct from GitHub:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
npm install Payloadhq/callx402
|
|
127
|
+
```
|
|
98
128
|
|
|
99
|
-
|
|
129
|
+
Local development:
|
|
100
130
|
|
|
101
131
|
```sh
|
|
102
132
|
git clone https://github.com/Payloadhq/callx402
|
|
@@ -105,15 +135,78 @@ npm install
|
|
|
105
135
|
npm link # exposes the `callx402` command
|
|
106
136
|
```
|
|
107
137
|
|
|
138
|
+
### 2. First run: what works with zero setup
|
|
139
|
+
|
|
108
140
|
```sh
|
|
109
141
|
callx402 status
|
|
110
|
-
callx402
|
|
111
|
-
|
|
142
|
+
callx402 'complete this job for under $1'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`status` is the honest starting point: a per-subsystem reachability report.
|
|
146
|
+
On a bare npm install it reads `0/15 subsystems reachable`, which is
|
|
147
|
+
expected (see step 3). The intent line plans in plain language and stops
|
|
148
|
+
before execution, so it is always safe to run; use single quotes so your
|
|
149
|
+
shell does not eat `$1`.
|
|
150
|
+
|
|
151
|
+
Free read-only checks against the live Payload rail (no account, no keys):
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
curl https://payload-rail.fly.dev/v1/callx402/actions
|
|
155
|
+
curl 'https://payload-rail.fly.dev/v1/callx402/quote?action=diagnose'
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
These return the paid action catalog with prices and a free price quote for
|
|
159
|
+
one action. Invoking a rail action is paid per action via checkout (machine
|
|
160
|
+
front door: https://payloadhq.github.io/agents.json); nothing here pays
|
|
161
|
+
anything.
|
|
162
|
+
|
|
163
|
+
### 3. Self-hosted runtime (advanced, optional)
|
|
164
|
+
|
|
165
|
+
By default every subsystem command routes to the hosted rail — no setup needed.
|
|
166
|
+
If you prefer to run everything on your own machine, set `CALLX402_LOCAL=1`
|
|
167
|
+
and point `CALLX402_V2_ROOT` at the v2.0.0 tree (the x402 Paid API Starter Kit,
|
|
168
|
+
a separate product):
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
export CALLX402_LOCAL=1
|
|
172
|
+
export CALLX402_V2_ROOT=/path/to/x402-paid-api-starter-kit/v2.0.0
|
|
173
|
+
callx402 status # now: 15/15 reachable, 0/15 enabled
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Without `CALLX402_LOCAL=1`, these commands use the hosted rail instead —
|
|
177
|
+
that is the standard path and needs nothing installed beyond the npm package.
|
|
178
|
+
|
|
179
|
+
(The default is a `x402-paid-api-starter-kit/v2.0.0` directory sitting next
|
|
180
|
+
to your callx402 checkout.)
|
|
181
|
+
|
|
182
|
+
Subsystems are disabled by default; `status` names the flag that enables
|
|
183
|
+
each one. Set a flag, then run its command:
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
export PAYLOAD_MCP_DOCTOR=1
|
|
187
|
+
callx402 diagnose --target 'https://api.example.com/x402/pay'
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
More examples (each needs its subsystem flag enabled; run `callx402 status`
|
|
191
|
+
to see the flag names):
|
|
192
|
+
|
|
193
|
+
```sh
|
|
112
194
|
callx402 rescue --incident inc_123
|
|
113
|
-
callx402 route --goal
|
|
195
|
+
callx402 route --goal 'fetch 100 product prices for under 0.50 USD'
|
|
114
196
|
callx402 resolve --evidence '{"txHash":"0xabc..."}'
|
|
115
197
|
```
|
|
116
198
|
|
|
199
|
+
Note the single quotes: the goal text contains `$`-style amounts that a
|
|
200
|
+
shell would expand inside double quotes.
|
|
201
|
+
|
|
202
|
+
Alternative to the local tree: run in remote mode against your own callx402
|
|
203
|
+
server (`server/index.js`):
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
export CALLX402_MODE=remote
|
|
207
|
+
export CALLX402_REMOTE_URL=http://127.0.0.1:8787
|
|
208
|
+
```
|
|
209
|
+
|
|
117
210
|
### JavaScript SDK
|
|
118
211
|
|
|
119
212
|
```js
|
|
@@ -170,8 +263,68 @@ Full HTTP surface: `server/openapi.yaml` (served live at `GET /openapi.json`).
|
|
|
170
263
|
| `callx402 monitor [--once\|--watch]` | Watch subsystem/incident state |
|
|
171
264
|
| `callx402 preflight` | Preflight checks before a paid run |
|
|
172
265
|
| `callx402 inspect [--query <text>]` | Inspect capability graph / state |
|
|
266
|
+
| `callx402 evidence <operationId> [--dir <path>]` | Show recorded evidence for an operation (read-only) — MCP/rail only in 1.0.1, not a published CLI command |
|
|
267
|
+
| `callx402 explain <operationId> [--dir <path>]` | Plain-language state assessment for an operation (read-only) — MCP/rail only in 1.0.1, not a published CLI command |
|
|
268
|
+
| `callx402 recover <operationId> [--identity <id> \| --evidence <json>]` | Safe recovery decision: RECOVERABLE / SAFE_RETRY / HUMAN_REVIEW (read-only) — MCP/rail only in 1.0.1, not a published CLI command |
|
|
173
269
|
| `callx402 config list \| get <k> \| set <k> <v>` | Manage local config |
|
|
174
270
|
|
|
271
|
+
Subsystem commands (`diagnose`, `rescue`, `route`, `resolve`, `doctor`,
|
|
272
|
+
`monitor`, `preflight`, `inspect`) need the v2.0.0 tree plus the matching
|
|
273
|
+
feature flag (see "Full subsystem commands" above); without them they exit 3
|
|
274
|
+
and do nothing. `status`, intent mode, and `config` work with zero setup.
|
|
275
|
+
|
|
276
|
+
## Execution modes
|
|
277
|
+
|
|
278
|
+
callx402 works out of the box. There are two modes:
|
|
279
|
+
|
|
280
|
+
| Mode | What it is | Cost | Setup | What you get |
|
|
281
|
+
|---|---|---|---|---|
|
|
282
|
+
| **callx402 CLI — Hosted** (default) | The npm package as a lightweight client to the hosted Payload Rail | Free quote, then pay per action (e.g. `diagnose` $0.10, `resolve` $0.25 on the x402 path) | `npm install callx402` — zero setup | `diagnose`, `resolve`, `recover`, `preflight`, `evidence`, `explain` and more, executed server-side: free quote first, payment verified exactly once on-chain, invocation metered and auditable, result returned. |
|
|
283
|
+
| **callx402 Runtime — Self-hosted** (advanced) | CLI + the v2.0.0 runtime tree (`CALLX402_LOCAL=1`, `CALLX402_V2_ROOT` set) | Free | Point `CALLX402_V2_ROOT` at the x402 Paid API Starter Kit v2.0.0 tree + enable feature flags | Full local execution on your machine against evidence you supply. Read-only analysis; never signs, never retries, never moves money. |
|
|
284
|
+
|
|
285
|
+
A bare `npm install callx402` gives you the hosted mode — no separate tree,
|
|
286
|
+
no config, no keys. The v2 tree is never required for standard use.
|
|
287
|
+
|
|
288
|
+
## Paid one-off diagnostics (no subscription)
|
|
289
|
+
|
|
290
|
+
The CLI and MCP tools above are the **free local tier**: read-only
|
|
291
|
+
diagnostics that never charge, never execute, and never move money. When a
|
|
292
|
+
free diagnostic is not enough — you need a paid, metered, auditable invocation
|
|
293
|
+
with quote-before-payment and exactly-once payment semantics — each action is
|
|
294
|
+
also available as a **paid one-off rail action**. No subscription, no account:
|
|
295
|
+
quote, then pay deliberately.
|
|
296
|
+
|
|
297
|
+
What paying buys: the rail authorizes the action, validates the payment
|
|
298
|
+
exactly once on-chain, meters the invocation against your org, records it for
|
|
299
|
+
audit, enforces governor/quota rules for subscribers — and then **executes the
|
|
300
|
+
read-only diagnostic server-side and returns the result**. No local setup, no
|
|
301
|
+
separate tree, no keys. The rail never fakes execution: every result is
|
|
302
|
+
produced by the diagnostic modules over the evidence you supply.
|
|
303
|
+
|
|
304
|
+
The quote-before-payment flow, verified live:
|
|
305
|
+
|
|
306
|
+
```sh
|
|
307
|
+
# 1. Free quote: exact price before anything is paid
|
|
308
|
+
curl "https://payload-rail.fly.dev/v1/callx402/quote?action=resolve&path=x402"
|
|
309
|
+
# -> {"quote_id":"...","quoted_price_usd":"0.25", ...}
|
|
310
|
+
|
|
311
|
+
# 2. Invoke unauthenticated -> x402 v2 402 with the exact payment terms
|
|
312
|
+
curl -X POST https://payload-rail.fly.dev/v1/callx402/actions/resolve \
|
|
313
|
+
-H 'Content-Type: application/json' -d '{"evidence":"{...}"}'
|
|
314
|
+
# -> HTTP 402: exact USDC amount on Base, pay-to address, 300s window, quote_id
|
|
315
|
+
|
|
316
|
+
# 3. Pay deliberately from an authorized wallet, then retry with {txHash, quote_id}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Live fee schedule: `GET https://payload-rail.fly.dev/v1/callx402/actions`
|
|
320
|
+
(responds `"model":"paid on-demand per action; no subscription required"`).
|
|
321
|
+
The x402-path price is the Stripe-path fee divided by 20 — for example
|
|
322
|
+
`resolve` is $5.00 via Stripe, $0.25 via the x402 path. Never blind-retry a
|
|
323
|
+
payment to reach a paid action: get the quote first.
|
|
324
|
+
|
|
325
|
+
Problem to action map (which paid action answers which failure, with the free
|
|
326
|
+
CLI/MCP path for each): [`docs/problem-map.md`](docs/problem-map.md).
|
|
327
|
+
|
|
175
328
|
## Integrations
|
|
176
329
|
|
|
177
330
|
Working entry points for agent frameworks, automation, MCP clients, and x402
|