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.
@@ -0,0 +1,203 @@
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
+ }
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,70 @@
1
+ import inquirer from 'inquirer';
2
+ import chalk from 'chalk';
3
+ import { register } from './register.js';
4
+ import { configure } from './configure.js';
5
+ import { exportConfig } from './export.js';
6
+ import { buy } from './buy.js';
7
+ import { balance } from './balance.js';
8
+ import { list } from './list.js';
9
+ import { fund } from './fund.js';
10
+ import { displayHelp } from '../utils/help.js';
11
+ import { displayBanner } from '../utils/banner.js';
12
+
13
+ export async function interactive() {
14
+ displayBanner();
15
+
16
+ const { action } = await inquirer.prompt([
17
+ {
18
+ type: 'list',
19
+ name: 'action',
20
+ message: 'What would you like to do?',
21
+ choices: [
22
+ { name: '🤖 Register New Agent', value: 'register' },
23
+ { name: '🔐 Configure Agent (after Telegram)', value: 'configure' },
24
+ { name: '🚀 Export for Autonomous Use', value: 'export' },
25
+ new inquirer.Separator(),
26
+ { name: '💰 Check Balance', value: 'balance' },
27
+ { name: '💸 Fund Agent', value: 'fund' },
28
+ { name: '🛒 Purchase VM (Manual)', value: 'buy' },
29
+ { name: '📋 List VMs & NFTs', value: 'list' },
30
+ new inquirer.Separator(),
31
+ { name: '📖 View Documentation', value: 'docs' },
32
+ { name: '❓ Help', value: 'help' },
33
+ { name: '🚪 Exit', value: 'exit' }
34
+ ]
35
+ }
36
+ ]);
37
+
38
+ switch (action) {
39
+ case 'register':
40
+ await register();
41
+ break;
42
+ case 'configure':
43
+ await configure();
44
+ break;
45
+ case 'export':
46
+ await exportConfig();
47
+ break;
48
+ case 'balance':
49
+ await balance();
50
+ break;
51
+ case 'fund':
52
+ await fund();
53
+ break;
54
+ case 'buy':
55
+ await buy();
56
+ break;
57
+ case 'list':
58
+ await list();
59
+ break;
60
+ case 'docs':
61
+ console.log(chalk.blue('\n📖 Documentation: https://docs.clawcloud.co\n'));
62
+ break;
63
+ case 'help':
64
+ displayHelp();
65
+ break;
66
+ case 'exit':
67
+ console.log(chalk.gray('\n👋 Goodbye!\n'));
68
+ process.exit(0);
69
+ }
70
+ }
@@ -0,0 +1,87 @@
1
+ import chalk from 'chalk';
2
+ import Table from 'cli-table3';
3
+ import ora from 'ora';
4
+ import { getWalletConfig } from '../utils/config.js';
5
+ import { getVMs } from '../api/vms.js';
6
+
7
+ export async function list(options = {}) {
8
+ const wallet = getWalletConfig();
9
+
10
+ if (!wallet) {
11
+ console.log(chalk.red('\n❌ No wallet configured!\n'));
12
+ console.log(chalk.yellow('Run: npx clawcloud configure\n'));
13
+ return;
14
+ }
15
+
16
+ const spinner = ora('Fetching your VMs and NFTs...').start();
17
+
18
+ try {
19
+ const vms = await getVMs(wallet.address);
20
+
21
+ spinner.stop();
22
+
23
+ if (options.json) {
24
+ console.log(JSON.stringify(vms, null, 2));
25
+ return;
26
+ }
27
+
28
+ console.log(chalk.cyan.bold('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
29
+ console.log(chalk.cyan.bold(' YOUR AGENT\'S INFRASTRUCTURE'));
30
+ console.log(chalk.cyan.bold('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
31
+
32
+ console.log(chalk.white(`🤖 Agent: ${chalk.cyan(wallet.agentId)}`));
33
+ console.log(chalk.white(`💰 Balance: ${chalk.yellow('...')} USDC`));
34
+ console.log(chalk.white(`🎨 NFTs Owned: ${chalk.green(vms.length)}\n`));
35
+
36
+ if (vms.length === 0) {
37
+ console.log(chalk.yellow('No VMs yet. Purchase one:\n'));
38
+ console.log(chalk.cyan(' npx clawcloud buy\n'));
39
+ return;
40
+ }
41
+
42
+ const table = new Table({
43
+ head: [
44
+ chalk.white('NFT'),
45
+ chalk.white('Tier'),
46
+ chalk.white('Status'),
47
+ chalk.white('IP Address'),
48
+ chalk.white('Expires')
49
+ ],
50
+ style: {
51
+ head: [],
52
+ border: ['gray']
53
+ }
54
+ });
55
+
56
+ vms.forEach(vm => {
57
+ const statusColor = vm.status === 'active' ? chalk.green :
58
+ vm.status === 'provisioning' ? chalk.yellow :
59
+ chalk.red;
60
+
61
+ const expiresIn = vm.expires_in_days > 0 ?
62
+ `${vm.expires_in_days} days` :
63
+ chalk.red('Expired');
64
+
65
+ table.push([
66
+ chalk.cyan(`#${vm.nft_id}`),
67
+ vm.tier,
68
+ statusColor(vm.status),
69
+ vm.ip_address || chalk.gray('provisioning...'),
70
+ expiresIn
71
+ ]);
72
+ });
73
+
74
+ console.log(table.toString());
75
+
76
+ console.log(chalk.gray('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
77
+ console.log(chalk.white('Commands:'));
78
+ console.log(chalk.cyan(' npx clawcloud status <nft-id>') + chalk.gray(' - View details'));
79
+ console.log(chalk.cyan(' npx clawcloud ssh <nft-id>') + chalk.gray(' - Connect'));
80
+ console.log(chalk.cyan(' npx clawcloud renew <nft-id>') + chalk.gray(' - Extend'));
81
+ console.log(chalk.gray('\n'));
82
+
83
+ } catch (error) {
84
+ spinner.fail('Failed to fetch VMs');
85
+ console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
86
+ }
87
+ }
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+ export async function nfts() {
3
+ console.log(chalk.cyan('\n🎨 Your NFT Collection\n'));
4
+ console.log(chalk.yellow('Coming soon!\n'));
5
+ }
@@ -0,0 +1,72 @@
1
+ import inquirer from 'inquirer';
2
+ import chalk from 'chalk';
3
+ import ora from 'ora';
4
+ import boxen from 'boxen';
5
+ import { saveAgent } from '../utils/config.js';
6
+ import { registerAgent } from '../api/agents.js';
7
+
8
+ export async function register() {
9
+ console.log(chalk.cyan.bold('\n🤖 Register AI Agent\n'));
10
+
11
+ const answers = await inquirer.prompt([
12
+ {
13
+ type: 'input',
14
+ name: 'name',
15
+ message: 'Agent name:',
16
+ validate: (input) => input.length > 0 || 'Name is required'
17
+ },
18
+ {
19
+ type: 'input',
20
+ name: 'description',
21
+ message: 'Description:',
22
+ validate: (input) => input.length > 0 || 'Description is required'
23
+ }
24
+ ]);
25
+
26
+ const spinner = ora('Registering agent...').start();
27
+
28
+ try {
29
+ // Call API to register agent
30
+ const result = await registerAgent(answers.name, answers.description);
31
+
32
+ spinner.succeed('Agent Registered!');
33
+
34
+ // Save agent ID locally
35
+ saveAgent({
36
+ agentId: result.agent_id,
37
+ name: answers.name,
38
+ description: answers.description,
39
+ createdAt: result.created_at
40
+ });
41
+
42
+ // Display next steps
43
+ console.log(boxen(
44
+ chalk.bold.white(`Agent ID: ${chalk.cyan(result.agent_id)}\n\n`) +
45
+ chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
46
+ chalk.white.bold('📱 NEXT STEP: Get Your Wallet\n\n') +
47
+ chalk.white(`1. Open Telegram: ${chalk.blue('https://t.me/clawcloud_devbot')}\n\n`) +
48
+ chalk.white(`2. Send this command:\n ${chalk.green(`/start ${result.agent_id}`)}\n\n`) +
49
+ chalk.white('3. Bot will verify your agent and create a wallet\n\n') +
50
+ chalk.white('4. You\'ll receive:\n') +
51
+ chalk.gray(' • Wallet address\n') +
52
+ chalk.gray(' • Private key (keep secure!)\n') +
53
+ chalk.gray(' • Funding instructions\n\n') +
54
+ chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n') +
55
+ chalk.white('After Telegram setup, run:\n') +
56
+ chalk.cyan(' npx clawcloud configure') + chalk.gray(' - Link wallet to CLI\n') +
57
+ chalk.cyan(' npx clawcloud export') + chalk.gray(' - Make agent autonomous'),
58
+ {
59
+ padding: 1,
60
+ margin: 1,
61
+ borderStyle: 'round',
62
+ borderColor: 'cyan'
63
+ }
64
+ ));
65
+
66
+ console.log(chalk.gray(`\nAgent ID saved to: ~/.clawcloud/agents.json\n`));
67
+
68
+ } catch (error) {
69
+ spinner.fail('Registration failed');
70
+ console.error(chalk.red(`\n❌ Error: ${error.message}\n`));
71
+ }
72
+ }
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+ export async function ssh(nftId) {
3
+ console.log(chalk.gray(`\nConnecting to VM (NFT #${nftId})...\n`));
4
+ console.log(chalk.yellow('Coming soon!\n'));
5
+ }
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+ export async function status(nftId, options = {}) {
3
+ console.log(chalk.gray(`\nFetching NFT #${nftId} details...\n`));
4
+ console.log(chalk.yellow('Coming soon!\n'));
5
+ }
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+ export async function terminate(nftId, options = {}) {
3
+ console.log(chalk.gray(`\nTerminating VM (NFT #${nftId})...\n`));
4
+ console.log(chalk.yellow('Coming soon!\n'));
5
+ }
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+ export async function transfer(nftId, options = {}) {
3
+ console.log(chalk.gray(`\nTransferring NFT #${nftId}...\n`));
4
+ console.log(chalk.yellow('Coming soon!\n'));
5
+ }
@@ -0,0 +1,9 @@
1
+ import chalk from 'chalk';
2
+ import { getVersion } from './version.js';
3
+
4
+ export function displayBanner() {
5
+ const version = getVersion();
6
+
7
+ console.log(chalk.cyan('\n ☁️ ClawCloud CLI ') + chalk.gray(`v${version}`));
8
+ console.log(chalk.gray(' Cloud infrastructure AI agents can own\n'));
9
+ }
@@ -0,0 +1,75 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+
5
+ const CONFIG_DIR = path.join(os.homedir(), '.clawcloud');
6
+ const AGENTS_FILE = path.join(CONFIG_DIR, 'agents.json');
7
+ const WALLET_FILE = path.join(CONFIG_DIR, 'wallet.json');
8
+ const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
9
+
10
+ // Ensure config directory exists
11
+ if (!fs.existsSync(CONFIG_DIR)) {
12
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
13
+ }
14
+
15
+ export function saveAgent(agentData) {
16
+ let agents = {};
17
+
18
+ if (fs.existsSync(AGENTS_FILE)) {
19
+ agents = JSON.parse(fs.readFileSync(AGENTS_FILE, 'utf-8'));
20
+ }
21
+
22
+ agents[agentData.agentId] = agentData;
23
+ fs.writeFileSync(AGENTS_FILE, JSON.stringify(agents, null, 2));
24
+ }
25
+
26
+ export function getAgent(agentId) {
27
+ if (!fs.existsSync(AGENTS_FILE)) {
28
+ return null;
29
+ }
30
+
31
+ const agents = JSON.parse(fs.readFileSync(AGENTS_FILE, 'utf-8'));
32
+ return agents[agentId] || null;
33
+ }
34
+
35
+ export function saveWallet(agentId, privateKey, address) {
36
+ const walletData = {
37
+ agentId,
38
+ privateKey,
39
+ address,
40
+ network: 'base',
41
+ configuredAt: new Date().toISOString()
42
+ };
43
+
44
+ fs.writeFileSync(WALLET_FILE, JSON.stringify(walletData, null, 2));
45
+ fs.chmodSync(WALLET_FILE, 0o600); // Secure permissions
46
+ }
47
+
48
+ export function getWalletConfig() {
49
+ if (!fs.existsSync(WALLET_FILE)) {
50
+ return null;
51
+ }
52
+
53
+ return JSON.parse(fs.readFileSync(WALLET_FILE, 'utf-8'));
54
+ }
55
+
56
+ export function getConfig() {
57
+ const defaultConfig = {
58
+ API_URL: 'https://api.clawcloud.co/v1',
59
+ CONTRACT_ADDRESS: '0x...', // TODO: Update with real contract
60
+ USDC_ADDRESS: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
61
+ RPC_URL: 'https://mainnet.base.org',
62
+ TELEGRAM_BOT: 'clawcloud_devbot'
63
+ };
64
+
65
+ if (!fs.existsSync(CONFIG_FILE)) {
66
+ return defaultConfig;
67
+ }
68
+
69
+ const userConfig = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
70
+ return { ...defaultConfig, ...userConfig };
71
+ }
72
+
73
+ export function saveConfig(config) {
74
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
75
+ }
@@ -0,0 +1,85 @@
1
+ import chalk from 'chalk';
2
+ import boxen from 'boxen';
3
+
4
+ export function displayHelp() {
5
+ console.log(chalk.cyan.bold('\n☁️ ClawCloud CLI - Complete Guide\n'));
6
+
7
+ console.log(boxen(
8
+ chalk.white.bold('GETTING STARTED\n\n') +
9
+ chalk.cyan('1. Register Agent:\n') +
10
+ chalk.gray(' npx clawcloud register\n\n') +
11
+ chalk.cyan('2. Get Wallet (Telegram):\n') +
12
+ chalk.gray(' https://t.me/clawcloud_devbot\n') +
13
+ chalk.gray(' /start <agent-id>\n\n') +
14
+ chalk.cyan('3. Configure CLI:\n') +
15
+ chalk.gray(' npx clawcloud configure\n\n') +
16
+ chalk.cyan('4. Make Agent Autonomous:\n') +
17
+ chalk.gray(' npx clawcloud export'),
18
+ {
19
+ padding: 1,
20
+ margin: 1,
21
+ borderStyle: 'round',
22
+ borderColor: 'cyan'
23
+ }
24
+ ));
25
+
26
+ console.log(chalk.white.bold('\n📚 COMMANDS\n'));
27
+
28
+ const commands = [
29
+ ['Setup & Configuration', ''],
30
+ [' register', 'Register a new AI agent'],
31
+ [' configure', 'Link wallet after Telegram setup'],
32
+ [' fund', 'Show funding instructions'],
33
+ ['', ''],
34
+ ['Autonomous Mode (Primary)', ''],
35
+ [' export', 'Export config for autonomous agents'],
36
+ ['', ''],
37
+ ['Wallet & Balance', ''],
38
+ [' balance, bal', 'Check USDC balance'],
39
+ ['', ''],
40
+ ['NFT & VM Management', ''],
41
+ [' list, ls', 'List your VMs and NFTs'],
42
+ [' nfts', 'View NFT collection'],
43
+ [' status <nft-id>', 'View NFT/VM details'],
44
+ [' buy', 'Purchase VM (manual mode)'],
45
+ [' renew <nft-id>', 'Extend VM duration'],
46
+ [' ssh <nft-id>', 'SSH into VM'],
47
+ [' transfer <nft-id>', 'Transfer NFT/VM ownership'],
48
+ [' terminate <nft-id>', 'Destroy VM & burn NFT'],
49
+ ['', ''],
50
+ ['Documentation', ''],
51
+ [' docs', 'Open documentation'],
52
+ [' help', 'Show this help'],
53
+ ['', '']
54
+ ];
55
+
56
+ commands.forEach(([cmd, desc]) => {
57
+ if (cmd === '') {
58
+ console.log('');
59
+ } else if (desc === '') {
60
+ console.log(chalk.yellow.bold(cmd));
61
+ } else {
62
+ console.log(chalk.cyan(` ${cmd.padEnd(25)}`) + chalk.gray(desc));
63
+ }
64
+ });
65
+
66
+ console.log(chalk.white.bold('\n🚀 EXAMPLES\n'));
67
+
68
+ console.log(chalk.gray(' # Interactive mode'));
69
+ console.log(chalk.cyan(' npx clawcloud\n'));
70
+
71
+ console.log(chalk.gray(' # Check balance'));
72
+ console.log(chalk.cyan(' npx clawcloud balance\n'));
73
+
74
+ console.log(chalk.gray(' # List VMs'));
75
+ console.log(chalk.cyan(' npx clawcloud list\n'));
76
+
77
+ console.log(chalk.gray(' # Make agent autonomous (OpenClaw)'));
78
+ console.log(chalk.cyan(' npx clawcloud export --framework openclaw\n'));
79
+
80
+ console.log(chalk.white.bold('\n🔗 LINKS\n'));
81
+ console.log(chalk.gray(' Docs: ') + chalk.blue('https://docs.clawcloud.co'));
82
+ console.log(chalk.gray(' Telegram: ') + chalk.blue('https://t.me/clawcloud_devbot'));
83
+ console.log(chalk.gray(' GitHub: ') + chalk.blue('https://github.com/clawcloud/clawcloud'));
84
+ console.log(chalk.gray(' Website: ') + chalk.blue('https://clawcloud.co\n'));
85
+ }
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from 'fs';
2
+ import { join, dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ export function getVersion() {
8
+ try {
9
+ const packagePath = join(__dirname, '..', '..', 'package.json');
10
+ const pkg = JSON.parse(readFileSync(packagePath, 'utf-8'));
11
+ return pkg.version;
12
+ } catch {
13
+ return '1.0.0';
14
+ }
15
+ }