@mainlayer/cli 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Copyright (c) 2026 Mainlayer. All rights reserved.
2
+
3
+ This software and its source code are proprietary and confidential.
4
+ Unauthorized copying, modification, distribution, or use of this software,
5
+ in whole or in part, is strictly prohibited without prior written permission
6
+ from Mainlayer.
7
+
8
+ The @mainlayer/cli package may be installed and used as part of the Mainlayer
9
+ platform under the terms of your Mainlayer service agreement.
10
+
11
+ For licensing inquiries: legal@mainlayer.io
package/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # @mainlayer/cli
2
+
3
+ > The official Mainlayer CLI. Sell and buy digital resources on-chain — APIs, data feeds, and AI services — directly from your terminal or AI agent.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@mainlayer/cli)](https://www.npmjs.com/package/@mainlayer/cli)
6
+ [![Node.js >=22](https://img.shields.io/badge/node-%3E%3D22-brightgreen)](https://nodejs.org)
7
+ [![License](https://img.shields.io/badge/license-proprietary-lightgrey)](LICENSE)
8
+
9
+ ## What is Mainlayer?
10
+
11
+ Mainlayer is a payment marketplace for the agentic economy. Vendors list APIs, data feeds, and AI services. Buyers — including AI agents — discover and pay for them on-chain using Solana USDC.
12
+
13
+ The CLI gives you full access to both sides of the marketplace from your terminal. It also works headlessly, so your AI agent can register, pay, and transact without any human in the loop.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install -g @mainlayer/cli
19
+ ```
20
+
21
+ On install, the CLI automatically detects AI platforms on your machine and configures the Mainlayer MCP server in each one. To re-run detection at any time:
22
+
23
+ ```bash
24
+ mainlayer setup
25
+ ```
26
+
27
+ ## Sell a resource in 60 seconds
28
+
29
+ ```bash
30
+ # Create an account and get an API key
31
+ mainlayer auth register --email you@example.com --password ...
32
+ mainlayer auth api-key create --label "my-service"
33
+ export MAINLAYER_API_KEY=sk_live_...
34
+
35
+ # Create a wallet to receive payments
36
+ export MAINLAYER_WALLET_PASSPHRASE=your-passphrase
37
+ mainlayer wallet create
38
+
39
+ # List your resource on the marketplace
40
+ mainlayer resource create \
41
+ --slug my-api \
42
+ --description "My API" \
43
+ --price 0.01 \
44
+ --fee-model per_call \
45
+ --type api
46
+
47
+ # Receive payment notifications
48
+ mainlayer webhook update --url https://example.com/webhooks
49
+ ```
50
+
51
+ ## Buy a resource in 60 seconds
52
+
53
+ ```bash
54
+ # Create an account
55
+ mainlayer auth register --email you@example.com --password ...
56
+ mainlayer auth api-key create --label "buyer"
57
+ export MAINLAYER_API_KEY=sk_live_...
58
+
59
+ # Create and fund a wallet (requires SOL + USDC)
60
+ export MAINLAYER_WALLET_PASSPHRASE=your-passphrase
61
+ mainlayer wallet create
62
+
63
+ # Browse the marketplace
64
+ mainlayer discover --query "data feeds"
65
+
66
+ # Purchase (on-chain payment, no intermediary)
67
+ mainlayer buy <resource-id>
68
+
69
+ # Check your active access
70
+ mainlayer entitlements
71
+ ```
72
+
73
+ ## Built for AI agents
74
+
75
+ Every command supports `--json` for structured output and returns predictable exit codes. Set environment variables and your agent can operate fully headlessly.
76
+
77
+ ```bash
78
+ export MAINLAYER_API_KEY=sk_live_...
79
+ export MAINLAYER_WALLET_PASSPHRASE=your-passphrase
80
+
81
+ mainlayer discover --json | jq '.[0].id'
82
+ mainlayer buy res_... --json
83
+ ```
84
+
85
+ **Exit codes:**
86
+
87
+ | Code | Meaning |
88
+ |------|---------|
89
+ | `0` | Success |
90
+ | `1` | General error |
91
+ | `2` | Authentication error |
92
+ | `3` | Not found |
93
+ | `4` | Validation error |
94
+ | `5` | Already exists |
95
+
96
+ ## Wallet security
97
+
98
+ Your private key never leaves your machine. It is encrypted with AES-256-GCM and a PBKDF2-derived key (200,000 iterations) and stored at `~/.mainlayer/wallet.json`. The key is only decrypted when a transaction needs to be signed.
99
+
100
+ ```bash
101
+ # Headless mode: set passphrase as env var to skip interactive prompt
102
+ export MAINLAYER_WALLET_PASSPHRASE=your-passphrase
103
+ mainlayer buy <resource-id> --json
104
+ ```
105
+
106
+ ## MCP auto-configuration
107
+
108
+ Installing the CLI automatically adds the Mainlayer MCP server to every AI platform detected on your machine. This lets AI agents use Mainlayer tools natively — no manual setup.
109
+
110
+ **Supported platforms:**
111
+
112
+ - [x] Claude Code
113
+ - [x] Cursor
114
+ - [x] Windsurf
115
+ - [x] Gemini CLI
116
+ - [x] VS Code (Copilot)
117
+ - [x] Zed
118
+ - [x] Continue
119
+ - [x] Cline
120
+ - [ ] Claude Desktop — add manually via **Settings > Connectors**, URL: `https://api.mainlayer.fr/mcp`
121
+ - [ ] OpenClaw — add manually via `~/.openclaw/openclaw.json`
122
+
123
+ **Re-run or force-update:**
124
+
125
+ ```bash
126
+ mainlayer setup # Re-detect and configure (skips already-configured)
127
+ mainlayer setup --force # Overwrite all existing entries
128
+ mainlayer setup --json # JSON output for programmatic use
129
+ ```
130
+
131
+ ## Command reference
132
+
133
+ | Command | Description |
134
+ |---------|-------------|
135
+ | `mainlayer auth` | Register, log in, log out, check status, manage API keys |
136
+ | `mainlayer wallet` | Create, import, view address, check balance, export |
137
+ | `mainlayer config` | Read and write CLI configuration |
138
+ | `mainlayer resource` | Create and manage resources, pricing plans, and quotas |
139
+ | `mainlayer coupon` | Create and manage discount codes |
140
+ | `mainlayer webhook` | Configure webhook URL, view logs, retry deliveries |
141
+ | `mainlayer earnings` | Revenue summary by resource and time period |
142
+ | `mainlayer metrics` | Usage analytics per resource |
143
+ | `mainlayer discover` | Search the marketplace — no auth required |
144
+ | `mainlayer buy` | Purchase a resource via on-chain payment |
145
+ | `mainlayer entitlements` | View your active access grants |
146
+ | `mainlayer subscribe` | Manage subscriptions (approve, pause, resume, cancel) |
147
+ | `mainlayer invoices` | View invoice history |
148
+ | `mainlayer refund` | Request a refund |
149
+ | `mainlayer dispute` | Open or list payment disputes |
150
+ | `mainlayer setup` | Re-run MCP platform detection |
151
+
152
+ ```bash
153
+ mainlayer <command> --help # Full flag docs for any command
154
+ ```
155
+
156
+ ## Environment variables
157
+
158
+ | Variable | Description |
159
+ |----------|-------------|
160
+ | `MAINLAYER_API_KEY` | API key for authentication. Create with `mainlayer auth api-key create` |
161
+ | `MAINLAYER_WALLET_PASSPHRASE` | Wallet passphrase for headless/agent signing |
162
+ | `MAINLAYER_API_URL` | Override API base URL (default: `https://api.mainlayer.fr`) |
163
+ | `MAINLAYER_SOLANA_NETWORK` | Override Solana network (default: `solana:mainnet`) |
164
+
165
+ ## License
166
+
167
+ Proprietary - see [LICENSE](LICENSE) for details.
@@ -0,0 +1 @@
1
+ export { };