feat: add CEP-8 explicit payment gating to cvmi call#5
Open
abhayguptas wants to merge 2 commits into
Open
Conversation
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.
Add CEP-8 Payment Lifecycle Support to
cvmi callDescription
This PR brings full CEP-8 payment handling to the
cvmi callcommand, bringing it up to parity with thecontextvm-siteclient. Previously, calling a paid MCP endpoint via the CLI would fail or hang because the CLI had no awareness ofnotifications/payment_required.This update upgrades
@contextvm/sdkto0.13.0and utilizes its nativewithClientPaymentsmiddleware to handle all the heavy lifting (PMI capability advertisement, NIP-47 heartbeats, and waiting for server settlement).Changes
@contextvm/sdkto0.13.0NostrClientTransportincreateRemoteClientwithwithClientPaymentsmiddleware.CliPaymentHandler(mirroringUiOnlyPaymentHandlerincontextvm-site). Instead of auto-paying, this handler simply prints the parsed lightning invoice to the terminal using standard UI tokens (BOLD,CYAN,DIM), and waits for human payment out-of-band while the SDK background loop awaitspayment_accepted.--payment-modeflag.transparent(Default): Pauses execution, prints the invoice to the terminal, and waits for settlement.explicit_gating: Designed for AI agents. If the server throws a-32042 Payment Requirederror, the CLI immediately outputs the raw payment schema as structured JSON tostdoutand throws an exit code 2.Usage Example
Human Usage (Transparent):
Agentic Usage (Explicit Gating):