@botwallet/cli 0.1.0-beta.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/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @botwallet/cli
2
+
3
+ Command-line interface for AI agents to manage their Botwallet accounts.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @botwallet/cli
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Register a new wallet (FROST threshold key generation)
15
+ botwallet register --name "My Agent Wallet" --owner human@example.com
16
+
17
+ # Check your balance (after wallet is claimed)
18
+ botwallet wallet balance
19
+
20
+ # Two-step payment flow
21
+ botwallet pay @merchant 10.00 # Step 1: Create intent
22
+ botwallet pay confirm <transaction_id> # Step 2: FROST sign & submit
23
+ ```
24
+
25
+ `register` is the recommended way to create a wallet. `wallet create` does the same thing.
26
+
27
+ ## Commands
28
+
29
+ | Group | Commands |
30
+ |-------|----------|
31
+ | `wallet` | `create`, `info`, `balance`, `list`, `use`, `deposit`, `owner`, `backup`, `export`, `import` |
32
+ | `pay` | `(default)`, `confirm`, `preview`, `list`, `cancel` |
33
+ | `paylink` | `create`, `send`, `get`, `list`, `cancel` |
34
+ | `fund` | `(default)`, `ask`, `list` |
35
+ | `withdraw` | `(default)`, `confirm`, `get` |
36
+ | `x402` | `fetch`, `fetch confirm`, `discover` |
37
+ | Utilities | `register`, `history`, `limits`, `approvals`, `approval status`, `events`, `lookup`, `ping`, `version`, `docs` |
38
+
39
+ Run `botwallet docs` for full embedded documentation.
40
+
41
+ ## Output Modes
42
+
43
+ - **JSON (default)** — Machine-readable for bots and scripts
44
+ - **`--human`** — Formatted output with colors and tips
45
+
46
+ ## Authentication
47
+
48
+ Credentials are saved automatically on `register`. Or set manually:
49
+
50
+ ```bash
51
+ export BOTWALLET_API_KEY="bw_bot_your_key_here"
52
+ ```
53
+
54
+ Use `--wallet <name>` to switch between multiple wallets, or `--api-key` for explicit auth.
55
+
56
+ ## Two-Step Flows
57
+
58
+ Payments, withdrawals, and x402 API access use a two-step flow:
59
+
60
+ 1. **Create intent** — CLI validates, server checks guard rails
61
+ 2. **Confirm** — FROST threshold signing (agent + server cooperate), then submit to Solana
62
+
63
+ This ensures neither party can sign alone.
64
+
65
+ ## Alternative Installation
66
+
67
+ ### Direct Download
68
+
69
+ Download from [GitHub Releases](https://github.com/botwallet-co/agent-cli/releases).
70
+
71
+ ### From Source
72
+
73
+ ```bash
74
+ go install github.com/botwallet-co/agent-cli@latest
75
+ ```
76
+
77
+ ## License
78
+
79
+ Apache 2.0 — See [LICENSE](../LICENSE) for details.
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@botwallet/cli",
3
+ "version": "0.1.0-beta.1",
4
+ "description": "CLI for AI agents to manage their Botwallet accounts",
5
+ "keywords": [
6
+ "botwallet",
7
+ "ai",
8
+ "agent",
9
+ "cli",
10
+ "payments",
11
+ "wallet",
12
+ "cryptocurrency",
13
+ "solana",
14
+ "usdc"
15
+ ],
16
+ "homepage": "https://botwallet.co",
17
+ "bugs": {
18
+ "url": "https://github.com/botwallet-co/agent-cli/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/botwallet-co/agent-cli.git"
23
+ },
24
+ "license": "Apache-2.0",
25
+ "author": "Botwallet <support@botwallet.co>",
26
+ "bin": {
27
+ "botwallet": "./bin/botwallet"
28
+ },
29
+ "scripts": {
30
+ "postinstall": "node scripts/install.js"
31
+ },
32
+ "engines": {
33
+ "node": ">=14.0.0"
34
+ },
35
+ "os": [
36
+ "darwin",
37
+ "linux",
38
+ "win32"
39
+ ],
40
+ "cpu": [
41
+ "x64",
42
+ "arm64"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env node
2
+ // =============================================================================
3
+ // Botwallet CLI npm postinstall script
4
+ // =============================================================================
5
+ // Downloads the appropriate binary for the user's platform.
6
+ // =============================================================================
7
+
8
+ const https = require('https');
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const { execSync } = require('child_process');
12
+
13
+ const PACKAGE_VERSION = require('../package.json').version;
14
+ const GITHUB_RELEASE_URL = `https://github.com/botwallet-co/agent-cli/releases/download/v${PACKAGE_VERSION}`;
15
+
16
+ // Platform mapping
17
+ const PLATFORM_MAP = {
18
+ darwin: 'darwin',
19
+ linux: 'linux',
20
+ win32: 'windows'
21
+ };
22
+
23
+ const ARCH_MAP = {
24
+ x64: 'amd64',
25
+ arm64: 'arm64'
26
+ };
27
+
28
+ function getPlatform() {
29
+ const platform = PLATFORM_MAP[process.platform];
30
+ if (!platform) {
31
+ throw new Error(`Unsupported platform: ${process.platform}`);
32
+ }
33
+ return platform;
34
+ }
35
+
36
+ function getArch() {
37
+ const arch = ARCH_MAP[process.arch];
38
+ if (!arch) {
39
+ throw new Error(`Unsupported architecture: ${process.arch}`);
40
+ }
41
+ return arch;
42
+ }
43
+
44
+ function getBinaryName() {
45
+ const platform = getPlatform();
46
+ const arch = getArch();
47
+ const ext = platform === 'windows' ? '.exe' : '';
48
+ return `botwallet_${PACKAGE_VERSION}_${platform}_${arch}${ext}`;
49
+ }
50
+
51
+ function getArchiveName() {
52
+ const platform = getPlatform();
53
+ const arch = getArch();
54
+ const ext = platform === 'windows' ? 'zip' : 'tar.gz';
55
+ return `botwallet_${PACKAGE_VERSION}_${platform}_${arch}.${ext}`;
56
+ }
57
+
58
+ function downloadFile(url, dest) {
59
+ return new Promise((resolve, reject) => {
60
+ const file = fs.createWriteStream(dest);
61
+
62
+ const request = https.get(url, (response) => {
63
+ // Handle redirects
64
+ if (response.statusCode === 302 || response.statusCode === 301) {
65
+ file.close();
66
+ fs.unlinkSync(dest);
67
+ return downloadFile(response.headers.location, dest).then(resolve).catch(reject);
68
+ }
69
+
70
+ if (response.statusCode !== 200) {
71
+ file.close();
72
+ fs.unlinkSync(dest);
73
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
74
+ return;
75
+ }
76
+
77
+ response.pipe(file);
78
+
79
+ file.on('finish', () => {
80
+ file.close();
81
+ resolve();
82
+ });
83
+ });
84
+
85
+ request.on('error', (err) => {
86
+ fs.unlink(dest, () => {}); // Delete partial file
87
+ reject(err);
88
+ });
89
+ });
90
+ }
91
+
92
+ function extractArchive(archivePath, destDir) {
93
+ const platform = getPlatform();
94
+
95
+ if (platform === 'windows') {
96
+ // Use PowerShell to extract zip
97
+ execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`, {
98
+ stdio: 'inherit'
99
+ });
100
+ } else {
101
+ // Use tar for tar.gz
102
+ execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, {
103
+ stdio: 'inherit'
104
+ });
105
+ }
106
+ }
107
+
108
+ async function install() {
109
+ console.log('Installing Botwallet CLI...');
110
+
111
+ const binDir = path.join(__dirname, '..', 'bin');
112
+ const tmpDir = path.join(__dirname, '..', 'tmp');
113
+
114
+ // Create directories
115
+ if (!fs.existsSync(binDir)) {
116
+ fs.mkdirSync(binDir, { recursive: true });
117
+ }
118
+ if (!fs.existsSync(tmpDir)) {
119
+ fs.mkdirSync(tmpDir, { recursive: true });
120
+ }
121
+
122
+ try {
123
+ const archiveName = getArchiveName();
124
+ const archiveUrl = `${GITHUB_RELEASE_URL}/${archiveName}`;
125
+ const archivePath = path.join(tmpDir, archiveName);
126
+
127
+ console.log(`Downloading ${archiveName}...`);
128
+ await downloadFile(archiveUrl, archivePath);
129
+
130
+ console.log('Extracting...');
131
+ extractArchive(archivePath, tmpDir);
132
+
133
+ // Move binary to bin directory
134
+ const platform = getPlatform();
135
+ const srcBinary = path.join(tmpDir, platform === 'windows' ? 'botwallet.exe' : 'botwallet');
136
+ const destBinary = path.join(binDir, platform === 'windows' ? 'botwallet.exe' : 'botwallet');
137
+
138
+ // Handle case where binary is inside the archive with full name
139
+ if (!fs.existsSync(srcBinary)) {
140
+ const binaryName = getBinaryName();
141
+ const altSrcBinary = path.join(tmpDir, binaryName);
142
+ if (fs.existsSync(altSrcBinary)) {
143
+ fs.renameSync(altSrcBinary, destBinary);
144
+ } else {
145
+ throw new Error(`Binary not found in archive: ${srcBinary} or ${altSrcBinary}`);
146
+ }
147
+ } else {
148
+ fs.renameSync(srcBinary, destBinary);
149
+ }
150
+
151
+ // Make executable on Unix
152
+ if (platform !== 'windows') {
153
+ fs.chmodSync(destBinary, 0o755);
154
+ }
155
+
156
+ // Clean up
157
+ fs.rmSync(tmpDir, { recursive: true });
158
+
159
+ console.log('Botwallet CLI installed successfully!');
160
+ console.log('Run "botwallet --help" to get started.');
161
+
162
+ } catch (error) {
163
+ console.error('Installation failed:', error.message);
164
+ console.error('');
165
+ console.error('You can manually download the binary from:');
166
+ console.error(`https://github.com/botwallet-co/agent-cli/releases/tag/v${PACKAGE_VERSION}`);
167
+ process.exit(1);
168
+ }
169
+ }
170
+
171
+ // Run installation
172
+ install();
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+