agentvault 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/.dfx/local/network-id +4 -0
- package/.next/trace +2 -0
- package/.vercel/README.txt +11 -0
- package/.vercel/project.json +1 -0
- package/AGENTS.md +43 -0
- package/CHANGELOG.md +196 -0
- package/LICENSE +21 -0
- package/PLAN_VAULT_INTEGRATION.md +318 -0
- package/README.md +253 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-28-967Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-29-032Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-373Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-428Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-132Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-247Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-216Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-283Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-772Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-793Z.json +28 -0
- package/backups/test-backup.json +28 -0
- package/dist/cli/commands/approve.d.ts +4 -0
- package/dist/cli/commands/approve.js +232 -0
- package/dist/cli/commands/archive.d.ts +4 -0
- package/dist/cli/commands/archive.js +192 -0
- package/dist/cli/commands/backup.d.ts +4 -0
- package/dist/cli/commands/backup.js +164 -0
- package/dist/cli/commands/cloud-backup.d.ts +4 -0
- package/dist/cli/commands/cloud-backup.js +221 -0
- package/dist/cli/commands/cycles.d.ts +8 -0
- package/dist/cli/commands/cycles.js +83 -0
- package/dist/cli/commands/decrypt.d.ts +16 -0
- package/dist/cli/commands/decrypt.js +101 -0
- package/dist/cli/commands/deploy.d.ts +32 -0
- package/dist/cli/commands/deploy.js +208 -0
- package/dist/cli/commands/exec.d.ts +26 -0
- package/dist/cli/commands/exec.js +109 -0
- package/dist/cli/commands/fetch.d.ts +23 -0
- package/dist/cli/commands/fetch.js +164 -0
- package/dist/cli/commands/health.d.ts +8 -0
- package/dist/cli/commands/health.js +72 -0
- package/dist/cli/commands/identity.d.ts +8 -0
- package/dist/cli/commands/identity.js +140 -0
- package/dist/cli/commands/inference.d.ts +4 -0
- package/dist/cli/commands/inference.js +225 -0
- package/dist/cli/commands/info.d.ts +8 -0
- package/dist/cli/commands/info.js +59 -0
- package/dist/cli/commands/init.d.ts +19 -0
- package/dist/cli/commands/init.js +135 -0
- package/dist/cli/commands/instrument.d.ts +8 -0
- package/dist/cli/commands/instrument.js +35 -0
- package/dist/cli/commands/list.d.ts +36 -0
- package/dist/cli/commands/list.js +173 -0
- package/dist/cli/commands/logs.d.ts +8 -0
- package/dist/cli/commands/logs.js +96 -0
- package/dist/cli/commands/monitor.d.ts +8 -0
- package/dist/cli/commands/monitor.js +84 -0
- package/dist/cli/commands/network.d.ts +14 -0
- package/dist/cli/commands/network.js +258 -0
- package/dist/cli/commands/package.d.ts +36 -0
- package/dist/cli/commands/package.js +188 -0
- package/dist/cli/commands/profile.d.ts +8 -0
- package/dist/cli/commands/profile.js +76 -0
- package/dist/cli/commands/promote.d.ts +8 -0
- package/dist/cli/commands/promote.js +89 -0
- package/dist/cli/commands/rebuild.d.ts +21 -0
- package/dist/cli/commands/rebuild.js +140 -0
- package/dist/cli/commands/rollback.d.ts +8 -0
- package/dist/cli/commands/rollback.js +120 -0
- package/dist/cli/commands/show.d.ts +36 -0
- package/dist/cli/commands/show.js +200 -0
- package/dist/cli/commands/stats.d.ts +8 -0
- package/dist/cli/commands/stats.js +34 -0
- package/dist/cli/commands/status.d.ts +14 -0
- package/dist/cli/commands/status.js +83 -0
- package/dist/cli/commands/test.d.ts +8 -0
- package/dist/cli/commands/test.js +109 -0
- package/dist/cli/commands/tokens.d.ts +8 -0
- package/dist/cli/commands/tokens.js +62 -0
- package/dist/cli/commands/trace.d.ts +8 -0
- package/dist/cli/commands/trace.js +68 -0
- package/dist/cli/commands/wallet-export.d.ts +13 -0
- package/dist/cli/commands/wallet-export.js +140 -0
- package/dist/cli/commands/wallet-history.d.ts +10 -0
- package/dist/cli/commands/wallet-history.js +127 -0
- package/dist/cli/commands/wallet-import.d.ts +10 -0
- package/dist/cli/commands/wallet-import.js +209 -0
- package/dist/cli/commands/wallet-multi-send.d.ts +17 -0
- package/dist/cli/commands/wallet-multi-send.js +195 -0
- package/dist/cli/commands/wallet-process-queue.d.ts +19 -0
- package/dist/cli/commands/wallet-process-queue.js +209 -0
- package/dist/cli/commands/wallet-sign.d.ts +13 -0
- package/dist/cli/commands/wallet-sign.js +207 -0
- package/dist/cli/commands/wallet.d.ts +12 -0
- package/dist/cli/commands/wallet.js +794 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.js +96 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.js +14 -0
- package/fixup_1_0_OSS_release.md +136 -0
- package/fixup_REALEASE_PRD.md +136 -0
- package/package.json +79 -0
- package/pnpm-workspace.yaml +5 -0
- package/scripts/dev-dashboard.mjs +84 -0
- package/site/README.md +63 -0
- package/site/docusaurus.config.ts +148 -0
- package/site/package-lock.json +18383 -0
- package/site/package.json +47 -0
- package/site/sidebars.ts +86 -0
- package/site/static/.gitkeep +0 -0
- package/site/static/img/logo.svg +28 -0
- package/site/static/img/og-image.svg +35 -0
- package/src/archival/archive-manager.ts +372 -0
- package/src/archival/arweave-client.ts +289 -0
- package/src/archival/index.ts +8 -0
- package/src/backup/backup.ts +315 -0
- package/src/backup/index.ts +7 -0
- package/src/cloud-storage/cloud-sync.ts +461 -0
- package/src/cloud-storage/index.ts +11 -0
- package/src/cloud-storage/provider-detector.ts +198 -0
- package/src/cloud-storage/types.ts +104 -0
- package/src/debugging/index.ts +6 -0
- package/src/debugging/logs.ts +193 -0
- package/src/debugging/types.ts +100 -0
- package/src/deployment/deployer.ts +274 -0
- package/src/deployment/icpClient.ts +620 -0
- package/src/deployment/index.ts +46 -0
- package/src/deployment/promotion.ts +161 -0
- package/src/deployment/types.ts +111 -0
- package/src/icp/batch.ts +374 -0
- package/src/icp/cycles.ts +50 -0
- package/src/icp/environment.ts +215 -0
- package/src/icp/icpcli.ts +438 -0
- package/src/icp/icwasm.ts +222 -0
- package/src/icp/identity.ts +77 -0
- package/src/icp/index.ts +94 -0
- package/src/icp/optimization.ts +242 -0
- package/src/icp/tokens.ts +36 -0
- package/src/icp/tool-detector.ts +110 -0
- package/src/icp/types.ts +574 -0
- package/src/index.ts +25 -0
- package/src/inference/bittensor-client.ts +304 -0
- package/src/inference/index.ts +8 -0
- package/src/inference/inference-manager.ts +327 -0
- package/src/metrics/index.ts +7 -0
- package/src/metrics/metrics.ts +186 -0
- package/src/monitoring/alerting.ts +190 -0
- package/src/monitoring/health.ts +197 -0
- package/src/monitoring/index.ts +38 -0
- package/src/monitoring/info.ts +114 -0
- package/src/monitoring/types.ts +99 -0
- package/src/network/index.ts +5 -0
- package/src/network/network-config.ts +129 -0
- package/src/packaging/compiler.ts +647 -0
- package/src/packaging/config-persistence.ts +135 -0
- package/src/packaging/config-schemas.ts +156 -0
- package/src/packaging/detector.ts +220 -0
- package/src/packaging/index.ts +90 -0
- package/src/packaging/packager.ts +118 -0
- package/src/packaging/parsers/clawdbot.ts +278 -0
- package/src/packaging/parsers/cline.ts +223 -0
- package/src/packaging/parsers/generic.ts +266 -0
- package/src/packaging/parsers/goose.ts +214 -0
- package/src/packaging/parsers/index.ts +11 -0
- package/src/packaging/serializer.ts +260 -0
- package/src/packaging/types.ts +144 -0
- package/src/packaging/wasmedge-compiler.ts +406 -0
- package/src/security/index.ts +17 -0
- package/src/security/multisig.ts +415 -0
- package/src/security/types.ts +416 -0
- package/src/security/vetkeys.ts +655 -0
- package/src/testing/index.ts +6 -0
- package/src/testing/local-runner.ts +264 -0
- package/src/testing/types.ts +104 -0
- package/src/wallet/cbor-serializer.ts +323 -0
- package/src/wallet/chain-dispatcher.ts +313 -0
- package/src/wallet/cross-chain-aggregator.ts +346 -0
- package/src/wallet/index.ts +76 -0
- package/src/wallet/key-derivation.ts +425 -0
- package/src/wallet/providers/base-provider.ts +154 -0
- package/src/wallet/providers/cketh-provider.ts +434 -0
- package/src/wallet/providers/polkadot-provider.ts +503 -0
- package/src/wallet/providers/solana-provider.ts +490 -0
- package/src/wallet/transaction-queue.ts +284 -0
- package/src/wallet/types.ts +178 -0
- package/src/wallet/vetkeys-adapter.ts +431 -0
- package/src/wallet/wallet-manager.ts +597 -0
- package/src/wallet/wallet-storage.ts +380 -0
- package/vercel.json +8 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet Export Command
|
|
3
|
+
*
|
|
4
|
+
* Export all wallets for an agent to a backup file.
|
|
5
|
+
*/
|
|
6
|
+
import { listAgentWallets, getWallet } from '../../src/wallet/index.js';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import * as crypto from 'node:crypto';
|
|
13
|
+
/**
|
|
14
|
+
* Create backup directory
|
|
15
|
+
*/
|
|
16
|
+
function ensureBackupDir() {
|
|
17
|
+
const backupDir = path.join(process.cwd(), 'backups');
|
|
18
|
+
if (!fs.existsSync(backupDir)) {
|
|
19
|
+
fs.mkdirSync(backupDir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
return backupDir;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate backup filename
|
|
25
|
+
*/
|
|
26
|
+
function generateBackupFilename(agentId, format) {
|
|
27
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
28
|
+
const ext = format === 'encrypted' ? 'backup' : 'json';
|
|
29
|
+
return `soulrecall-backup-${agentId}-${timestamp}.${ext}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Display wallet summary
|
|
33
|
+
*/
|
|
34
|
+
function displayWalletSummary(wallets) {
|
|
35
|
+
console.log();
|
|
36
|
+
console.log(chalk.cyan('Wallets to export:'));
|
|
37
|
+
for (const wallet of wallets) {
|
|
38
|
+
console.log(` - ${wallet.chain.toUpperCase()}: ${wallet.address}`);
|
|
39
|
+
}
|
|
40
|
+
console.log(` Total: ${wallets.length} wallet(s)`);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Encrypt data with password
|
|
44
|
+
*/
|
|
45
|
+
function encryptData(data, password) {
|
|
46
|
+
const salt = crypto.randomBytes(16);
|
|
47
|
+
const iv = crypto.randomBytes(16);
|
|
48
|
+
const key = crypto.pbkdf2Sync(password, salt, 100000, 32, 'sha256');
|
|
49
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
|
|
50
|
+
let encrypted = cipher.update(data, 'utf8', 'hex');
|
|
51
|
+
encrypted += cipher.final('hex');
|
|
52
|
+
const authTag = cipher.getAuthTag();
|
|
53
|
+
const encryptedWithAuth = `${encrypted}.${authTag.toString('hex')}`;
|
|
54
|
+
return {
|
|
55
|
+
encrypted: encryptedWithAuth,
|
|
56
|
+
iv: iv.toString('hex'),
|
|
57
|
+
salt: salt.toString('hex'),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handle wallet export command
|
|
62
|
+
*/
|
|
63
|
+
export async function handleExport(agentId, options = {}) {
|
|
64
|
+
console.log(chalk.bold('\nš¦ Export Wallets\n'));
|
|
65
|
+
const walletIds = listAgentWallets(agentId);
|
|
66
|
+
if (walletIds.length === 0) {
|
|
67
|
+
console.log(chalk.yellow('No wallets found for this agent'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const wallets = walletIds.map(id => getWallet(agentId, id)).filter(Boolean);
|
|
71
|
+
displayWalletSummary(wallets);
|
|
72
|
+
const { format } = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: 'list',
|
|
75
|
+
name: 'format',
|
|
76
|
+
message: 'Select export format:',
|
|
77
|
+
choices: [
|
|
78
|
+
{ name: 'JSON (plain text, easy to read)', value: 'json' },
|
|
79
|
+
{ name: 'Encrypted (password-protected)', value: 'encrypted' },
|
|
80
|
+
],
|
|
81
|
+
default: options.format || 'json',
|
|
82
|
+
},
|
|
83
|
+
]);
|
|
84
|
+
const backupDir = ensureBackupDir();
|
|
85
|
+
const filename = options.output || generateBackupFilename(agentId, format);
|
|
86
|
+
const filepath = path.join(backupDir, filename);
|
|
87
|
+
const { confirm } = await inquirer.prompt([
|
|
88
|
+
{
|
|
89
|
+
type: 'confirm',
|
|
90
|
+
name: 'confirm',
|
|
91
|
+
message: `Export ${wallets.length} wallet(s) to ${filepath}?`,
|
|
92
|
+
default: true,
|
|
93
|
+
},
|
|
94
|
+
]);
|
|
95
|
+
if (!confirm) {
|
|
96
|
+
console.log(chalk.yellow('\nExport cancelled'));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const spinner = ora('Exporting wallets...').start();
|
|
100
|
+
try {
|
|
101
|
+
const backup = {
|
|
102
|
+
version: '1.0',
|
|
103
|
+
agentId,
|
|
104
|
+
exportedAt: Date.now(),
|
|
105
|
+
format,
|
|
106
|
+
wallets,
|
|
107
|
+
};
|
|
108
|
+
let data = JSON.stringify(backup, null, 2);
|
|
109
|
+
if (format === 'encrypted') {
|
|
110
|
+
const { password } = await inquirer.prompt([
|
|
111
|
+
{
|
|
112
|
+
type: 'password',
|
|
113
|
+
name: 'password',
|
|
114
|
+
message: 'Enter encryption password:',
|
|
115
|
+
validate: (input) => input.length >= 8,
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
const { encrypted, iv, salt } = encryptData(data, password);
|
|
119
|
+
backup.encrypted = true;
|
|
120
|
+
backup.iv = iv;
|
|
121
|
+
backup.salt = salt;
|
|
122
|
+
data = JSON.stringify(backup, null, 2);
|
|
123
|
+
data = JSON.stringify({ encrypted });
|
|
124
|
+
}
|
|
125
|
+
fs.writeFileSync(filepath, data, 'utf-8');
|
|
126
|
+
spinner.succeed('Wallets exported successfully');
|
|
127
|
+
console.log();
|
|
128
|
+
console.log(chalk.green('ā'), `Export saved to: ${filepath}`);
|
|
129
|
+
console.log(` Size: ${(data.length / 1024).toFixed(2)} KB`);
|
|
130
|
+
if (format === 'json') {
|
|
131
|
+
console.log();
|
|
132
|
+
console.log(chalk.yellow('ā '), 'This file contains private keys - keep it secure!');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
137
|
+
spinner.fail(`Failed to export wallets: ${message}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=wallet-export.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet History Command
|
|
3
|
+
*
|
|
4
|
+
* Display transaction history for a wallet.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Handle wallet history command
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleHistory(agentId: string, json?: boolean): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=wallet-history.d.ts.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet History Command
|
|
3
|
+
*
|
|
4
|
+
* Display transaction history for a wallet.
|
|
5
|
+
*/
|
|
6
|
+
import { CkEthProvider } from '../../src/wallet/providers/cketh-provider.js';
|
|
7
|
+
import { PolkadotProvider } from '../../src/wallet/providers/polkadot-provider.js';
|
|
8
|
+
import { SolanaProvider } from '../../src/wallet/providers/solana-provider.js';
|
|
9
|
+
import { getWallet, listAgentWallets } from '../../src/wallet/index.js';
|
|
10
|
+
import inquirer from 'inquirer';
|
|
11
|
+
import ora from 'ora';
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
/**
|
|
14
|
+
* Format address for display
|
|
15
|
+
*/
|
|
16
|
+
function formatAddress(address, length = 8) {
|
|
17
|
+
if (address.length <= length * 2)
|
|
18
|
+
return address;
|
|
19
|
+
return `${address.slice(0, length)}...${address.slice(-length)}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get status color
|
|
23
|
+
*/
|
|
24
|
+
function getStatusColor(status) {
|
|
25
|
+
switch (status) {
|
|
26
|
+
case 'confirmed':
|
|
27
|
+
return chalk.green(status);
|
|
28
|
+
case 'pending':
|
|
29
|
+
return chalk.yellow(status);
|
|
30
|
+
case 'failed':
|
|
31
|
+
return chalk.red(status);
|
|
32
|
+
default:
|
|
33
|
+
return chalk.white(status);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create provider for chain
|
|
38
|
+
*/
|
|
39
|
+
function createProvider(chain) {
|
|
40
|
+
switch (chain) {
|
|
41
|
+
case 'cketh':
|
|
42
|
+
return new CkEthProvider({
|
|
43
|
+
chain: 'cketh',
|
|
44
|
+
rpcUrl: CkEthProvider.getDefaultRpcUrl(),
|
|
45
|
+
isTestnet: false,
|
|
46
|
+
});
|
|
47
|
+
case 'polkadot':
|
|
48
|
+
return new PolkadotProvider({
|
|
49
|
+
chain: 'polkadot',
|
|
50
|
+
rpcUrl: 'wss://rpc.polkadot.io',
|
|
51
|
+
isTestnet: false,
|
|
52
|
+
});
|
|
53
|
+
case 'solana':
|
|
54
|
+
return new SolanaProvider({
|
|
55
|
+
chain: 'solana',
|
|
56
|
+
rpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
57
|
+
isTestnet: false,
|
|
58
|
+
});
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Unsupported chain: ${chain}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Display transaction history
|
|
65
|
+
*/
|
|
66
|
+
function displayTransactions(transactions) {
|
|
67
|
+
if (transactions.length === 0) {
|
|
68
|
+
console.log(chalk.yellow('No transactions found'));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.log();
|
|
72
|
+
console.log(chalk.cyan(`Transaction History (${transactions.length} transactions):\n`));
|
|
73
|
+
const table = [];
|
|
74
|
+
for (const tx of transactions) {
|
|
75
|
+
table.push({
|
|
76
|
+
Hash: formatAddress(tx.hash),
|
|
77
|
+
From: formatAddress(tx.from),
|
|
78
|
+
To: formatAddress(tx.to),
|
|
79
|
+
Amount: `${tx.amount}`,
|
|
80
|
+
Status: getStatusColor(tx.status),
|
|
81
|
+
Fee: tx.fee || 'N/A',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
console.table(table);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Handle wallet history command
|
|
88
|
+
*/
|
|
89
|
+
export async function handleHistory(agentId, json = false) {
|
|
90
|
+
console.log(chalk.bold('\nš Wallet History\n'));
|
|
91
|
+
const wallets = listAgentWallets(agentId);
|
|
92
|
+
if (wallets.length === 0) {
|
|
93
|
+
console.log(chalk.yellow('No wallets found for this agent'));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const { walletId } = await inquirer.prompt([
|
|
97
|
+
{
|
|
98
|
+
type: 'list',
|
|
99
|
+
name: 'walletId',
|
|
100
|
+
message: 'Select wallet:',
|
|
101
|
+
choices: wallets,
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
const wallet = getWallet(agentId, walletId);
|
|
105
|
+
if (!wallet) {
|
|
106
|
+
console.log(chalk.red('Wallet not found'));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const spinner = ora('Fetching transaction history...').start();
|
|
110
|
+
try {
|
|
111
|
+
const provider = createProvider(wallet.chain);
|
|
112
|
+
await provider.connect();
|
|
113
|
+
const transactions = await provider.getTransactionHistory(wallet.address);
|
|
114
|
+
spinner.succeed('Transaction history fetched');
|
|
115
|
+
if (json) {
|
|
116
|
+
console.log(JSON.stringify(transactions, null, 2));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
displayTransactions(transactions);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
124
|
+
spinner.fail(`Failed to fetch history: ${message}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=wallet-history.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet Import Command
|
|
3
|
+
*
|
|
4
|
+
* Import wallets from an exported backup file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Handle wallet import command
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleImport(agentId: string, filePath: string): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=wallet-import.d.ts.map
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet Import Command
|
|
3
|
+
*
|
|
4
|
+
* Import wallets from an exported backup file.
|
|
5
|
+
*/
|
|
6
|
+
import { importWalletFromPrivateKey, importWalletFromSeed } from '../../src/wallet/index.js';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as crypto from 'node:crypto';
|
|
12
|
+
/**
|
|
13
|
+
* Decrypt data with password
|
|
14
|
+
*/
|
|
15
|
+
function decryptData(encryptedData, password, ivHex, saltHex) {
|
|
16
|
+
const iv = Buffer.from(ivHex || '', 'hex');
|
|
17
|
+
const salt = Buffer.from(saltHex || '', 'hex');
|
|
18
|
+
const key = crypto.pbkdf2Sync(password, salt, 100000, 32, 'sha256');
|
|
19
|
+
const [encrypted, authTagHex] = encryptedData.split('.');
|
|
20
|
+
const authTag = Buffer.from(authTagHex || '', 'hex');
|
|
21
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
|
|
22
|
+
decipher.setAuthTag(authTag);
|
|
23
|
+
let decrypted = decipher.update(encrypted || '', 'hex', 'utf8');
|
|
24
|
+
decrypted += decipher.final('utf8');
|
|
25
|
+
return decrypted;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load backup file
|
|
29
|
+
*/
|
|
30
|
+
function loadBackupFile(filepath) {
|
|
31
|
+
if (!fs.existsSync(filepath)) {
|
|
32
|
+
throw new Error(`Backup file not found: ${filepath}`);
|
|
33
|
+
}
|
|
34
|
+
const data = fs.readFileSync(filepath, 'utf-8');
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(data);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new Error('Invalid backup file format');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Decrypt backup if needed
|
|
44
|
+
*/
|
|
45
|
+
async function loadBackup(filepath) {
|
|
46
|
+
const loaded = loadBackupFile(filepath);
|
|
47
|
+
if (loaded.encrypted && loaded.iv && loaded.salt && loaded.encrypted) {
|
|
48
|
+
const encryptedData = loaded.encrypted;
|
|
49
|
+
const { password } = await inquirer.prompt([
|
|
50
|
+
{
|
|
51
|
+
type: 'password',
|
|
52
|
+
name: 'password',
|
|
53
|
+
message: 'Enter decryption password:',
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
try {
|
|
57
|
+
const decrypted = decryptData(encryptedData, password, loaded.iv, loaded.salt);
|
|
58
|
+
return JSON.parse(decrypted);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new Error('Failed to decrypt backup - incorrect password or corrupted file');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return loaded;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate backup structure
|
|
68
|
+
*/
|
|
69
|
+
function validateBackup(backup) {
|
|
70
|
+
if (!backup.version || !backup.agentId || !backup.wallets || !Array.isArray(backup.wallets)) {
|
|
71
|
+
throw new Error('Invalid backup structure');
|
|
72
|
+
}
|
|
73
|
+
if (backup.wallets.length === 0) {
|
|
74
|
+
throw new Error('Backup contains no wallets');
|
|
75
|
+
}
|
|
76
|
+
for (const wallet of backup.wallets) {
|
|
77
|
+
if (!wallet.id || !wallet.chain || !wallet.address) {
|
|
78
|
+
throw new Error('Invalid wallet data in backup');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Display backup summary
|
|
84
|
+
*/
|
|
85
|
+
function displayBackupSummary(backup) {
|
|
86
|
+
console.log();
|
|
87
|
+
console.log(chalk.cyan('Backup Summary:'));
|
|
88
|
+
console.log(` Version: ${backup.version}`);
|
|
89
|
+
console.log(` Agent ID: ${backup.agentId}`);
|
|
90
|
+
console.log(` Exported: ${new Date(backup.exportedAt).toISOString()}`);
|
|
91
|
+
console.log(` Format: ${backup.format}`);
|
|
92
|
+
console.log(` Wallets: ${backup.wallets.length}`);
|
|
93
|
+
console.log();
|
|
94
|
+
console.log(chalk.cyan('Wallets:'));
|
|
95
|
+
for (const wallet of backup.wallets) {
|
|
96
|
+
console.log(` - ${wallet.chain.toUpperCase()}: ${wallet.address}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Import wallet from backup
|
|
101
|
+
*/
|
|
102
|
+
async function importWallet(wallet, agentId, resolution) {
|
|
103
|
+
try {
|
|
104
|
+
if (wallet.privateKey) {
|
|
105
|
+
importWalletFromPrivateKey(agentId, wallet.chain, wallet.privateKey);
|
|
106
|
+
}
|
|
107
|
+
else if (wallet.mnemonic) {
|
|
108
|
+
importWalletFromSeed(agentId, wallet.chain, wallet.mnemonic, wallet.seedDerivationPath);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.log(chalk.yellow(`ā Skipping ${wallet.id}: No private key or mnemonic`));
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (error.message?.includes('already exists')) {
|
|
118
|
+
if (resolution === 'skip') {
|
|
119
|
+
console.log(chalk.yellow(`ā Skipping ${wallet.id}: Already exists`));
|
|
120
|
+
}
|
|
121
|
+
else if (resolution === 'overwrite') {
|
|
122
|
+
console.log(chalk.yellow(`ā Overwriting ${wallet.id}`));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log(chalk.red(`ā Failed to import ${wallet.id}: ${error.message}`));
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Handle wallet import command
|
|
133
|
+
*/
|
|
134
|
+
export async function handleImport(agentId, filePath) {
|
|
135
|
+
console.log(chalk.bold('\nš„ Import Wallets\n'));
|
|
136
|
+
if (!filePath) {
|
|
137
|
+
const { path: inputPath } = await inquirer.prompt([
|
|
138
|
+
{
|
|
139
|
+
type: 'input',
|
|
140
|
+
name: 'path',
|
|
141
|
+
message: 'Path to backup file:',
|
|
142
|
+
validate: (input) => input.length > 0,
|
|
143
|
+
},
|
|
144
|
+
]);
|
|
145
|
+
filePath = inputPath;
|
|
146
|
+
}
|
|
147
|
+
const spinner = ora('Loading backup file...').start();
|
|
148
|
+
try {
|
|
149
|
+
const backup = await loadBackup(filePath);
|
|
150
|
+
validateBackup(backup);
|
|
151
|
+
spinner.succeed('Backup loaded');
|
|
152
|
+
displayBackupSummary(backup);
|
|
153
|
+
const { confirm } = await inquirer.prompt([
|
|
154
|
+
{
|
|
155
|
+
type: 'confirm',
|
|
156
|
+
name: 'confirm',
|
|
157
|
+
message: `Import ${backup.wallets.length} wallet(s) to agent ${agentId}?`,
|
|
158
|
+
default: false,
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
if (!confirm) {
|
|
162
|
+
console.log(chalk.yellow('\nImport cancelled'));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const { resolution } = await inquirer.prompt([
|
|
166
|
+
{
|
|
167
|
+
type: 'list',
|
|
168
|
+
name: 'resolution',
|
|
169
|
+
message: 'How to handle existing wallets?',
|
|
170
|
+
choices: [
|
|
171
|
+
{ name: 'Skip existing wallets', value: 'skip' },
|
|
172
|
+
{ name: 'Overwrite existing wallets', value: 'overwrite' },
|
|
173
|
+
{ name: 'Rename with suffix', value: 'rename' },
|
|
174
|
+
],
|
|
175
|
+
default: 'skip',
|
|
176
|
+
},
|
|
177
|
+
]);
|
|
178
|
+
console.log();
|
|
179
|
+
console.log(chalk.cyan('Importing wallets...'));
|
|
180
|
+
let successCount = 0;
|
|
181
|
+
const skipCount = 0;
|
|
182
|
+
let failCount = 0;
|
|
183
|
+
for (const wallet of backup.wallets) {
|
|
184
|
+
const result = await importWallet(wallet, agentId, resolution);
|
|
185
|
+
if (result) {
|
|
186
|
+
successCount++;
|
|
187
|
+
console.log(chalk.green(`ā Imported: ${wallet.id} (${wallet.chain})`));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
failCount++;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
console.log();
|
|
194
|
+
console.log(chalk.cyan('Import Summary:'));
|
|
195
|
+
console.log(` ā Successful: ${successCount}`);
|
|
196
|
+
console.log(` ā Skipped: ${skipCount}`);
|
|
197
|
+
console.log(` ā Failed: ${failCount}`);
|
|
198
|
+
if (successCount > 0) {
|
|
199
|
+
console.log();
|
|
200
|
+
console.log(chalk.green('ā'), 'Wallets imported successfully');
|
|
201
|
+
console.log(chalk.yellow('ā '), 'Keep your backup file secure until you verify all wallets work correctly');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
206
|
+
spinner.fail(`Failed to import wallets: ${message}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=wallet-import.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet Multi-Send Command
|
|
3
|
+
*
|
|
4
|
+
* CLI command to send transactions across multiple chains in parallel.
|
|
5
|
+
* Part of Phase 5C: Cross-Chain Actions.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Handle multi-send command
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleMultiSend(agentId: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Export handler for use by wallet.ts
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleMultiSendWithArgs(args: {
|
|
15
|
+
agentId: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=wallet-multi-send.d.ts.map
|