Skip to content

0.9.48

Choose a tag to compare

@github-actions github-actions released this 28 Jul 00:15
acdacd7
feat: prepaid session payment via x402 Lifecycle Hooks grantAccess

Session-based prepaid payment using standard x402 Lifecycle Hooks
(onProtectedRequest → grantAccess). Fully x402-compliant — no protocol
modifications, no facilitator changes, no pay.sh changes.

Flow:
1. Agent calls sap_payments_start_prepaid (free local tool)
2. Bridge calls hosted sap_payments_fund_prepaid via x402 (1 payment)
3. Server creates PrepaidCreditStore session after settlement
4. Returns sessionId to agent
5. Agent passes prepaidSessionId to sap_payments_call_paid_tool
6. Bridge injects X-SAP-Prepaid-Session header
7. Server monetization gate checks prepaid balance
8. If sufficient → grantAccess (no 402 challenge, no payment)
9. If insufficient → fall through to normal 402 payment

Components:
- src/payments/prepaid-credit-store.ts — PrepaidCreditStore (in-memory + file persistence)
- src/payments/monetization-gate.ts — onProtectedRequest hook checks X-SAP-Prepaid-Session
- src/payments/x402-paid-call.ts — bridge injects header, detects prepaid grant
- src/tools/x402-paid-call-tool.ts — 3 new tools:
  - sap_payments_fund_prepaid (hosted, paid — creates session)
  - sap_payments_start_prepaid (local, free — calls fund via bridge)
  - sap_payments_prepaid_balance (local, free — checks remaining)

Skill adrena-perp-trading updated with prepaid session docs.
Agent context prompt updated with prepaid + dry-run + batch + intent flow.
626/626 tests pass. tsc clean.