callx402 1.0.1 → 1.0.3

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.
@@ -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
+ - uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '22'
21
+ registry-url: 'https://registry.npmjs.org'
22
+ - run: npm install -g npm@latest
23
+ - run: npm ci --no-audit --no-fund
24
+ - run: npm test
25
+ - run: npm pack --dry-run
26
+
27
+
28
+ - name: Publish to npm via Trusted Publishing (OIDC, no token)
29
+ run: npm publish --provenance --access public
@@ -0,0 +1,24 @@
1
+ name: callx402 Review Tests (no live payments)
2
+ on:
3
+ pull_request:
4
+ branches: [main]
5
+ workflow_dispatch:
6
+ permissions:
7
+ contents: read
8
+ jobs:
9
+ verify:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-node@v4
14
+ with:
15
+ node-version: "22"
16
+ - run: npm ci
17
+ - run: npm test
18
+ - run: node --check core/rail.js
19
+ - run: node --check core/payer-auth.js
20
+ - run: node --check bin/callx402.js
21
+ - name: Validate package/lockfile version parity
22
+ run: node -e "const p=require('./package.json');const l=require('./package-lock.json');if(p.version!==l.version||p.version!==l.packages[''].version)process.exit(1)"
23
+ - name: Verify npm release archive without publishing
24
+ run: npm pack --dry-run
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 (one minute):**
18
+ **Try it (two minutes, no setup, no account):**
19
19
  ```sh
20
- git clone https://github.com/Payloadhq/callx402
21
- cd callx402 && npm install && npm link
22
- callx402 diagnose --target "https://api.example.com/x402/pay"
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,17 +111,22 @@ Behavioral usage language (not trademark claims):
88
111
 
89
112
  ## Quickstart
90
113
 
114
+ ### 1. Install
115
+
91
116
  ```sh
92
- npm install callx402
117
+ npm install -g callx402
93
118
  ```
94
119
 
95
- Alternative — install direct from GitHub (keeps working as a fallback):
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:
96
124
 
97
125
  ```sh
98
126
  npm install Payloadhq/callx402
99
127
  ```
100
128
 
101
- Alternative — clone and link for local development:
129
+ Local development:
102
130
 
103
131
  ```sh
104
132
  git clone https://github.com/Payloadhq/callx402
@@ -107,15 +135,78 @@ npm install
107
135
  npm link # exposes the `callx402` command
108
136
  ```
109
137
 
138
+ ### 2. First run: what works with zero setup
139
+
110
140
  ```sh
111
141
  callx402 status
112
- callx402 "complete this job for under $1"
113
- callx402 diagnose --target "https://api.example.com/x402/pay"
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
114
194
  callx402 rescue --incident inc_123
115
- callx402 route --goal "fetch 100 product prices for under $0.50"
195
+ callx402 route --goal 'fetch 100 product prices for under 0.50 USD'
116
196
  callx402 resolve --evidence '{"txHash":"0xabc..."}'
117
197
  ```
118
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
+
119
210
  ### JavaScript SDK
120
211
 
121
212
  ```js
@@ -172,8 +263,78 @@ Full HTTP surface: `server/openapi.yaml` (served live at `GET /openapi.json`).
172
263
  | `callx402 monitor [--once\|--watch]` | Watch subsystem/incident state |
173
264
  | `callx402 preflight` | Preflight checks before a paid run |
174
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 |
175
269
  | `callx402 config list \| get <k> \| set <k> <v>` | Manage local config |
176
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 hosted quote-before-payment flow:
305
+
306
+ ```sh
307
+ # 1. Obtain a free quote. No money moves.
308
+ curl "https://payload-rail.fly.dev/v1/callx402/quote?action=resolve&path=x402"
309
+
310
+ # 2. Run the interactive client. Pay explicitly by card or with USDC.
311
+ # For USDC redemption, the paying wallet must EIP-191-sign the exact
312
+ # authorization message displayed by the CLI.
313
+ callx402 resolve --evidence '{"txHash":"0x..."}'
314
+
315
+ # 3. Agents with an external wallet-produced signature can redeem the
316
+ # ORIGINAL canonical quote with a signed authorization file:
317
+ callx402 resolve --evidence '{"txHash":"0x..."}' \
318
+ --tx-hash 0xYOUR_SETTLED_PAYMENT_HASH \
319
+ --payer-auth @signed-auth.json --approve
320
+ ```
321
+
322
+ A public transaction hash alone never authorizes an action. The signed authorization
323
+ binds the paying wallet, action, transaction hash, quote, recipient, network,
324
+ and request inputs. Keep the original `quote_inputs` with the signed authorization;
325
+ requesting a new quote does not authorize an older payment. **Never give Payload
326
+ a private key, seed phrase, or wallet recovery phrase.** EIP-1271 contract-wallet
327
+ redemption is not currently enabled. Stripe credits use a separate redemption path.
328
+
329
+ Live fee schedule: `GET https://payload-rail.fly.dev/v1/callx402/actions`
330
+ (responds `"model":"paid on-demand per action; no subscription required"`).
331
+ The x402-path price is the Stripe-path fee divided by 20 — for example
332
+ `resolve` is $5.00 via Stripe, $0.25 via the x402 path. Never blind-retry a
333
+ payment to reach a paid action: get the quote first.
334
+
335
+ Problem to action map (which paid action answers which failure, with the free
336
+ CLI/MCP path for each): [`docs/problem-map.md`](docs/problem-map.md).
337
+
177
338
  ## Integrations
178
339
 
179
340
  Working entry points for agent frameworks, automation, MCP clients, and x402