Agentic payments demo + swap visualization + installable PWA#131
Open
Pattermesh wants to merge 1 commit into
Open
Agentic payments demo + swap visualization + installable PWA#131Pattermesh wants to merge 1 commit into
Pattermesh wants to merge 1 commit into
Conversation
DEMO-READY agentic payments + light UI + PWA proposal.
(1) examples/agentic_demo/ — runnable A2A scenario: Agent A pays Agent B for
work via the x402 middleware + on-chain escrow (402 offer -> validate ->
lock -> deliver -> confirm/release), then an AGENTIC SWAP step where B routes
the received USDC through SafeSwap. Node/RPC-free: drives the real
X402Middleware + GasTracker against an in-memory chain (MockChain /
MockPaymentClient) and a mockable SafeSwap orchestrator. Runs with
`python examples/agentic_demo/run.py` (+ --json, --swap-to, --price).
tests/test_agentic_demo.py asserts the full flow: 402 -> pay -> settle
(escrow Released) and the SafeSwap swap routes (quote -> execute).
(2) web/lab/swap.html — a focused lab page visualizing the A2A pay + swap demo:
animated canvas (payer / escrow / payee / SafeSwap nodes + in-flight
packets), a step-by-step flow ledger, and live balances. Reuses the lab's
shared.css/shared.js; wired into the lab dashboard + sidebar + _build.js.
Does not touch the strict agents-demo.html scene engine.
(3) PWA — web/manifest.json + web/sw.js make the lab installable + offline-
capable (app-shell precache, network-first navigations w/ offline fallback,
stale-while-revalidate assets). Registration injected via shared.js (lab)
and web/index.html (root). docs/PWA.md proposes the "switchboard plugin"
PWA: install/consent flow, offline architecture, and how a host PWA embeds
switchboard payments (402 interception -> pay -> retry, budget-gated).
tests/test_pwa.py validates manifest, icons, SW shell, and registration.
GATE: PYTHONPATH=. python3 -m pytest -q -> 245 passed, 62 skipped (was 223;
+22 new). swap.html + sw.js pass node --check.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| """Minimal transport SafeSwapClient drives. The real impl is HTTP; the test | ||
| impl is :class:`MockSafeSwapOrchestrator`.""" | ||
|
|
||
| def post(self, path: str, body: dict) -> dict: ... |
| from __future__ import annotations | ||
|
|
||
| import hashlib | ||
| import time |
| import hashlib | ||
| import time | ||
| import uuid | ||
| from dataclasses import dataclass, field |
Contributor
|
🤖 Audit skipped — diff is 96KB (limit 64KB). Labelling for human review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes SWITCHBOARD demo-ready for agentic payments, adds a focused UI visualization, and ships an installable PWA with a plugin proposal. All additive; the existing lab and tests are untouched.
(1) Agentic payments demo —
examples/agentic_demo/A runnable scenario where Agent A pays Agent B for work via the x402 middleware + on-chain escrow, then Agent B routes the received token through SafeSwap.
Flow:
402 offer -> validate (cap/allowlist/gas budget) -> lock in escrow -> deliver -> confirm/release -> SafeSwap quote -> execute.switchboard.x402_middleware.X402Middleware+switchboard.gas_tracker.GasTrackeragainst an in-memory chain (MockChain/MockPaymentClient) that implements thePaymentClient+ AgentEscrow surface — so it runs node/RPC-free.safeswap.pyis aSafeSwapClientagainst the orchestrator API (/v1/quote,/v1/execute) with an in-processMockSafeSwapOrchestrator. PointSafeSwapClient(base_url=...)at the live orchestrator for real routing.tests/test_agentic_demo.pyasserts the full flow: the 402 offer carries the escrow scheme + price, the escrow ends Released (not just Locked), funds move payer -> escrow -> payee, the SafeSwap orchestrator is genuinely called (quotethenexecute), and the swap routes.(2) UI —
web/lab/swap.htmlA new lab page that visualizes the A2A pay + swap demo: an animated canvas (payer / escrow / payee / SafeSwap nodes with in-flight packets), a step-by-step flow ledger, and live balances, with
swap-into/job-pricecontrols. Reuses the lab'sshared.css/shared.jsand the Luxury-Observatory aesthetic. Wired into the lab dashboard, sidebar, and_build.js. The strictagents-demo.htmlscene engine is not touched.(3) PWA —
web/manifest.json+web/sw.js+docs/PWA.mdany+maskable, shortcuts), service worker (app-shell precache, network-first navigations with offline fallback, stale-while-revalidate assets, cross-origin font cache).shared.js(every lab page) andweb/index.html(root, scope./).docs/PWA.mdproposes the "switchboard plugin" PWA: install/consent flow, offline architecture, and how a host PWA embeds switchboard payments (402 interception -> budget-gated pay -> retry with proof, optional SafeSwap rebalance), reusing the same wire types as the Python library.tests/test_pwa.pyvalidates the manifest + icons +start_url/shortcut targets, thatsw.jsis valid JS precaching a real on-disk shell with an offline fallback, and that registration is wired into root + lab pages.swap.htmlJS isnode --checked too.Gate
(baseline was 223 passed; +22 new tests across the demo + PWA).
swap.htmlandsw.jspassnode --check.🤖 Generated with Claude Code