docs(sdk): add D402 agent-payment cookbook (HTTP-402 settlement loop)#8
docs(sdk): add D402 agent-payment cookbook (HTTP-402 settlement loop)#8cX3po wants to merge 2 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 41 minutes and 36 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR introduces comprehensive documentation for D402 Agent Payments over HTTP 402. It adds a new documentation page describing the server-side middleware for gating routes with payment requirements and the client-side flow for handling and fulfilling those payments, along with verification logic and error cases. The navigation configuration is updated to surface the new page. ChangesD402 HTTP 402 Payment Documentation
🎯 1 (Trivial) | ⏱️ ~5 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by QodoAdd D402 agent-payment cookbook with HTTP 402 settlement guide
WalkthroughsDescription• Adds comprehensive D402 cookbook documentation page • Covers server-side d402Required middleware with all configuration options • Covers client-side D402Client payment flow and round-trip verification • Includes denomination guide (OS_PER_DEM = 10^9) to prevent overcharging errors • Documents error handling, edge cases, and defensive client patterns • Registers new page in navigation under Code Examples group Diagramflowchart LR
A["D402 Cookbook Page"] --> B["Server: d402Required Middleware"]
A --> C["Client: D402Client Flow"]
B --> D["Payment Requirement Challenge"]
C --> E["Create & Settle Payment"]
E --> F["Retry with X-Payment-Proof"]
F --> G["On-Chain Verification"]
G --> H["Resource Access"]
A --> I["Denomination Guide: 10^9 OS per DEM"]
A --> J["Error Handling & Edge Cases"]
File Changes1. docs.json
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs.json (1)
220-221: 💤 Low valueConsider grouping standalone cookbook pages for consistency.
The
d402andevm-contract-write-transactionsentries are placed at the root level of "Code Examples" alongside group objects like SWAP and Transactions. While valid, this creates a mixed navigation structure. Consider grouping these under a "Recipes" or "Additional Examples" group for consistency, or moving d402 into a "Payments" or "Commerce" group if more payment-related docs are planned.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs.json` around lines 220 - 221, The docs.json navigation mixes standalone entries "sdk/cookbook/d402" and "sdk/cookbook/evm-contract-write-transactions" with grouped objects under "Code Examples"; to fix, move these two strings into a new group object (e.g., title "Recipes" or "Additional Examples") or place "sdk/cookbook/d402" into an existing "Payments"/"Commerce" group so all cookbook pages follow the same grouped structure; update the "Code Examples" array to replace the raw strings with the new group object containing these slugs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@docs.json`:
- Around line 220-221: The docs.json navigation mixes standalone entries
"sdk/cookbook/d402" and "sdk/cookbook/evm-contract-write-transactions" with
grouped objects under "Code Examples"; to fix, move these two strings into a new
group object (e.g., title "Recipes" or "Additional Examples") or place
"sdk/cookbook/d402" into an existing "Payments"/"Commerce" group so all cookbook
pages follow the same grouped structure; update the "Code Examples" array to
replace the raw strings with the new group object containing these slugs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3714f55b-83c6-4164-bb4a-e3ff82d2a6f3
📒 Files selected for processing (2)
docs.jsonsdk/cookbook/d402.mdx
Addresses Qodo review: line 62 said "matches exactly" but validatePayment enforces >= (overpayment accepted). Aligned the intro to the >= semantics documented in the verification section + Warning.
|
Thanks — fixed the contradiction. The intro now matches the |
Why. D402 ships as a public SDK export (
@kynesyslabs/demosdk/d402,/d402/server,/d402/client) but has no docs page — builders have no guide to the 402 → pay →X-Payment-Proof→ verify loop. This adds a complete cookbook page: serverd402Requiredmiddleware (all options), clientD402Clientflow, the round-trip + on-chain verification, error handling, and a denomination<Note>(OS_PER_DEM = 10^9 — the page deliberately avoids the 10^18 trap that's currently in the middleware JSDoc, see sdks#92).Section & path. new
sdk/cookbook/d402.mdx+ nav entry indocs.json(Code Examples group). Verified line-by-line against the live SDK source.One implementer's contribution from the PATH-OS Labs review pass — happy to adjust tone/placement.
Summary by CodeRabbit