Skip to content

fix(cli): harden remote calls and payment compatibility - #6

Open
1amKhush wants to merge 5 commits into
ContextVM:mainfrom
1amKhush:fix/cvmi-e2e-qa
Open

fix(cli): harden remote calls and payment compatibility#6
1amKhush wants to merge 5 commits into
ContextVM:mainfrom
1amKhush:fix/cvmi-e2e-qa

Conversation

@1amKhush

Copy link
Copy Markdown

Summary

  • detect encryption support from server announcements and safely fall back for servers that do not support encryption
  • add bounded MCP request timeouts with a --timeout override
  • correctly forward --extract and --pretty-raw
  • return nonzero exit codes for MCP tool errors
  • consume CEP-41 streams, render muxll text incrementally, preserve raw stream records, and clean up failed streams
  • make explicit payment gating opt-in for cvmi use
  • run both test directories and real type-checking in CI

Validation

  • npm test — 32 files, 416 tests passed
  • npm run type-check
  • npm run build
  • npm run format:check
  • git diff --check

End-to-end QA

Validated the packaged CLI against a local Nostr relay with:

  • an encryption-disabled public cvmi serve
  • --pretty-raw and --extract
  • a complete cvmi use MCP proxy call
  • faux-backed muxll streaming
  • an MCP isError result returning exit code 1

Copilot AI lite review requested due to automatic review settings August 18, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --timeout override, forwards additional output flags, supports CEP-41 streaming consumption, and returns nonzero statuses for tool error results.
  • Makes cvmi use payment 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-mode unset 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.

Comment thread src/use.ts Outdated
--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
Comment thread src/call.ts Outdated
--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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants