-
Notifications
You must be signed in to change notification settings - Fork 127
feat: add mppx agent skill #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| name: mppx | ||
| description: TypeScript SDK for the Payment HTTP Authentication Scheme. Handles 402 Payment Required flows with Tempo, Stripe, and other payment methods. Use when integrating payments or mppx into a client or server application. | ||
| --- | ||
|
|
||
| # mppx | ||
|
|
||
| TypeScript SDK for the "Payment" HTTP Authentication Scheme. Full 402 flow: challenge → credential → receipt. | ||
|
|
||
| ## Client | ||
|
|
||
| ```ts | ||
| import { Mppx, tempo } from 'mppx/client' | ||
|
|
||
| // Polyfills globalThis.fetch to handle 402 automatically | ||
| Mppx.create({ | ||
| methods: [tempo({ account })], | ||
| }) | ||
|
|
||
| const res = await fetch('https://api.example.com/resource') | ||
| ``` | ||
|
|
||
| Without polyfilling: | ||
|
|
||
| ```ts | ||
| const mppx = Mppx.create({ | ||
| methods: [tempo({ account })], | ||
| polyfill: false, | ||
| }) | ||
|
|
||
| const res = await mppx.fetch('https://api.example.com/resource') | ||
| ``` | ||
|
|
||
| ## Server | ||
|
|
||
| ```ts | ||
| import { Mppx, tempo } from 'mppx/server' | ||
|
|
||
| const mppx = Mppx.create({ | ||
| methods: [tempo({ currency: '0x...', recipient: '0x...' })], | ||
| secretKey: process.env.MPP_SECRET_KEY, | ||
| }) | ||
|
|
||
| async function handler(request: Request): Promise<Response> { | ||
| const result = await mppx.charge({ amount: '1.00' })(request) | ||
| if (result.status === 402) return result.challenge | ||
| return result.withReceipt(Response.json({ data: '...' })) | ||
| } | ||
| ``` | ||
|
|
||
| ## Methods | ||
|
|
||
| | Method | Intent | Description | | ||
| |---|---|---| | ||
| | `tempo.charge` | `charge` | One-time stablecoin payment (TIP-20 token transfer on Tempo) | | ||
| | `tempo.session` | `session` | Streaming payments via payment channels on Tempo | | ||
| | `stripe.charge` | `charge` | One-time payment via Stripe | | ||
|
|
||
| `tempo()` returns `[tempo.charge, tempo.session]` as a tuple. Use `tempo.charge()` or `tempo.session()` individually if you only need one intent. | ||
|
|
||
| ## Exports | ||
|
|
||
| | Path | Purpose | | ||
| |---|---| | ||
| | `mppx` | Core primitives (`Challenge`, `Credential`, `Method`, `Receipt`, `PaymentRequest`) | | ||
| | `mppx/client` | `Mppx`, `tempo`, `stripe`, `session`, `Transport` | | ||
| | `mppx/server` | `Mppx`, `tempo`, `stripe`, `Transport`, `Store`, `NodeListener` | | ||
| | `mppx/hono` | Hono middleware | | ||
| | `mppx/express` | Express middleware | | ||
| | `mppx/nextjs` | Next.js middleware | | ||
| | `mppx/elysia` | Elysia middleware | | ||
|
|
||
| ## CLI | ||
|
|
||
| `mppx` includes a CLI for making paid requests during development: | ||
|
|
||
| ```sh | ||
| npx mppx account create # create wallet | ||
| npx mppx mpp.dev/api/ping/paid # make paid request | ||
| npx mppx example.com -v # verbose output | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| - Docs: https://mpp.dev/sdk/typescript | ||
| - Repo: https://github.com/wevm/mppx | ||
| - Spec: https://github.com/tempoxyz/payment-auth-spec | ||
| - Tempo: https://docs.tempo.xyz |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extremely basic for now (can benchmark later, wanted to get something out to fix wevm/mppx#211)