solverr-agent 0.1.0 → 0.1.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 +11 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -128,27 +128,16 @@ claude mcp add solverr-agent \
|
|
|
128
128
|
|
|
129
129
|
## <img src="https://github.com/forcequitx/solverr/raw/main/assets/icons/workflow.svg" width="24" height="24" style="vertical-align: middle; margin-right: 4px;"> How a Payment Works
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
E --> F[Rank coins held: coin the business receives, same coin on another chain, stablecoins, others]
|
|
142
|
-
F --> G[POST quote with own refund address]
|
|
143
|
-
G -->|422| F
|
|
144
|
-
G --> H{Coin, refund address, deposit address, amount, deadline, limits all check out?}
|
|
145
|
-
H -->|no| X
|
|
146
|
-
H -->|yes| I[Send exact amount_in_base to deposit_address]
|
|
147
|
-
I --> J[POST deposit tx hash, poll status until paid]
|
|
148
|
-
J -->|paid| K[Send the same request with PAYMENT-SIGNATURE, up to 3 tries]
|
|
149
|
-
J -->|underpaid, refunded, failed, timeout, any other error| Y[PaymentError, fundsSent = true, invoiceId]
|
|
150
|
-
K -->|402, or still failing| Y
|
|
151
|
-
```
|
|
131
|
+
1. The agent requests the URL with the caller's method. When the answer is not a `402`, or is a `402` without a `solverr` offer it can read, the agent returns that response as it is.
|
|
132
|
+
2. For a `402` with the `solverr` scheme, it checks that the host is allowed, the gateway is trusted and the invoice is live. If any check fails, it throws `PaymentError` and nothing is sent.
|
|
133
|
+
3. It prices the invoice in USD from `/tokens` and checks the per-payment and 24-hour limits. If the price is over a limit, it throws `PaymentError` and nothing is sent.
|
|
134
|
+
4. It reserves the amount in the spend log.
|
|
135
|
+
5. It ranks the coins it holds: the coin the business receives first, then the same coin on another chain, then stablecoins, then the rest.
|
|
136
|
+
6. It asks for a quote (`POST`) with its own refund address. A `422` sends it back to step 5 for the next coin.
|
|
137
|
+
7. It checks the quote: coin, refund address, deposit address, amount, deadline and limits. If anything does not match, it throws `PaymentError` and nothing is sent.
|
|
138
|
+
8. It sends exactly `amount_in_base` to `deposit_address`, reports the transaction hash (`POST` deposit) and polls the status until the invoice is paid.
|
|
139
|
+
9. Once the invoice is paid, it sends the same request with `PAYMENT-SIGNATURE`, up to 3 tries.
|
|
140
|
+
10. When the payment ends underpaid, refunded, failed or timed out, any other error happens, or the paid request still fails or answers `402`, it throws `PaymentError` with `fundsSent: true` and the `invoiceId`.
|
|
152
141
|
|
|
153
142
|
How each chain sends the transfer, and how payments take turns:
|
|
154
143
|
|
|
@@ -196,7 +185,7 @@ npm run build -w agent
|
|
|
196
185
|
|
|
197
186
|
### Publish
|
|
198
187
|
|
|
199
|
-
Publish `solverr-x402` before `solverr-agent`: the agent's `package.json` names the x402 version it needs (`"solverr-x402": "0.1.
|
|
188
|
+
Publish `solverr-x402` before `solverr-agent`: the agent's `package.json` names the x402 version it needs (`"solverr-x402": "0.1.1"`), and npm can only install the agent once that version exists on the registry. When x402 gets a new version, set the same exact version in the agent's `dependencies` and run `npm install` in `packages/` to update the lockfile.
|
|
200
189
|
|
|
201
190
|
```bash
|
|
202
191
|
cd packages
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solverr-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Agent wallet that pays x402 Solverr paywalls from NEAR and Base within spending limits, plus a local stdio MCP server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/forcequitx/solverr/tree/main/packages/agent#readme",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"test": "vitest run"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"solverr-x402": "0.1.
|
|
52
|
+
"solverr-x402": "0.1.1",
|
|
53
53
|
"@modelcontextprotocol/server": "2.4.0",
|
|
54
54
|
"near-api-js": "7.4.0",
|
|
55
55
|
"undici": "8.12.4",
|