clawcloud 1.0.0 → 1.1.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/CLI_PUBLISHING_GUIDE.md +325 -0
- package/README.md +253 -118
- package/index.js +637 -0
- package/package.json +18 -35
- package/bin/clawcloud.js +0 -158
- package/src/api/agents.js +0 -22
- package/src/api/vms.js +0 -23
- package/src/api/wallet.js +0 -21
- package/src/commands/balance.js +0 -27
- package/src/commands/buy.js +0 -8
- package/src/commands/configure.js +0 -86
- package/src/commands/export.js +0 -203
- package/src/commands/fund.js +0 -13
- package/src/commands/interactive.js +0 -70
- package/src/commands/list.js +0 -87
- package/src/commands/nfts.js +0 -5
- package/src/commands/register.js +0 -72
- package/src/commands/ssh.js +0 -5
- package/src/commands/status.js +0 -5
- package/src/commands/terminate.js +0 -5
- package/src/commands/transfer.js +0 -5
- package/src/utils/banner.js +0 -9
- package/src/utils/config.js +0 -75
- package/src/utils/help.js +0 -85
- package/src/utils/version.js +0 -15
- package/templates/SKILL.md +0 -215
package/package.json
CHANGED
|
@@ -1,57 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawcloud",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "
|
|
6
|
-
"type": "module",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "ClawCloud CLI - Decentralized cloud infrastructure for AI agents on Base",
|
|
5
|
+
"main": "index.js",
|
|
7
6
|
"bin": {
|
|
8
|
-
"clawcloud": "./
|
|
7
|
+
"clawcloud": "./index.js"
|
|
9
8
|
},
|
|
10
9
|
"scripts": {
|
|
11
|
-
"test": "echo \"
|
|
12
|
-
"prepublishOnly": "chmod +x bin/clawcloud.js"
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
11
|
},
|
|
14
12
|
"keywords": [
|
|
15
|
-
"ai",
|
|
16
|
-
"agents",
|
|
17
|
-
"cloud",
|
|
18
|
-
"vm",
|
|
19
|
-
"infrastructure",
|
|
20
|
-
"autonomous",
|
|
21
13
|
"blockchain",
|
|
22
14
|
"base",
|
|
15
|
+
"cloud",
|
|
16
|
+
"vm",
|
|
17
|
+
"ai",
|
|
18
|
+
"agents",
|
|
19
|
+
"cryptocurrency",
|
|
23
20
|
"nft",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
21
|
+
"web3",
|
|
22
|
+
"cli"
|
|
26
23
|
],
|
|
27
24
|
"author": "ClawCloud",
|
|
28
25
|
"license": "MIT",
|
|
29
26
|
"repository": {
|
|
30
27
|
"type": "git",
|
|
31
|
-
"url": "https://github.com/clawcloud/clawcloud.git"
|
|
32
|
-
"directory": "cli"
|
|
28
|
+
"url": "https://github.com/clawcloud/clawcloud-cli.git"
|
|
33
29
|
},
|
|
34
30
|
"homepage": "https://clawcloud.co",
|
|
35
31
|
"bugs": {
|
|
36
|
-
"url": "https://github.com/clawcloud/clawcloud/issues"
|
|
37
|
-
},
|
|
38
|
-
"engines": {
|
|
39
|
-
"node": ">=18.0.0"
|
|
32
|
+
"url": "https://github.com/clawcloud/clawcloud-cli/issues"
|
|
40
33
|
},
|
|
41
34
|
"dependencies": {
|
|
42
|
-
"
|
|
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"
|
|
35
|
+
"ethers": "^6.9.0"
|
|
49
36
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"templates/",
|
|
54
|
-
"README.md",
|
|
55
|
-
"LICENSE"
|
|
56
|
-
]
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
}
|
|
57
40
|
}
|
package/bin/clawcloud.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
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/src/api/agents.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
package/src/api/wallet.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/balance.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/buy.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/export.js
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import inquirer from 'inquirer';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import boxen from 'boxen';
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import os from 'os';
|
|
8
|
-
import { getWalletConfig } from '../utils/config.js';
|
|
9
|
-
|
|
10
|
-
export async function exportConfig(options = {}) {
|
|
11
|
-
console.log(chalk.cyan.bold('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
12
|
-
console.log(chalk.cyan.bold(' AUTONOMOUS AGENT CONFIGURATION'));
|
|
13
|
-
console.log(chalk.cyan.bold('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
14
|
-
|
|
15
|
-
console.log(chalk.white('This enables your AI agent to:\n'));
|
|
16
|
-
console.log(chalk.green(' ✓ Purchase VMs autonomously'));
|
|
17
|
-
console.log(chalk.green(' ✓ Check balance and make decisions'));
|
|
18
|
-
console.log(chalk.green(' ✓ Deploy code automatically'));
|
|
19
|
-
console.log(chalk.green(' ✓ Scale compute based on needs\n'));
|
|
20
|
-
|
|
21
|
-
// Get wallet config
|
|
22
|
-
const walletConfig = getWalletConfig();
|
|
23
|
-
|
|
24
|
-
if (!walletConfig) {
|
|
25
|
-
console.log(chalk.red('❌ No wallet configured!\n'));
|
|
26
|
-
console.log(chalk.yellow('Run: npx clawcloud configure\n'));
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let framework = options.framework;
|
|
31
|
-
|
|
32
|
-
if (!framework) {
|
|
33
|
-
const { selectedFramework } = await inquirer.prompt([
|
|
34
|
-
{
|
|
35
|
-
type: 'list',
|
|
36
|
-
name: 'selectedFramework',
|
|
37
|
-
message: 'Agent framework:',
|
|
38
|
-
choices: [
|
|
39
|
-
{ name: '🦞 OpenClaw / Clawd / Molt (Skill)', value: 'openclaw' },
|
|
40
|
-
{ name: '📦 Node.js SDK', value: 'nodejs' },
|
|
41
|
-
{ name: '🐍 Python SDK', value: 'python' },
|
|
42
|
-
{ name: '🔧 Environment Variables (Generic)', value: 'env' }
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
]);
|
|
46
|
-
framework = selectedFramework;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const spinner = ora('Exporting configuration...').start();
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
switch (framework) {
|
|
53
|
-
case 'openclaw':
|
|
54
|
-
await exportOpenClaw(walletConfig, spinner);
|
|
55
|
-
break;
|
|
56
|
-
case 'nodejs':
|
|
57
|
-
await exportNodeJS(walletConfig, spinner);
|
|
58
|
-
break;
|
|
59
|
-
case 'python':
|
|
60
|
-
await exportPython(walletConfig, spinner);
|
|
61
|
-
break;
|
|
62
|
-
case 'env':
|
|
63
|
-
await exportEnv(walletConfig, spinner);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
} catch (error) {
|
|
67
|
-
spinner.fail('Export failed');
|
|
68
|
-
console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function exportOpenClaw(config, spinner) {
|
|
73
|
-
const { workspace } = await inquirer.prompt([
|
|
74
|
-
{
|
|
75
|
-
type: 'input',
|
|
76
|
-
name: 'workspace',
|
|
77
|
-
message: 'OpenClaw workspace path:',
|
|
78
|
-
default: path.join(os.homedir(), '.openclaw', 'workspace')
|
|
79
|
-
}
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
const skillPath = path.join(workspace, 'skills', 'clawcloud');
|
|
83
|
-
|
|
84
|
-
// Create skill directory
|
|
85
|
-
if (!fs.existsSync(skillPath)) {
|
|
86
|
-
fs.mkdirSync(skillPath, { recursive: true });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Copy SKILL.md template
|
|
90
|
-
const templatePath = path.join(__dirname, '..', '..', 'templates', 'SKILL.md');
|
|
91
|
-
const skillContent = fs.readFileSync(templatePath, 'utf-8')
|
|
92
|
-
.replace('{{WALLET_ADDRESS}}', config.address)
|
|
93
|
-
.replace('{{PRIVATE_KEY}}', config.privateKey)
|
|
94
|
-
.replace('{{AGENT_ID}}', config.agentId);
|
|
95
|
-
|
|
96
|
-
fs.writeFileSync(path.join(skillPath, 'SKILL.md'), skillContent);
|
|
97
|
-
|
|
98
|
-
spinner.succeed('Skill Installed!');
|
|
99
|
-
|
|
100
|
-
console.log(boxen(
|
|
101
|
-
chalk.bold.white(`Location: ${chalk.cyan(skillPath)}\n`) +
|
|
102
|
-
chalk.white(`Version: ${chalk.yellow('1.0.0')}\n\n`) +
|
|
103
|
-
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n') +
|
|
104
|
-
chalk.bold.white(' YOUR AGENT CAN NOW:\n') +
|
|
105
|
-
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
|
|
106
|
-
chalk.white('🗣️ Talk to your agent:\n\n') +
|
|
107
|
-
chalk.cyan(' "How much USDC do I have?"\n') +
|
|
108
|
-
chalk.cyan(' "Buy me a SMALL VM for 1 month"\n') +
|
|
109
|
-
chalk.cyan(' "Check my VMs"\n') +
|
|
110
|
-
chalk.cyan(' "I need more compute for backtesting"\n\n') +
|
|
111
|
-
chalk.white('🤖 The agent will:\n') +
|
|
112
|
-
chalk.gray(' • Decide when it needs compute\n') +
|
|
113
|
-
chalk.gray(' • Purchase VMs automatically\n') +
|
|
114
|
-
chalk.gray(' • Deploy code on its own\n') +
|
|
115
|
-
chalk.gray(' • Manage infrastructure 24/7\n\n') +
|
|
116
|
-
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
|
|
117
|
-
chalk.white(`View skill: ${chalk.gray(`cat ${skillPath}/SKILL.md`)}\n`) +
|
|
118
|
-
chalk.white(`Test agent: ${chalk.gray('molt chat')}`),
|
|
119
|
-
{
|
|
120
|
-
padding: 1,
|
|
121
|
-
margin: 1,
|
|
122
|
-
borderStyle: 'round',
|
|
123
|
-
borderColor: 'green'
|
|
124
|
-
}
|
|
125
|
-
));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
async function exportNodeJS(config, spinner) {
|
|
129
|
-
const configPath = path.join(os.homedir(), '.clawcloud', 'autonomous-config.json');
|
|
130
|
-
|
|
131
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
132
|
-
agentId: config.agentId,
|
|
133
|
-
walletAddress: config.address,
|
|
134
|
-
privateKey: config.privateKey,
|
|
135
|
-
network: 'base',
|
|
136
|
-
apiUrl: 'https://api.clawcloud.co/v1'
|
|
137
|
-
}, null, 2));
|
|
138
|
-
|
|
139
|
-
spinner.succeed('Configuration Exported!');
|
|
140
|
-
|
|
141
|
-
console.log(boxen(
|
|
142
|
-
chalk.bold.white(`File: ${chalk.cyan(configPath)}\n\n`) +
|
|
143
|
-
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n') +
|
|
144
|
-
chalk.bold.white(' AUTONOMOUS AGENT CODE\n') +
|
|
145
|
-
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
|
|
146
|
-
chalk.gray('import') + chalk.white(' ClawCloud ') + chalk.gray('from') + chalk.green(' \'@clawcloud/sdk\'' + chalk.white(';\n\n')) +
|
|
147
|
-
chalk.gray('const') + chalk.white(' cloud = ') + chalk.gray('new') + chalk.white(' ClawCloud({\n') +
|
|
148
|
-
chalk.white(' configPath: ') + chalk.green(`'${configPath}'`) + chalk.white('\n});\n\n') +
|
|
149
|
-
chalk.gray('// Agent checks if it needs compute\n') +
|
|
150
|
-
chalk.gray('async function') + chalk.white(' run() {\n') +
|
|
151
|
-
chalk.white(' ') + chalk.gray('const') + chalk.white(' balance = ') + chalk.gray('await') + chalk.white(' cloud.wallet.balance();\n') +
|
|
152
|
-
chalk.white(' console.log(') + chalk.green('`I have ${balance} USDC`') + chalk.white(');\n\n') +
|
|
153
|
-
chalk.white(' ') + chalk.gray('if') + chalk.white(' (needsCompute) {\n') +
|
|
154
|
-
chalk.white(' ') + chalk.gray('const') + chalk.white(' vm = ') + chalk.gray('await') + chalk.white(' cloud.vms.purchase({\n') +
|
|
155
|
-
chalk.white(' tier: ') + chalk.green('\'SMALL\'') + chalk.white(',\n') +
|
|
156
|
-
chalk.white(' months: ') + chalk.yellow('1') + chalk.white('\n') +
|
|
157
|
-
chalk.white(' });\n\n') +
|
|
158
|
-
chalk.white(' ') + chalk.gray('await') + chalk.white(' vm.waitReady();\n') +
|
|
159
|
-
chalk.white(' ') + chalk.gray('await') + chalk.white(' vm.deployCode(') + chalk.green('\'./strategy\'') + chalk.white(');\n') +
|
|
160
|
-
chalk.white(' }\n}\n\n') +
|
|
161
|
-
chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
|
|
162
|
-
chalk.white('Install SDK: ') + chalk.cyan('npm install @clawcloud/sdk\n') +
|
|
163
|
-
chalk.white('Run agent: ') + chalk.cyan('node agent.js'),
|
|
164
|
-
{
|
|
165
|
-
padding: 1,
|
|
166
|
-
margin: 1,
|
|
167
|
-
borderStyle: 'round',
|
|
168
|
-
borderColor: 'blue'
|
|
169
|
-
}
|
|
170
|
-
));
|
|
171
|
-
|
|
172
|
-
console.log(chalk.gray(`\n⚠️ Keep this file secure! Contains private key.\n`));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async function exportPython(config, spinner) {
|
|
176
|
-
spinner.info('Python SDK coming soon!');
|
|
177
|
-
console.log(chalk.yellow('\n🐍 Python SDK is under development.\n'));
|
|
178
|
-
console.log(chalk.white('For now, use:\n'));
|
|
179
|
-
console.log(chalk.cyan(' • Node.js SDK'));
|
|
180
|
-
console.log(chalk.cyan(' • Environment variables'));
|
|
181
|
-
console.log(chalk.gray('\nStar the repo to get notified: github.com/clawcloud/clawcloud\n'));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async function exportEnv(config, spinner) {
|
|
185
|
-
spinner.succeed('Environment variables exported!');
|
|
186
|
-
|
|
187
|
-
console.log(boxen(
|
|
188
|
-
chalk.white('Add these to your ') + chalk.cyan('.env') + chalk.white(' file:\n\n') +
|
|
189
|
-
chalk.gray('CLAWCLOUD_AGENT_ID') + chalk.white('=') + chalk.green(config.agentId) + chalk.white('\n') +
|
|
190
|
-
chalk.gray('CLAWCLOUD_WALLET_ADDRESS') + chalk.white('=') + chalk.green(config.address) + chalk.white('\n') +
|
|
191
|
-
chalk.gray('CLAWCLOUD_PRIVATE_KEY') + chalk.white('=') + chalk.green(config.privateKey) + chalk.white('\n') +
|
|
192
|
-
chalk.gray('CLAWCLOUD_NETWORK') + chalk.white('=') + chalk.green('base') + chalk.white('\n') +
|
|
193
|
-
chalk.gray('CLAWCLOUD_API_URL') + chalk.white('=') + chalk.green('https://api.clawcloud.co/v1'),
|
|
194
|
-
{
|
|
195
|
-
padding: 1,
|
|
196
|
-
margin: 1,
|
|
197
|
-
borderStyle: 'round',
|
|
198
|
-
borderColor: 'yellow'
|
|
199
|
-
}
|
|
200
|
-
));
|
|
201
|
-
|
|
202
|
-
console.log(chalk.gray(`\n⚠️ Never commit .env files to git!\n`));
|
|
203
|
-
}
|
package/src/commands/fund.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { getWalletConfig } from '../utils/config.js';
|
|
3
|
-
export async function fund() {
|
|
4
|
-
const wallet = getWalletConfig();
|
|
5
|
-
if (!wallet) {
|
|
6
|
-
console.log(chalk.red('\n❌ No wallet configured!\n'));
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
console.log(chalk.cyan.bold('\n💰 Fund Your Agent\n'));
|
|
10
|
-
console.log(chalk.white(`Wallet: ${chalk.green(wallet.address)}\n`));
|
|
11
|
-
console.log(chalk.white('Send USDC (Base network) to the address above.\n'));
|
|
12
|
-
console.log(chalk.blue(`Or visit: https://clawcloud.co/fund/${wallet.agentId}\n`));
|
|
13
|
-
}
|