clawcloud 1.0.0
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 +178 -0
- package/bin/clawcloud.js +158 -0
- package/package.json +57 -0
- package/src/api/agents.js +22 -0
- package/src/api/vms.js +23 -0
- package/src/api/wallet.js +21 -0
- package/src/commands/balance.js +27 -0
- package/src/commands/buy.js +8 -0
- package/src/commands/configure.js +86 -0
- package/src/commands/export.js +203 -0
- package/src/commands/fund.js +13 -0
- package/src/commands/interactive.js +70 -0
- package/src/commands/list.js +87 -0
- package/src/commands/nfts.js +5 -0
- package/src/commands/register.js +72 -0
- package/src/commands/ssh.js +5 -0
- package/src/commands/status.js +5 -0
- package/src/commands/terminate.js +5 -0
- package/src/commands/transfer.js +5 -0
- package/src/utils/banner.js +9 -0
- package/src/utils/config.js +75 -0
- package/src/utils/help.js +85 -0
- package/src/utils/version.js +15 -0
- package/templates/SKILL.md +215 -0
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# ClawCloud CLI
|
|
2
|
+
|
|
3
|
+
☁️ **Cloud infrastructure AI agents can own**
|
|
4
|
+
|
|
5
|
+
Command-line interface for managing ClawCloud - autonomous cloud VMs purchased with crypto, owned as NFTs.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx clawcloud
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Use with npx (recommended)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx clawcloud register
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Install globally
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g clawcloud
|
|
25
|
+
clawcloud register
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Getting Started
|
|
29
|
+
|
|
30
|
+
### 1. Register Your Agent
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx clawcloud register
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You'll get an Agent ID like `agent_1738445234_k9x2m`
|
|
37
|
+
|
|
38
|
+
### 2. Get Your Wallet (Telegram)
|
|
39
|
+
|
|
40
|
+
Open Telegram and message [@clawcloud_devbot](https://t.me/clawcloud_devbot):
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
/start agent_1738445234_k9x2m
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The bot will:
|
|
47
|
+
- Verify your agent ID
|
|
48
|
+
- Create a wallet
|
|
49
|
+
- Send you the private key
|
|
50
|
+
- Provide funding instructions
|
|
51
|
+
|
|
52
|
+
### 3. Configure CLI
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx clawcloud configure
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Enter your Agent ID and private key from Telegram.
|
|
59
|
+
|
|
60
|
+
### 4. Make Your Agent Autonomous
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx clawcloud export
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Choose your framework:
|
|
67
|
+
- **OpenClaw / Clawd / Molt** - Installs skill automatically
|
|
68
|
+
- **Node.js SDK** - Exports config for custom agents
|
|
69
|
+
- **Python SDK** - Coming soon
|
|
70
|
+
- **Environment Variables** - For any language
|
|
71
|
+
|
|
72
|
+
## Commands
|
|
73
|
+
|
|
74
|
+
### Setup
|
|
75
|
+
- `npx clawcloud` - Interactive menu
|
|
76
|
+
- `npx clawcloud register` - Register new agent
|
|
77
|
+
- `npx clawcloud configure` - Link wallet after Telegram
|
|
78
|
+
- `npx clawcloud fund` - Show funding instructions
|
|
79
|
+
|
|
80
|
+
### Autonomous Mode
|
|
81
|
+
- `npx clawcloud export` - Export for autonomous agents
|
|
82
|
+
- `npx clawcloud export --framework openclaw` - Install OpenClaw skill
|
|
83
|
+
|
|
84
|
+
### Wallet & Balance
|
|
85
|
+
- `npx clawcloud balance` - Check USDC balance
|
|
86
|
+
|
|
87
|
+
### VMs & NFTs
|
|
88
|
+
- `npx clawcloud list` - List your VMs and NFTs
|
|
89
|
+
- `npx clawcloud status <nft-id>` - View NFT/VM details
|
|
90
|
+
- `npx clawcloud ssh <nft-id>` - SSH into VM
|
|
91
|
+
- `npx clawcloud transfer <nft-id>` - Transfer NFT/VM ownership
|
|
92
|
+
- `npx clawcloud terminate <nft-id>` - Destroy VM & burn NFT
|
|
93
|
+
|
|
94
|
+
### Help
|
|
95
|
+
- `npx clawcloud help` - Detailed help
|
|
96
|
+
- `npx clawcloud docs` - Open documentation
|
|
97
|
+
|
|
98
|
+
## Autonomous Agent Example
|
|
99
|
+
|
|
100
|
+
After running `npx clawcloud export`, your agent can:
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
import ClawCloud from '@clawcloud/sdk';
|
|
104
|
+
|
|
105
|
+
const cloud = new ClawCloud({
|
|
106
|
+
configPath: '~/.clawcloud/autonomous-config.json'
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Agent decides: "I need to run a backtest"
|
|
110
|
+
const balance = await cloud.wallet.balance();
|
|
111
|
+
|
|
112
|
+
if (balance > 10) {
|
|
113
|
+
// Purchase VM autonomously
|
|
114
|
+
const vm = await cloud.vms.purchase({
|
|
115
|
+
tier: 'SMALL',
|
|
116
|
+
months: 1
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Wait for provisioning
|
|
120
|
+
await vm.waitReady();
|
|
121
|
+
|
|
122
|
+
// Deploy code
|
|
123
|
+
await vm.deployCode('./my-strategy');
|
|
124
|
+
|
|
125
|
+
// Run task
|
|
126
|
+
await vm.execute('npm run backtest');
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## NFTs
|
|
131
|
+
|
|
132
|
+
When you purchase a VM:
|
|
133
|
+
- An ERC-721 NFT is minted to your wallet
|
|
134
|
+
- NFT token ID = VM identifier
|
|
135
|
+
- Own the NFT = Own the VM
|
|
136
|
+
- Transfer NFT = Transfer VM ownership
|
|
137
|
+
|
|
138
|
+
View your NFTs on [OpenSea](https://opensea.io) or [BaseScan](https://basescan.org).
|
|
139
|
+
|
|
140
|
+
## Features
|
|
141
|
+
|
|
142
|
+
- 🤖 **Autonomous**: Agents purchase VMs on their own
|
|
143
|
+
- 🎨 **NFT-Based**: VMs are owned as ERC-721 tokens
|
|
144
|
+
- ⛓️ **Base Blockchain**: Fast, cheap transactions
|
|
145
|
+
- ☁️ **Multi-Cloud**: GCP, AWS, private servers
|
|
146
|
+
- 💰 **Pay-as-you-go**: Starting at $0.08/hour
|
|
147
|
+
- 🔐 **Non-Custodial**: You control your keys
|
|
148
|
+
|
|
149
|
+
## Requirements
|
|
150
|
+
|
|
151
|
+
- Node.js >= 18.0.0
|
|
152
|
+
- USDC on Base blockchain
|
|
153
|
+
- Telegram account (for wallet setup)
|
|
154
|
+
|
|
155
|
+
## Configuration
|
|
156
|
+
|
|
157
|
+
Config stored in `~/.clawcloud/`:
|
|
158
|
+
- `agents.json` - Registered agents
|
|
159
|
+
- `wallet.json` - Wallet configuration (secure!)
|
|
160
|
+
- `config.json` - API endpoints and settings
|
|
161
|
+
|
|
162
|
+
## Links
|
|
163
|
+
|
|
164
|
+
- **Website**: https://clawcloud.co
|
|
165
|
+
- **Docs**: https://docs.clawcloud.co
|
|
166
|
+
- **Telegram**: https://t.me/clawcloud_devbot
|
|
167
|
+
- **GitHub**: https://github.com/clawcloud/clawcloud
|
|
168
|
+
- **Twitter**: https://twitter.com/clawcloudx
|
|
169
|
+
|
|
170
|
+
## Support
|
|
171
|
+
|
|
172
|
+
- 💬 Telegram: https://t.me/clawcloud
|
|
173
|
+
- 🐛 Issues: https://github.com/clawcloud/clawcloud/issues
|
|
174
|
+
- 📧 Email: support@clawcloud.co
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT © ClawCloud
|
package/bin/clawcloud.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { register } from '../src/commands/register.js';
|
|
6
|
+
import { configure } from '../src/commands/configure.js';
|
|
7
|
+
import { exportConfig } from '../src/commands/export.js';
|
|
8
|
+
import { balance } from '../src/commands/balance.js';
|
|
9
|
+
import { buy } from '../src/commands/buy.js';
|
|
10
|
+
import { list } from '../src/commands/list.js';
|
|
11
|
+
import { status } from '../src/commands/status.js';
|
|
12
|
+
import { ssh } from '../src/commands/ssh.js';
|
|
13
|
+
import { transfer } from '../src/commands/transfer.js';
|
|
14
|
+
import { terminate } from '../src/commands/terminate.js';
|
|
15
|
+
import { fund } from '../src/commands/fund.js';
|
|
16
|
+
import { nfts } from '../src/commands/nfts.js';
|
|
17
|
+
import { interactive } from '../src/commands/interactive.js';
|
|
18
|
+
import { displayHelp } from '../src/utils/help.js';
|
|
19
|
+
import { getVersion } from '../src/utils/version.js';
|
|
20
|
+
|
|
21
|
+
const version = getVersion();
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.name('clawcloud')
|
|
25
|
+
.description('☁️ Cloud infrastructure AI agents can own')
|
|
26
|
+
.version(version, '-v, --version', 'Output the current version');
|
|
27
|
+
|
|
28
|
+
// Interactive mode (default when no command)
|
|
29
|
+
program
|
|
30
|
+
.action(() => {
|
|
31
|
+
interactive();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Registration & Setup
|
|
35
|
+
program
|
|
36
|
+
.command('register')
|
|
37
|
+
.description('Register a new AI agent')
|
|
38
|
+
.action(register);
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command('configure')
|
|
42
|
+
.description('Configure agent wallet after Telegram setup')
|
|
43
|
+
.action(configure);
|
|
44
|
+
|
|
45
|
+
program
|
|
46
|
+
.command('fund')
|
|
47
|
+
.description('Show funding instructions')
|
|
48
|
+
.action(fund);
|
|
49
|
+
|
|
50
|
+
// Autonomous Mode (Primary)
|
|
51
|
+
program
|
|
52
|
+
.command('export')
|
|
53
|
+
.description('Export configuration for autonomous agents')
|
|
54
|
+
.option('-f, --framework <type>', 'Agent framework (openclaw, nodejs, python, env)', 'openclaw')
|
|
55
|
+
.option('-o, --output <path>', 'Output path')
|
|
56
|
+
.action(exportConfig);
|
|
57
|
+
|
|
58
|
+
// Wallet & Balance
|
|
59
|
+
program
|
|
60
|
+
.command('balance')
|
|
61
|
+
.alias('bal')
|
|
62
|
+
.description('Check USDC balance')
|
|
63
|
+
.option('--json', 'Output as JSON')
|
|
64
|
+
.action(balance);
|
|
65
|
+
|
|
66
|
+
// NFT/VM Management
|
|
67
|
+
program
|
|
68
|
+
.command('list')
|
|
69
|
+
.alias('ls')
|
|
70
|
+
.description('List your VMs and NFTs')
|
|
71
|
+
.option('--json', 'Output as JSON')
|
|
72
|
+
.action(list);
|
|
73
|
+
|
|
74
|
+
program
|
|
75
|
+
.command('nfts')
|
|
76
|
+
.description('View your NFT collection')
|
|
77
|
+
.action(nfts);
|
|
78
|
+
|
|
79
|
+
program
|
|
80
|
+
.command('status <nft-id>')
|
|
81
|
+
.description('View NFT and VM details')
|
|
82
|
+
.option('--json', 'Output as JSON')
|
|
83
|
+
.action(status);
|
|
84
|
+
|
|
85
|
+
program
|
|
86
|
+
.command('buy')
|
|
87
|
+
.description('Purchase a VM (manual mode)')
|
|
88
|
+
.option('-t, --tier <tier>', 'VM tier (MICRO, SMALL, MEDIUM, LARGE, XLARGE)')
|
|
89
|
+
.option('-m, --months <months>', 'Duration in months (1-12)')
|
|
90
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
91
|
+
.action(buy);
|
|
92
|
+
|
|
93
|
+
program
|
|
94
|
+
.command('renew <nft-id>')
|
|
95
|
+
.description('Renew/extend a VM')
|
|
96
|
+
.option('-m, --months <months>', 'Additional months')
|
|
97
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
98
|
+
.action((nftId, options) => {
|
|
99
|
+
console.log(chalk.yellow('Renew feature coming soon!'));
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
program
|
|
103
|
+
.command('ssh <nft-id>')
|
|
104
|
+
.description('SSH into a VM')
|
|
105
|
+
.action(ssh);
|
|
106
|
+
|
|
107
|
+
program
|
|
108
|
+
.command('transfer <nft-id>')
|
|
109
|
+
.description('Transfer NFT/VM to another address')
|
|
110
|
+
.option('-t, --to <address>', 'Recipient address')
|
|
111
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
112
|
+
.action(transfer);
|
|
113
|
+
|
|
114
|
+
program
|
|
115
|
+
.command('terminate <nft-id>')
|
|
116
|
+
.alias('destroy')
|
|
117
|
+
.description('Destroy VM and burn NFT')
|
|
118
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
119
|
+
.action(terminate);
|
|
120
|
+
|
|
121
|
+
// Documentation & Help
|
|
122
|
+
program
|
|
123
|
+
.command('docs')
|
|
124
|
+
.description('Open documentation in browser')
|
|
125
|
+
.action(() => {
|
|
126
|
+
const { exec } = require('child_process');
|
|
127
|
+
exec('open https://docs.clawcloud.co');
|
|
128
|
+
console.log(chalk.blue('📖 Opening documentation...'));
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
program
|
|
132
|
+
.command('help')
|
|
133
|
+
.description('Display detailed help')
|
|
134
|
+
.action(displayHelp);
|
|
135
|
+
|
|
136
|
+
// Hidden dev commands
|
|
137
|
+
program
|
|
138
|
+
.command('contract')
|
|
139
|
+
.description('Show contract addresses')
|
|
140
|
+
.option('--testnet', 'Show testnet contracts')
|
|
141
|
+
.action((options) => {
|
|
142
|
+
const { getConfig } = require('../src/utils/config.js');
|
|
143
|
+
const config = getConfig();
|
|
144
|
+
console.log(chalk.cyan('\n📝 Contract Addresses:\n'));
|
|
145
|
+
if (options.testnet) {
|
|
146
|
+
console.log(chalk.gray('Base Sepolia:'), '0x...');
|
|
147
|
+
} else {
|
|
148
|
+
console.log(chalk.gray('Base Mainnet:'), config.CONTRACT_ADDRESS || 'Not configured');
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Parse arguments
|
|
153
|
+
program.parse(process.argv);
|
|
154
|
+
|
|
155
|
+
// Show help if no command provided
|
|
156
|
+
if (!process.argv.slice(2).length) {
|
|
157
|
+
interactive();
|
|
158
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clawcloud",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "☁️ Cloud infrastructure AI agents can own - CLI tool",
|
|
5
|
+
"main": "bin/clawcloud.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"clawcloud": "./bin/clawcloud.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Tests coming soon\"",
|
|
12
|
+
"prepublishOnly": "chmod +x bin/clawcloud.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"ai",
|
|
16
|
+
"agents",
|
|
17
|
+
"cloud",
|
|
18
|
+
"vm",
|
|
19
|
+
"infrastructure",
|
|
20
|
+
"autonomous",
|
|
21
|
+
"blockchain",
|
|
22
|
+
"base",
|
|
23
|
+
"nft",
|
|
24
|
+
"openclaw",
|
|
25
|
+
"depin"
|
|
26
|
+
],
|
|
27
|
+
"author": "ClawCloud",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/clawcloud/clawcloud.git",
|
|
32
|
+
"directory": "cli"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://clawcloud.co",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/clawcloud/clawcloud/issues"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"boxen": "^7.1.1",
|
|
43
|
+
"chalk": "^5.3.0",
|
|
44
|
+
"cli-table3": "^0.6.3",
|
|
45
|
+
"commander": "^11.1.0",
|
|
46
|
+
"ethers": "^6.10.0",
|
|
47
|
+
"inquirer": "^9.2.12",
|
|
48
|
+
"ora": "^7.0.1"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"bin/",
|
|
52
|
+
"src/",
|
|
53
|
+
"templates/",
|
|
54
|
+
"README.md",
|
|
55
|
+
"LICENSE"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getConfig } from '../utils/config.js';
|
|
2
|
+
|
|
3
|
+
export async function registerAgent(name, description) {
|
|
4
|
+
const config = getConfig();
|
|
5
|
+
|
|
6
|
+
// TODO: Replace with real API call
|
|
7
|
+
// const response = await fetch(`${config.API_URL}/agents/register`, {
|
|
8
|
+
// method: 'POST',
|
|
9
|
+
// headers: { 'Content-Type': 'application/json' },
|
|
10
|
+
// body: JSON.stringify({ name, description })
|
|
11
|
+
// });
|
|
12
|
+
|
|
13
|
+
// Mock response for now
|
|
14
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
agent_id: `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
18
|
+
name,
|
|
19
|
+
description,
|
|
20
|
+
created_at: new Date().toISOString()
|
|
21
|
+
};
|
|
22
|
+
}
|
package/src/api/vms.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getConfig } from '../utils/config.js';
|
|
2
|
+
|
|
3
|
+
export async function getVMs(address) {
|
|
4
|
+
const config = getConfig();
|
|
5
|
+
|
|
6
|
+
// TODO: Replace with real API call
|
|
7
|
+
// const response = await fetch(`${config.API_URL}/vms?address=${address}`);
|
|
8
|
+
|
|
9
|
+
// Mock response for now
|
|
10
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
11
|
+
|
|
12
|
+
return [
|
|
13
|
+
// Example: NFT #42, SMALL tier, active
|
|
14
|
+
// {
|
|
15
|
+
// nft_id: 42,
|
|
16
|
+
// tier: 'SMALL',
|
|
17
|
+
// status: 'active',
|
|
18
|
+
// ip_address: '34.123.45.67',
|
|
19
|
+
// expires_at: '2026-02-28',
|
|
20
|
+
// expires_in_days: 28
|
|
21
|
+
// }
|
|
22
|
+
];
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { getConfig } from '../utils/config.js';
|
|
3
|
+
|
|
4
|
+
export async function getBalance(address) {
|
|
5
|
+
const config = getConfig();
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const provider = new ethers.JsonRpcProvider(config.RPC_URL);
|
|
9
|
+
const usdcContract = new ethers.Contract(
|
|
10
|
+
config.USDC_ADDRESS,
|
|
11
|
+
['function balanceOf(address) view returns (uint256)'],
|
|
12
|
+
provider
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const balance = await usdcContract.balanceOf(address);
|
|
16
|
+
return ethers.formatUnits(balance, 6); // USDC has 6 decimals
|
|
17
|
+
} catch (error) {
|
|
18
|
+
// Fallback for development
|
|
19
|
+
return '0.00';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { getWalletConfig } from '../utils/config.js';
|
|
4
|
+
import { getBalance } from '../api/wallet.js';
|
|
5
|
+
|
|
6
|
+
export async function balance(options = {}) {
|
|
7
|
+
const wallet = getWalletConfig();
|
|
8
|
+
|
|
9
|
+
if (!wallet) {
|
|
10
|
+
console.log(chalk.red('\n❌ No wallet configured!\n'));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const spinner = ora('Checking balance...').start();
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const bal = await getBalance(wallet.address);
|
|
18
|
+
spinner.succeed(`Balance: ${chalk.yellow(bal)} USDC`);
|
|
19
|
+
|
|
20
|
+
if (options.json) {
|
|
21
|
+
console.log(JSON.stringify({ balance: bal, currency: 'USDC' }));
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
spinner.fail('Failed to check balance');
|
|
25
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export async function buy(options = {}) {
|
|
3
|
+
console.log(chalk.yellow('\n⚠️ Manual Purchase Mode\n'));
|
|
4
|
+
console.log(chalk.white('Note: ClawCloud is designed for AUTONOMOUS agents.'));
|
|
5
|
+
console.log(chalk.white(' Your agent can purchase VMs on its own!\n'));
|
|
6
|
+
console.log(chalk.cyan('Run: npx clawcloud export\n'));
|
|
7
|
+
console.log(chalk.gray('Manual purchase coming soon...\n'));
|
|
8
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import boxen from 'boxen';
|
|
5
|
+
import { ethers } from 'ethers';
|
|
6
|
+
import { saveWallet, getAgent } from '../utils/config.js';
|
|
7
|
+
import { getBalance } from '../api/wallet.js';
|
|
8
|
+
|
|
9
|
+
export async function configure() {
|
|
10
|
+
console.log(chalk.cyan.bold('\n🔐 Configure Agent Wallet\n'));
|
|
11
|
+
|
|
12
|
+
const answers = await inquirer.prompt([
|
|
13
|
+
{
|
|
14
|
+
type: 'input',
|
|
15
|
+
name: 'agentId',
|
|
16
|
+
message: 'Agent ID:',
|
|
17
|
+
validate: (input) => input.startsWith('agent_') || 'Invalid agent ID format'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'password',
|
|
21
|
+
name: 'privateKey',
|
|
22
|
+
message: 'Private Key (from Telegram bot):',
|
|
23
|
+
validate: (input) => {
|
|
24
|
+
try {
|
|
25
|
+
new ethers.Wallet(input);
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return 'Invalid private key';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const spinner = ora('Verifying...').start();
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
// Create wallet from private key
|
|
38
|
+
const wallet = new ethers.Wallet(answers.privateKey);
|
|
39
|
+
const address = wallet.address;
|
|
40
|
+
|
|
41
|
+
// Get agent info
|
|
42
|
+
const agent = getAgent(answers.agentId);
|
|
43
|
+
|
|
44
|
+
if (!agent) {
|
|
45
|
+
spinner.fail('Agent not found');
|
|
46
|
+
console.log(chalk.yellow(`\n⚠️ Agent ID not found locally. Did you run 'npx clawcloud register'?\n`));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Save wallet configuration
|
|
51
|
+
saveWallet(answers.agentId, answers.privateKey, address);
|
|
52
|
+
|
|
53
|
+
// Check balance
|
|
54
|
+
const balance = await getBalance(address);
|
|
55
|
+
|
|
56
|
+
spinner.succeed('Agent Configured!');
|
|
57
|
+
|
|
58
|
+
console.log(boxen(
|
|
59
|
+
chalk.bold.white(`Agent: ${chalk.cyan(agent.name)}\n`) +
|
|
60
|
+
chalk.white(`Wallet: ${chalk.green(address)}\n`) +
|
|
61
|
+
chalk.white(`Balance: ${chalk.yellow(balance)} USDC\n`) +
|
|
62
|
+
chalk.white(`Network: ${chalk.blue('Base')}\n\n`) +
|
|
63
|
+
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
|
|
64
|
+
(balance === '0.00' ?
|
|
65
|
+
chalk.white.bold('💰 Fund your agent:\n') +
|
|
66
|
+
chalk.blue(` https://clawcloud.co/fund/${answers.agentId}\n\n`) :
|
|
67
|
+
chalk.green.bold('✅ Agent is funded and ready!\n\n')
|
|
68
|
+
) +
|
|
69
|
+
chalk.white('Next steps:\n') +
|
|
70
|
+
chalk.cyan(' npx clawcloud balance') + chalk.gray(' - Check USDC balance\n') +
|
|
71
|
+
chalk.cyan(' npx clawcloud export') + chalk.gray(' - Enable autonomous mode'),
|
|
72
|
+
{
|
|
73
|
+
padding: 1,
|
|
74
|
+
margin: 1,
|
|
75
|
+
borderStyle: 'round',
|
|
76
|
+
borderColor: 'green'
|
|
77
|
+
}
|
|
78
|
+
));
|
|
79
|
+
|
|
80
|
+
console.log(chalk.gray(`\n🔒 Wallet saved securely to: ~/.clawcloud/wallet.json\n`));
|
|
81
|
+
|
|
82
|
+
} catch (error) {
|
|
83
|
+
spinner.fail('Configuration failed');
|
|
84
|
+
console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
|
|
85
|
+
}
|
|
86
|
+
}
|