fix(cli): harden remote calls and payment compatibility - #6
Open
1amKhush wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens cvmi’s remote MCP interactions and improves compatibility with older/alternate servers by adding encryption capability detection, bounded request timeouts, better streaming support, and more reliable CLI exit codes—while also tightening CI validation.
Changes:
- Adds encryption-support discovery via server announcements and falls back to unencrypted mode when encryption is optional but unsupported.
- Introduces bounded MCP request timeouts with a
--timeoutoverride, forwards additional output flags, supports CEP-41 streaming consumption, and returns nonzero statuses for tool error results. - Makes
cvmi usepayment interaction mode opt-in for broader server compatibility, and strengthens CI by running full tests + real type-checking.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/cli-parsing.test.ts | Adds coverage to ensure call/use CLI parsing forwards output + timeout options and leaves payment mode unset by default. |
| src/use.ts | Makes payment negotiation opt-in when proxying over stdio; updates help text and adds a small test export. |
| src/use.test.ts | Verifies payment option resolution does not force negotiation by default. |
| src/discover.ts | Recognizes singleton support_encryption announcement tags. |
| src/discover.test.ts | Adds regression test for singleton encryption-support tag parsing. |
| src/cli.ts | Centralizes call options mapping, supports timeout forwarding, and sets process exit codes based on MCP call results/errors. |
| src/call.ts | Implements timeouts, encryption discovery fallback, CEP-41 streaming consumption, stderr diagnostics, and numeric exit status returns. |
| src/call.test.ts | Expands tests for timeouts, encryption discovery, streaming behavior, stderr logging, and exit code handling. |
| package.json | Runs the full Vitest suite (not just src/). |
| .github/workflows/ci.yml | Runs pnpm type-check in CI before build. |
Suppressed comments (1)
src/use.ts:171
- This help line still claims
transparent (default), but the code now leaves--payment-modeunset unless the user explicitly passes it. Clarify that the default is omitting the flag (server-compatible behavior).
--payment-mode transparent (default) | explicit_gating
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| --relays <urls> Comma-separated relay URLs (default: wss://relay.contextvm.org) | ||
| --encryption-mode Encryption mode: optional, required, disabled (default: optional) | ||
| --payment-mode Payment interaction: explicit_gating (default), transparent | ||
| --payment-mode Payment interaction: transparent (default), explicit_gating |
| --relays <urls> Comma-separated relay URLs | ||
| --encryption-mode Encryption mode: optional, required, disabled | ||
| --payment-mode Payment interaction mode: transparent (default), explicit_gating | ||
| --timeout <ms> Request timeout; defaults to 60s idle / 5m total |
Request explicit_gating only when the kind-11316 announcement advertises the CEP-8 availability tag; otherwise leave negotiation unset. Free, legacy, and transparent-only servers keep working (a transparent-only server rejects an explicit_gating request with -32602), while gating- capable priced servers give agent hosts the clean -32042 error instead of an unwatched invoice notification.
…calls - post-result stream drain is now bounded by min(--timeout, 30s) instead of hanging forever on a stuck CEP-41 iterator; the zero-tick heuristic and its chunk-dropping ceiling are documented - stateful calls skip the announcement probe (handshake carries caps), saving a relay roundtrip; stateless (default) keeps it - share announcement helpers (kind constant, hex pubkey, encryption support) with discover.ts instead of duplicating them - --timeout help now says it caps both idle and total time
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.
Summary
--timeoutoverride--extractand--pretty-rawcvmi useValidation
npm test— 32 files, 416 tests passednpm run type-checknpm run buildnpm run format:checkgit diff --checkEnd-to-end QA
Validated the packaged CLI against a local Nostr relay with:
cvmi serve--pretty-rawand--extractcvmi useMCP proxy callisErrorresult returning exit code 1