Add Creem Prepaid Billing & HMAC Webhooks to Any CLI Tool (shell=False)
Battle-tested open-source CLIs such as jqlang/jq (36,514 stars, MIT), prettier/prettier (52,482 stars, MIT), and svg/svgo (22,852 stars, MIT) deliver 92%-94% cold gross margins when offered as hosted APIs—yet raw shell wrappers are notoriously vulnerable to command injection and double-credited webhooks. Monetize-Anything parses --help flags into strict JSON Schema, runs subprocess.run(..., shell=False) with allowlisted flags, and wires constant-time Creem HMAC-SHA256 webhooks into an atomic SQLite WAL ledger. Verified in our live adversarial Gauntlet (16/16 real non-mocked heterogeneous cases passing in 13546.33 ms total, median 305.8 ms, plus 34/34 unit tests under python3 -W default with 0 warnings).
HTTP 422, and empty or fake-200 errors bill strictly $0.00.
Deterministic Architecture & Billing Invariants
POST /webhooks/creem authenticates every top-up via core_kit.payment_kit.verify_creem_signature (HTTP 401 on forged/missing signature) and enforces UNIQUE event_id idempotency inside SQLite WAL BEGIN IMMEDIATE. CLI execution strictly rejects shell metacharacters (;, &&, |, $(), backticks) and path traversal (..).
1-Source → 3-Channel Publishing: Every compiled target emits (1) a self-hosted Creem prepaid storefront + SQLite WAL gateway (3.9% + $0.40 MoR, $0/mo base), (2) a remote Streamable JSON-RPC 2.0 /mcp endpoint + Causal Bazaar public card (b01_monetize_anything_compiler_v1), and (3) a 4-file treg_hub/ merchant pack at 0% commission (treg call monetize-anything).
Data-Backed Comparison & Live Benchmarks
| Verified CLI Target | Incumbent Paid Alternative | Monetize-Anything Prepaid Tier | Verified Economics |
|---|---|---|---|
| jq Deterministic JSON Query & Projection CLI (MIT, 36,514 GitHub stars) — https://github.com/jqlang/jq | RapidAPI JSON Transform APIs · $29/mo · $0.0029/call | $19 Starter (38,000 calls, $0.0005/call) | 82.8% cheaper; 93% cold / 100% cached margin |
| Prettier Multi-Language Code Formatter CLI (MIT, 52,482 GitHub stars) — https://github.com/prettier/prettier | Codacy Pro (Team Code Quality) · $105/mo · $0.005/call | $19 Starter (23,750 calls, $0.0008/call) | 81.9% cheaper; 92.5% cold / 100% cached margin |
| SVGO Vector Asset Optimizer & Sanitizer CLI (MIT, 22,852 GitHub stars) — https://github.com/svg/svgo | Cloudinary Plus · $99/mo · $0.0044/call | $19 Starter (23,750 calls, $0.0008/call) | 80.8% cheaper; 93.75% cold / 100% cached margin |
| Command Injection & Webhook Replay | shell=True RCE & duplicate webhook credits | shell=False argv + HMAC-SHA256 + UNIQUE event_id | Verified in adversarial Gauntlet |
Copy-Paste Integration Example
curl -fsSL -X POST "https://monetize.fastmesh.dev/v1/compile" \
-H "Content-Type: application/json" \
-d '{"target_kind":"cli_tool","command":"jq","license":"MIT","help_text":"Usage: jq [options] <filter>\n -r, --raw-output output raw strings\n -c, --compact-output compact JSON\n -S, --sort-keys sort keys"}'
Deterministic Output
{
"ok": true,
"target_kind": "cli_tool",
"shell_mode": "shell=False",
"webhook_auth": "creem_hmac_sha256_idempotent"
}
Implementation Steps
- Parse CLI --help output via /v1/inspect: Extract short/long flags, booleans, and typed arguments into OpenAPI 3.1 and MCP schemas.
- Attach Creem prepaid packs & webhook secret: Load CREEM_WEBHOOK_SECRET via env for Starter ($19), Pro ($79), and Agency ($249) packs (Creem MoR 3.9%+$0.40, $0/mo base).
- Deploy safe shell=False execution: Block injection payloads, bill $0.00 on non-zero exit codes, and cache deterministic stdout in ArchiveCache.
Frequently Asked Questions
Why use Creem instead of building custom Stripe tax handling?
Creem acts as Merchant of Record at 3.9% + $0.40 with $0/mo base fee, handling global VAT/GST/sales tax compliance automatically with rolling 1st & 15th payouts.
How are shell injection payloads like '; rm -rf /' or '$(whoami)' stopped?
Every compiled CLI wrapper enforces subprocess.run(argv, shell=False), rejects shell metacharacters and '..' path traversal before dispatch, and bounds execution with strict timeouts.
Are failed CLI invocations billed?
No. Non-zero exit codes and empty outputs automatically settle at $0.00.
support@fastmesh.dev.