Skip to content

Commit 55fdf54

Browse files
Docs: publisher/agent guides, x402 flow diagrams, mypy fix
- README: restore high-level x402 and wallet sequence diagrams - PUBLISHER_GUIDE: rewrite for non-technical users with nav menu, step-by-step, examples (News Today), failure tables, callouts - AI_AGENT_GUIDE: nav menu, system checks, limitations, failure points table, example I/O, keep technical content - core/url_validation: fix mypy assignment (addr type annotation)
1 parent 9bf6437 commit 55fdf54

4 files changed

Lines changed: 663 additions & 467 deletions

File tree

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,62 @@ asyncio.run(main())
228228

229229
The payment flow works like a toll booth: you ask for content, get told the price, pay, and then receive the content along with a receipt and a legal access grant.
230230

231+
### High-level flow (technical overview)
232+
233+
**Path A — x402 (one-time payment):** Agent → 402 → pay → retry → Fairfetch settles with Facilitator → 200 + content + grant.
234+
235+
```
236+
Agent Fairfetch Facilitator
237+
| | |
238+
| GET /content/fetch?url=... | |
239+
| &usage=rag | |
240+
|------------------------------>| |
241+
| | |
242+
| 402 Payment Required | |
243+
| { accepts: { price (2x), | |
244+
| usage_category: "rag" }, | |
245+
| available_tiers: {...} } | |
246+
|<------------------------------| |
247+
| | |
248+
| GET + X-PAYMENT: <proof> | |
249+
|------------------------------>| |
250+
| | POST /settle |
251+
| |-------------------------> |
252+
| | { valid, tx_hash } |
253+
| |<------------------------- |
254+
| | |
255+
| 200 OK + Content | |
256+
| X-PAYMENT-RECEIPT: 0x... | |
257+
| X-FairFetch-License-ID: ... | |
258+
| X-FairFetch-Usage-Category: | |
259+
| rag | |
260+
| X-FairFetch-Compliance-Level:| |
261+
| standard | |
262+
|<------------------------------| |
263+
```
264+
265+
**Path B — Wallet (pre-funded):** Agent sends `X-WALLET-TOKEN`; Fairfetch charges the ledger and returns content in one round-trip. No 402, no Facilitator call.
266+
267+
```
268+
Agent Fairfetch Ledger
269+
| | |
270+
| GET /content/fetch?url=... | |
271+
| X-WALLET-TOKEN: <token> | |
272+
|------------------------------>| |
273+
| | charge(wallet, price) |
274+
| |-------------------------> |
275+
| | { tx_id, balance } |
276+
| |<------------------------- |
277+
| | |
278+
| 200 OK + Content | |
279+
| X-FairFetch-Payment-Method: | |
280+
| wallet | |
281+
| X-FairFetch-Wallet-Balance: | |
282+
| X-PAYMENT-RECEIPT: ff_... | |
283+
| X-FairFetch-License-ID: ... | |
284+
|<------------------------------| |
285+
```
286+
231287
**Step 1 — Ask for content (no payment yet):**
232288

233289
```bash

core/url_validation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def validate_url(url: str) -> str:
5858
if parsed.path.startswith(prefix):
5959
raise UnsafeURLError(f"Path '{parsed.path}' is blocked (cloud metadata)")
6060

61+
addr: ipaddress.IPv4Address | ipaddress.IPv6Address | None
6162
try:
6263
addr = ipaddress.ip_address(hostname)
6364
except ValueError:

0 commit comments

Comments
 (0)