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.
Files changed (188) hide show
  1. package/.dfx/local/network-id +4 -0
  2. package/.next/trace +2 -0
  3. package/.vercel/README.txt +11 -0
  4. package/.vercel/project.json +1 -0
  5. package/AGENTS.md +43 -0
  6. package/CHANGELOG.md +196 -0
  7. package/LICENSE +21 -0
  8. package/PLAN_VAULT_INTEGRATION.md +318 -0
  9. package/README.md +253 -0
  10. package/backups/agentvault-backup-test-agent-2026-02-12T17-54-28-967Z.json +28 -0
  11. package/backups/agentvault-backup-test-agent-2026-02-12T17-54-29-032Z.backup +1 -0
  12. package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-373Z.json +28 -0
  13. package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-428Z.backup +1 -0
  14. package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-132Z.json +28 -0
  15. package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-247Z.backup +1 -0
  16. package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-216Z.json +28 -0
  17. package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-283Z.backup +1 -0
  18. package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-772Z.backup +1 -0
  19. package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-793Z.json +28 -0
  20. package/backups/test-backup.json +28 -0
  21. package/dist/cli/commands/approve.d.ts +4 -0
  22. package/dist/cli/commands/approve.js +232 -0
  23. package/dist/cli/commands/archive.d.ts +4 -0
  24. package/dist/cli/commands/archive.js +192 -0
  25. package/dist/cli/commands/backup.d.ts +4 -0
  26. package/dist/cli/commands/backup.js +164 -0
  27. package/dist/cli/commands/cloud-backup.d.ts +4 -0
  28. package/dist/cli/commands/cloud-backup.js +221 -0
  29. package/dist/cli/commands/cycles.d.ts +8 -0
  30. package/dist/cli/commands/cycles.js +83 -0
  31. package/dist/cli/commands/decrypt.d.ts +16 -0
  32. package/dist/cli/commands/decrypt.js +101 -0
  33. package/dist/cli/commands/deploy.d.ts +32 -0
  34. package/dist/cli/commands/deploy.js +208 -0
  35. package/dist/cli/commands/exec.d.ts +26 -0
  36. package/dist/cli/commands/exec.js +109 -0
  37. package/dist/cli/commands/fetch.d.ts +23 -0
  38. package/dist/cli/commands/fetch.js +164 -0
  39. package/dist/cli/commands/health.d.ts +8 -0
  40. package/dist/cli/commands/health.js +72 -0
  41. package/dist/cli/commands/identity.d.ts +8 -0
  42. package/dist/cli/commands/identity.js +140 -0
  43. package/dist/cli/commands/inference.d.ts +4 -0
  44. package/dist/cli/commands/inference.js +225 -0
  45. package/dist/cli/commands/info.d.ts +8 -0
  46. package/dist/cli/commands/info.js +59 -0
  47. package/dist/cli/commands/init.d.ts +19 -0
  48. package/dist/cli/commands/init.js +135 -0
  49. package/dist/cli/commands/instrument.d.ts +8 -0
  50. package/dist/cli/commands/instrument.js +35 -0
  51. package/dist/cli/commands/list.d.ts +36 -0
  52. package/dist/cli/commands/list.js +173 -0
  53. package/dist/cli/commands/logs.d.ts +8 -0
  54. package/dist/cli/commands/logs.js +96 -0
  55. package/dist/cli/commands/monitor.d.ts +8 -0
  56. package/dist/cli/commands/monitor.js +84 -0
  57. package/dist/cli/commands/network.d.ts +14 -0
  58. package/dist/cli/commands/network.js +258 -0
  59. package/dist/cli/commands/package.d.ts +36 -0
  60. package/dist/cli/commands/package.js +188 -0
  61. package/dist/cli/commands/profile.d.ts +8 -0
  62. package/dist/cli/commands/profile.js +76 -0
  63. package/dist/cli/commands/promote.d.ts +8 -0
  64. package/dist/cli/commands/promote.js +89 -0
  65. package/dist/cli/commands/rebuild.d.ts +21 -0
  66. package/dist/cli/commands/rebuild.js +140 -0
  67. package/dist/cli/commands/rollback.d.ts +8 -0
  68. package/dist/cli/commands/rollback.js +120 -0
  69. package/dist/cli/commands/show.d.ts +36 -0
  70. package/dist/cli/commands/show.js +200 -0
  71. package/dist/cli/commands/stats.d.ts +8 -0
  72. package/dist/cli/commands/stats.js +34 -0
  73. package/dist/cli/commands/status.d.ts +14 -0
  74. package/dist/cli/commands/status.js +83 -0
  75. package/dist/cli/commands/test.d.ts +8 -0
  76. package/dist/cli/commands/test.js +109 -0
  77. package/dist/cli/commands/tokens.d.ts +8 -0
  78. package/dist/cli/commands/tokens.js +62 -0
  79. package/dist/cli/commands/trace.d.ts +8 -0
  80. package/dist/cli/commands/trace.js +68 -0
  81. package/dist/cli/commands/wallet-export.d.ts +13 -0
  82. package/dist/cli/commands/wallet-export.js +140 -0
  83. package/dist/cli/commands/wallet-history.d.ts +10 -0
  84. package/dist/cli/commands/wallet-history.js +127 -0
  85. package/dist/cli/commands/wallet-import.d.ts +10 -0
  86. package/dist/cli/commands/wallet-import.js +209 -0
  87. package/dist/cli/commands/wallet-multi-send.d.ts +17 -0
  88. package/dist/cli/commands/wallet-multi-send.js +195 -0
  89. package/dist/cli/commands/wallet-process-queue.d.ts +19 -0
  90. package/dist/cli/commands/wallet-process-queue.js +209 -0
  91. package/dist/cli/commands/wallet-sign.d.ts +13 -0
  92. package/dist/cli/commands/wallet-sign.js +207 -0
  93. package/dist/cli/commands/wallet.d.ts +12 -0
  94. package/dist/cli/commands/wallet.js +794 -0
  95. package/dist/cli/index.d.ts +10 -0
  96. package/dist/cli/index.js +96 -0
  97. package/dist/vitest.config.d.ts +3 -0
  98. package/dist/vitest.config.js +14 -0
  99. package/fixup_1_0_OSS_release.md +136 -0
  100. package/fixup_REALEASE_PRD.md +136 -0
  101. package/package.json +79 -0
  102. package/pnpm-workspace.yaml +5 -0
  103. package/scripts/dev-dashboard.mjs +84 -0
  104. package/site/README.md +63 -0
  105. package/site/docusaurus.config.ts +148 -0
  106. package/site/package-lock.json +18383 -0
  107. package/site/package.json +47 -0
  108. package/site/sidebars.ts +86 -0
  109. package/site/static/.gitkeep +0 -0
  110. package/site/static/img/logo.svg +28 -0
  111. package/site/static/img/og-image.svg +35 -0
  112. package/src/archival/archive-manager.ts +372 -0
  113. package/src/archival/arweave-client.ts +289 -0
  114. package/src/archival/index.ts +8 -0
  115. package/src/backup/backup.ts +315 -0
  116. package/src/backup/index.ts +7 -0
  117. package/src/cloud-storage/cloud-sync.ts +461 -0
  118. package/src/cloud-storage/index.ts +11 -0
  119. package/src/cloud-storage/provider-detector.ts +198 -0
  120. package/src/cloud-storage/types.ts +104 -0
  121. package/src/debugging/index.ts +6 -0
  122. package/src/debugging/logs.ts +193 -0
  123. package/src/debugging/types.ts +100 -0
  124. package/src/deployment/deployer.ts +274 -0
  125. package/src/deployment/icpClient.ts +620 -0
  126. package/src/deployment/index.ts +46 -0
  127. package/src/deployment/promotion.ts +161 -0
  128. package/src/deployment/types.ts +111 -0
  129. package/src/icp/batch.ts +374 -0
  130. package/src/icp/cycles.ts +50 -0
  131. package/src/icp/environment.ts +215 -0
  132. package/src/icp/icpcli.ts +438 -0
  133. package/src/icp/icwasm.ts +222 -0
  134. package/src/icp/identity.ts +77 -0
  135. package/src/icp/index.ts +94 -0
  136. package/src/icp/optimization.ts +242 -0
  137. package/src/icp/tokens.ts +36 -0
  138. package/src/icp/tool-detector.ts +110 -0
  139. package/src/icp/types.ts +574 -0
  140. package/src/index.ts +25 -0
  141. package/src/inference/bittensor-client.ts +304 -0
  142. package/src/inference/index.ts +8 -0
  143. package/src/inference/inference-manager.ts +327 -0
  144. package/src/metrics/index.ts +7 -0
  145. package/src/metrics/metrics.ts +186 -0
  146. package/src/monitoring/alerting.ts +190 -0
  147. package/src/monitoring/health.ts +197 -0
  148. package/src/monitoring/index.ts +38 -0
  149. package/src/monitoring/info.ts +114 -0
  150. package/src/monitoring/types.ts +99 -0
  151. package/src/network/index.ts +5 -0
  152. package/src/network/network-config.ts +129 -0
  153. package/src/packaging/compiler.ts +647 -0
  154. package/src/packaging/config-persistence.ts +135 -0
  155. package/src/packaging/config-schemas.ts +156 -0
  156. package/src/packaging/detector.ts +220 -0
  157. package/src/packaging/index.ts +90 -0
  158. package/src/packaging/packager.ts +118 -0
  159. package/src/packaging/parsers/clawdbot.ts +278 -0
  160. package/src/packaging/parsers/cline.ts +223 -0
  161. package/src/packaging/parsers/generic.ts +266 -0
  162. package/src/packaging/parsers/goose.ts +214 -0
  163. package/src/packaging/parsers/index.ts +11 -0
  164. package/src/packaging/serializer.ts +260 -0
  165. package/src/packaging/types.ts +144 -0
  166. package/src/packaging/wasmedge-compiler.ts +406 -0
  167. package/src/security/index.ts +17 -0
  168. package/src/security/multisig.ts +415 -0
  169. package/src/security/types.ts +416 -0
  170. package/src/security/vetkeys.ts +655 -0
  171. package/src/testing/index.ts +6 -0
  172. package/src/testing/local-runner.ts +264 -0
  173. package/src/testing/types.ts +104 -0
  174. package/src/wallet/cbor-serializer.ts +323 -0
  175. package/src/wallet/chain-dispatcher.ts +313 -0
  176. package/src/wallet/cross-chain-aggregator.ts +346 -0
  177. package/src/wallet/index.ts +76 -0
  178. package/src/wallet/key-derivation.ts +425 -0
  179. package/src/wallet/providers/base-provider.ts +154 -0
  180. package/src/wallet/providers/cketh-provider.ts +434 -0
  181. package/src/wallet/providers/polkadot-provider.ts +503 -0
  182. package/src/wallet/providers/solana-provider.ts +490 -0
  183. package/src/wallet/transaction-queue.ts +284 -0
  184. package/src/wallet/types.ts +178 -0
  185. package/src/wallet/vetkeys-adapter.ts +431 -0
  186. package/src/wallet/wallet-manager.ts +597 -0
  187. package/src/wallet/wallet-storage.ts +380 -0
  188. package/vercel.json +8 -0
@@ -0,0 +1,195 @@
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
+ import inquirer from 'inquirer';
8
+ import ora from 'ora';
9
+ import chalk from 'chalk';
10
+ import { listAgentWallets, getWallet } from '../../src/wallet/wallet-manager.js';
11
+ import { createChainDispatcher } from '../../src/wallet/chain-dispatcher.js';
12
+ import { createCrossChainAggregator } from '../../src/wallet/cross-chain-aggregator.js';
13
+ /**
14
+ * Handle multi-send command
15
+ */
16
+ export async function handleMultiSend(agentId) {
17
+ console.log(chalk.bold('\n💸 Multi-Chain Send\n'));
18
+ console.log(chalk.yellow('[Experimental] This feature is under active development and may change.\n'));
19
+ const walletIds = listAgentWallets(agentId);
20
+ if (walletIds.length === 0) {
21
+ console.log(chalk.yellow('No wallets found for this agent'));
22
+ return;
23
+ }
24
+ const wallets = [];
25
+ for (const walletId of walletIds) {
26
+ try {
27
+ const wallet = getWallet(agentId, walletId);
28
+ if (wallet) {
29
+ wallets.push(wallet);
30
+ }
31
+ }
32
+ catch (_error) {
33
+ console.log(chalk.yellow(`Failed to load wallet ${walletId}`));
34
+ }
35
+ }
36
+ if (wallets.length === 0) {
37
+ console.log(chalk.yellow('No wallets could be loaded'));
38
+ return;
39
+ }
40
+ console.log(chalk.cyan(`Found ${wallets.length} wallet(s)\n`));
41
+ for (const wallet of wallets) {
42
+ console.log(chalk.dim(`[${wallet.id} - ${wallet.chain.toUpperCase()}]`));
43
+ }
44
+ console.log();
45
+ const { actionType } = await inquirer.prompt([
46
+ {
47
+ type: 'list',
48
+ name: 'actionType',
49
+ message: 'What would you like to do?',
50
+ default: 'send-all',
51
+ choices: [
52
+ { name: 'send-all', value: 'send-all' },
53
+ { name: 'send-specific', value: 'send-specific' },
54
+ { name: 'balance-check', value: 'balance-check' },
55
+ { name: 'batch-send', value: 'batch-send' },
56
+ ],
57
+ },
58
+ ]);
59
+ if (actionType === 'balance-check') {
60
+ await checkBalances(wallets);
61
+ return;
62
+ }
63
+ let selectedWallets;
64
+ if (actionType === 'send-specific' || actionType === 'batch-send') {
65
+ const { selectedIds } = await inquirer.prompt([
66
+ {
67
+ type: 'checkbox',
68
+ name: 'selectedIds',
69
+ message: 'Select wallets to include:',
70
+ choices: wallets.map((w) => ({ name: w.id, value: w.id, checked: false })),
71
+ },
72
+ ]);
73
+ selectedWallets = wallets.filter((w) => selectedIds.includes(w.id));
74
+ if (selectedWallets.length === 0) {
75
+ console.log(chalk.yellow('No wallets selected'));
76
+ return;
77
+ }
78
+ }
79
+ else {
80
+ selectedWallets = wallets;
81
+ }
82
+ const { amount } = await inquirer.prompt([
83
+ {
84
+ type: 'input',
85
+ name: 'amount',
86
+ message: 'Amount to send to each wallet:',
87
+ default: '0.01',
88
+ },
89
+ ]);
90
+ const { memo } = await inquirer.prompt([
91
+ {
92
+ type: 'input',
93
+ name: 'memo',
94
+ message: 'Memo (optional):',
95
+ default: '',
96
+ },
97
+ ]);
98
+ const { confirm } = await inquirer.prompt([
99
+ {
100
+ type: 'confirm',
101
+ name: 'confirm',
102
+ message: `Send ${selectedWallets.length} transactions (${amount}${memo ? ' + memo' : ''})?`,
103
+ default: false,
104
+ },
105
+ ]);
106
+ if (!confirm) {
107
+ console.log(chalk.yellow('\nMulti-chain send cancelled'));
108
+ return;
109
+ }
110
+ const spinner = ora('Preparing transactions...').start();
111
+ try {
112
+ const actions = [];
113
+ for (const wallet of selectedWallets) {
114
+ const action = {
115
+ walletId: wallet.id,
116
+ chain: wallet.chain,
117
+ request: {
118
+ to: '',
119
+ amount,
120
+ chain: wallet.chain,
121
+ },
122
+ };
123
+ actions.push(action);
124
+ }
125
+ const aggregator = createCrossChainAggregator({
126
+ maxConcurrency: 5,
127
+ continueOnError: false,
128
+ });
129
+ const results = await aggregator.execute(actions);
130
+ spinner.succeed(`Executed ${results.total} actions (${results.succeeded} succeeded, ${results.failed} failed)`);
131
+ console.log();
132
+ console.log(chalk.cyan('Execution Summary:'));
133
+ console.table(results.results.map((r) => ({
134
+ Chain: r.action.chain,
135
+ Wallet: r.action.walletId,
136
+ Success: r.success,
137
+ TxHash: r.txHash || 'N/A',
138
+ Error: r.error || 'N/A',
139
+ })));
140
+ console.log();
141
+ console.log(chalk.green('✓ Multi-chain send complete'));
142
+ }
143
+ catch (error) {
144
+ const message = error instanceof Error ? error.message : 'Unknown error';
145
+ spinner.fail(`Execution failed: ${message}`);
146
+ }
147
+ }
148
+ /**
149
+ * Check balances across multiple wallets
150
+ */
151
+ async function checkBalances(wallets) {
152
+ console.log(chalk.bold('\n📊 Balance Check\n'));
153
+ const spinner = ora('Checking balances...').start();
154
+ try {
155
+ const dispatcher = createChainDispatcher();
156
+ const balances = [];
157
+ for (const wallet of wallets) {
158
+ try {
159
+ const balance = await dispatcher.getBalance(wallet);
160
+ balances.push({
161
+ wallet,
162
+ balance: `${balance.amount} ${balance.denomination}`,
163
+ error: undefined,
164
+ });
165
+ }
166
+ catch (_error) {
167
+ balances.push({
168
+ wallet,
169
+ balance: '0',
170
+ error: _error instanceof Error ? _error.message : 'Unknown error',
171
+ });
172
+ }
173
+ }
174
+ spinner.succeed('Balance check complete');
175
+ console.log();
176
+ console.log(chalk.cyan('Balance Summary:'));
177
+ console.table(balances.map((b) => ({
178
+ Chain: b.wallet.chain,
179
+ Address: b.wallet.address,
180
+ Balance: b.balance,
181
+ Error: b.error || 'N/A',
182
+ })));
183
+ }
184
+ catch (error) {
185
+ const message = error instanceof Error ? error.message : 'Unknown error';
186
+ spinner.fail(`Balance check failed: ${message}`);
187
+ }
188
+ }
189
+ /**
190
+ * Export handler for use by wallet.ts
191
+ */
192
+ export async function handleMultiSendWithArgs(args) {
193
+ await handleMultiSend(args.agentId);
194
+ }
195
+ //# sourceMappingURL=wallet-multi-send.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Wallet Process Queue Command (Phase 5B/5D)
3
+ *
4
+ * CLI command to process pending transactions from canister queue.
5
+ * Part of Phase 5B: Agent-Initiated Transactions.
6
+ * Phase 5D: VetKeys threshold signing support.
7
+ */
8
+ /**
9
+ * Handle process-queue command
10
+ */
11
+ export declare function handleProcessQueue(agentId: string, canisterId: string): Promise<void>;
12
+ /**
13
+ * Export handler for use by wallet.ts
14
+ */
15
+ export declare function handleProcessQueueWithArgs(args: {
16
+ agentId: string;
17
+ canisterId: string;
18
+ }): Promise<void>;
19
+ //# sourceMappingURL=wallet-process-queue.d.ts.map
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Wallet Process Queue Command (Phase 5B/5D)
3
+ *
4
+ * CLI command to process pending transactions from canister queue.
5
+ * Part of Phase 5B: Agent-Initiated Transactions.
6
+ * Phase 5D: VetKeys threshold signing support.
7
+ */
8
+ import inquirer from 'inquirer';
9
+ import ora from 'ora';
10
+ import chalk from 'chalk';
11
+ import { CkEthProvider, PolkadotProvider, SolanaProvider } from '../../src/wallet/index.js';
12
+ /**
13
+ * Handle process-queue command
14
+ */
15
+ export async function handleProcessQueue(agentId, canisterId) {
16
+ console.log(chalk.bold('\n🔄 Process Transaction Queue\n'));
17
+ console.log(chalk.yellow('[Experimental] This feature is under active development and may change.\n'));
18
+ const { createActor, createAnonymousAgent } = await import('../../src/canister/actor.js');
19
+ const spinner = ora('Connecting to canister...').start();
20
+ try {
21
+ const agent = createAnonymousAgent();
22
+ const actor = createActor(canisterId, agent);
23
+ spinner.succeed('Connected to canister');
24
+ const stats = await actor.getTransactionQueueStats();
25
+ if (stats.total === 0) {
26
+ console.log(chalk.yellow('No transactions in queue'));
27
+ return;
28
+ }
29
+ console.log();
30
+ console.log(chalk.cyan('Queue Statistics:'));
31
+ console.log(` Total: ${stats.total}`);
32
+ console.log(` Pending: ${stats.pending}`);
33
+ console.log(` Queued: ${stats.queued}`);
34
+ console.log(` Signed: ${stats.signed}`);
35
+ console.log(` Completed: ${stats.completed}`);
36
+ console.log(` Failed: ${stats.failed}`);
37
+ console.log();
38
+ const pending = await actor.getPendingTransactions();
39
+ if (pending.length === 0) {
40
+ console.log(chalk.yellow('No pending transactions to process'));
41
+ return;
42
+ }
43
+ console.log(chalk.cyan(`Found ${pending.length} pending transaction(s)\n`));
44
+ const { processAll } = await inquirer.prompt([
45
+ {
46
+ type: 'confirm',
47
+ name: 'processAll',
48
+ message: `Process all ${pending.length} pending transactions?`,
49
+ default: false,
50
+ },
51
+ ]);
52
+ if (!processAll) {
53
+ console.log(chalk.yellow('\nProcessing cancelled'));
54
+ return;
55
+ }
56
+ spinner.start('Processing transactions...');
57
+ let processed = 0;
58
+ let succeeded = 0;
59
+ let failed = 0;
60
+ for (const tx of pending) {
61
+ const result = await processTransaction(tx, agentId, actor);
62
+ processed++;
63
+ if (result.success) {
64
+ succeeded++;
65
+ spinner.text = `Processed ${processed}/${pending.length} transactions...`;
66
+ }
67
+ else {
68
+ failed++;
69
+ spinner.warn(`Transaction ${tx.id} failed: ${result.error}`);
70
+ }
71
+ }
72
+ spinner.succeed(`Processed ${processed} transactions (${succeeded} succeeded, ${failed} failed)`);
73
+ console.log();
74
+ console.log(chalk.green('✓ Queue processing complete'));
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : 'Unknown error';
78
+ spinner.fail(`Processing failed: ${message}`);
79
+ }
80
+ }
81
+ /**
82
+ * Process a single transaction with VetKeys threshold signing
83
+ */
84
+ async function processTransaction(tx, agentId, actor) {
85
+ try {
86
+ const { getWallet } = await import('../../src/wallet/wallet-manager.js');
87
+ const wallet = getWallet(agentId, tx.action.walletId);
88
+ if (!wallet) {
89
+ await actor.markTransactionFailed(tx.id, 'Wallet not found');
90
+ return { success: false, error: 'Wallet not found' };
91
+ }
92
+ const action = mapActionToRequest(tx.action);
93
+ // Phase 5D: VetKeys threshold signing for transactions with threshold > 1
94
+ const threshold = tx.action.threshold ? Number(tx.action.threshold) : 1;
95
+ if (threshold > 1) {
96
+ console.log(chalk.yellow(`Transaction ${tx.id} requires threshold signatures (${threshold} of ${tx.action.threshold ? Number(tx.action.threshold) : 3})...`));
97
+ const { createVetKeysAdapter } = await import('../../src/wallet/vetkeys-adapter.js');
98
+ const vetKeys = createVetKeysAdapter({
99
+ threshold: threshold,
100
+ totalParties: 3,
101
+ encryptionAlgorithm: 'aes-256-gcm',
102
+ });
103
+ const thresholdResult = await vetKeys.initiateThresholdSignature(tx.id, wallet, action);
104
+ if (!thresholdResult.success) {
105
+ await actor.markTransactionFailed(tx.id, thresholdResult.error);
106
+ return {
107
+ success: false,
108
+ error: thresholdResult.error,
109
+ };
110
+ }
111
+ await actor.markTransactionSigned(tx.id, thresholdResult.signature || '');
112
+ console.log(chalk.green(`✓ Threshold signature completed for ${tx.id}`));
113
+ return {
114
+ success: true,
115
+ txHash: 'threshold-signed',
116
+ };
117
+ }
118
+ else {
119
+ // Normal signing (threshold = 1)
120
+ const signed = await signTransaction(wallet, action);
121
+ if (!signed) {
122
+ await actor.markTransactionFailed(tx.id, 'Signing failed');
123
+ return { success: false, error: 'Signing failed' };
124
+ }
125
+ await actor.markTransactionSigned(tx.id, signed.signature || '');
126
+ const provider = createProvider(wallet.chain);
127
+ const txResult = await provider.sendTransaction(wallet.address, action);
128
+ await actor.markTransactionCompleted(tx.id, txResult.hash);
129
+ return {
130
+ success: true,
131
+ txHash: txResult.hash,
132
+ };
133
+ }
134
+ }
135
+ catch (error) {
136
+ const message = error instanceof Error ? error.message : 'Unknown error';
137
+ await actor.markTransactionFailed(tx.id, message);
138
+ return {
139
+ success: false,
140
+ error: message,
141
+ };
142
+ }
143
+ }
144
+ /**
145
+ * Map canister action to transaction request
146
+ */
147
+ function mapActionToRequest(action) {
148
+ const params = new Map(action.parameters);
149
+ return {
150
+ to: params.get('to') || '',
151
+ amount: params.get('amount') || '0',
152
+ chain: (params.get('chain') || 'cketh'),
153
+ memo: params.get('memo'),
154
+ gasPrice: params.get('gasPrice'),
155
+ gasLimit: params.get('gasLimit'),
156
+ };
157
+ }
158
+ /**
159
+ * Sign transaction with wallet
160
+ */
161
+ async function signTransaction(wallet, action) {
162
+ try {
163
+ const provider = createProvider(wallet.chain);
164
+ const signed = await provider.signTransaction({
165
+ to: action.to,
166
+ amount: action.amount,
167
+ chain: action.chain,
168
+ }, wallet.privateKey);
169
+ return signed;
170
+ }
171
+ catch (error) {
172
+ console.error('Failed to sign transaction:', error);
173
+ return null;
174
+ }
175
+ }
176
+ /**
177
+ * Create blockchain provider
178
+ */
179
+ function createProvider(chain) {
180
+ switch (chain) {
181
+ case 'cketh':
182
+ return new CkEthProvider({
183
+ chain: 'cketh',
184
+ rpcUrl: '',
185
+ isTestnet: false,
186
+ });
187
+ case 'polkadot':
188
+ return new PolkadotProvider({
189
+ chain: 'polkadot',
190
+ rpcUrl: '',
191
+ isTestnet: false,
192
+ });
193
+ case 'solana':
194
+ return new SolanaProvider({
195
+ chain: 'solana',
196
+ rpcUrl: '',
197
+ isTestnet: false,
198
+ });
199
+ default:
200
+ throw new Error(`Unsupported chain: ${chain}`);
201
+ }
202
+ }
203
+ /**
204
+ * Export handler for use by wallet.ts
205
+ */
206
+ export async function handleProcessQueueWithArgs(args) {
207
+ await handleProcessQueue(args.agentId, args.canisterId);
208
+ }
209
+ //# sourceMappingURL=wallet-process-queue.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Wallet Sign Command
3
+ *
4
+ * Sign transactions with wallet's private key.
5
+ */
6
+ /**
7
+ * Handle wallet sign command
8
+ */
9
+ export declare function handleSign(agentId: string, options?: {
10
+ output?: string;
11
+ json?: boolean;
12
+ }): Promise<void>;
13
+ //# sourceMappingURL=wallet-sign.d.ts.map
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Wallet Sign Command
3
+ *
4
+ * Sign transactions with wallet's private key.
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
+ import * as fs from 'node:fs';
14
+ import * as path from 'node:path';
15
+ /**
16
+ * Format address for display
17
+ */
18
+ function formatAddress(address, length = 10) {
19
+ if (address.length <= length * 2)
20
+ return address;
21
+ return `${address.slice(0, length)}...${address.slice(-length)}`;
22
+ }
23
+ /**
24
+ * Create provider for chain
25
+ */
26
+ function createProvider(chain) {
27
+ switch (chain) {
28
+ case 'cketh':
29
+ return new CkEthProvider({
30
+ chain: 'cketh',
31
+ rpcUrl: CkEthProvider.getDefaultRpcUrl(),
32
+ isTestnet: false,
33
+ });
34
+ case 'polkadot':
35
+ return new PolkadotProvider({
36
+ chain: 'polkadot',
37
+ rpcUrl: 'wss://rpc.polkadot.io',
38
+ isTestnet: false,
39
+ });
40
+ case 'solana':
41
+ return new SolanaProvider({
42
+ chain: 'solana',
43
+ rpcUrl: 'https://api.mainnet-beta.solana.com',
44
+ isTestnet: false,
45
+ });
46
+ default:
47
+ throw new Error(`Unsupported chain: ${chain}`);
48
+ }
49
+ }
50
+ /**
51
+ * Display signed transaction
52
+ */
53
+ function displaySignedTransaction(signedTx, chain) {
54
+ console.log();
55
+ console.log(chalk.cyan('Signed Transaction:'));
56
+ console.log(` Chain: ${chain.toUpperCase()}`);
57
+ console.log(` Hash: ${signedTx.txHash}`);
58
+ console.log(` Signature: ${signedTx.signature || 'Included in tx'}`);
59
+ console.log(` Recipient: ${formatAddress(signedTx.request.to)}`);
60
+ console.log(` Amount: ${signedTx.request.amount}`);
61
+ }
62
+ /**
63
+ * Save signed transaction to file
64
+ */
65
+ function saveSignedTransaction(signedTx, agentId, chain) {
66
+ const outputDir = path.join(process.cwd(), '.soulrecall', 'signed-txs');
67
+ if (!fs.existsSync(outputDir)) {
68
+ fs.mkdirSync(outputDir, { recursive: true });
69
+ }
70
+ const timestamp = Date.now();
71
+ const filename = `signed-tx-${agentId}-${chain}-${timestamp}.json`;
72
+ const filepath = path.join(outputDir, filename);
73
+ const data = JSON.stringify(signedTx, null, 2);
74
+ fs.writeFileSync(filepath, data, 'utf-8');
75
+ return filepath;
76
+ }
77
+ /**
78
+ * Handle wallet sign command
79
+ */
80
+ export async function handleSign(agentId, options = {}) {
81
+ console.log(chalk.bold('\n✍️ Sign Transaction\n'));
82
+ const wallets = listAgentWallets(agentId);
83
+ if (wallets.length === 0) {
84
+ console.log(chalk.yellow('No wallets found for this agent'));
85
+ return;
86
+ }
87
+ const { walletId } = await inquirer.prompt([
88
+ {
89
+ type: 'list',
90
+ name: 'walletId',
91
+ message: 'Select wallet to sign with:',
92
+ choices: wallets,
93
+ },
94
+ ]);
95
+ const wallet = getWallet(agentId, walletId);
96
+ if (!wallet) {
97
+ console.log(chalk.red('Wallet not found'));
98
+ return;
99
+ }
100
+ const chain = wallet.chain;
101
+ const txDetails = await inquirer.prompt([
102
+ {
103
+ type: 'input',
104
+ name: 'to',
105
+ message: 'Recipient address:',
106
+ validate: (input) => input.length > 0,
107
+ },
108
+ {
109
+ type: 'input',
110
+ name: 'amount',
111
+ message: 'Amount to send:',
112
+ validate: (input) => parseFloat(input) > 0,
113
+ },
114
+ ]);
115
+ if (chain === 'cketh' || chain === 'polkadot') {
116
+ const gasDetails = await inquirer.prompt([
117
+ {
118
+ type: 'input',
119
+ name: 'gasPrice',
120
+ message: 'Gas price (optional, leave empty for auto):',
121
+ default: '',
122
+ },
123
+ {
124
+ type: 'input',
125
+ name: 'gasLimit',
126
+ message: 'Gas limit (optional, leave empty for auto):',
127
+ default: '',
128
+ },
129
+ ]);
130
+ if (gasDetails.gasPrice)
131
+ txDetails.gasPrice = gasDetails.gasPrice;
132
+ if (gasDetails.gasLimit)
133
+ txDetails.gasLimit = gasDetails.gasLimit;
134
+ }
135
+ else if (chain === 'solana') {
136
+ const { memo } = await inquirer.prompt([
137
+ {
138
+ type: 'input',
139
+ name: 'memo',
140
+ message: 'Memo (optional):',
141
+ default: '',
142
+ },
143
+ ]);
144
+ if (memo)
145
+ txDetails.memo = memo;
146
+ }
147
+ const { confirm } = await inquirer.prompt([
148
+ {
149
+ type: 'confirm',
150
+ name: 'confirm',
151
+ message: `Sign transaction to send ${txDetails.amount} to ${formatAddress(txDetails.to)}?`,
152
+ default: false,
153
+ },
154
+ ]);
155
+ if (!confirm) {
156
+ console.log(chalk.yellow('\nTransaction signing cancelled'));
157
+ return;
158
+ }
159
+ const spinner = ora('Signing transaction...').start();
160
+ try {
161
+ const provider = createProvider(chain);
162
+ await provider.connect();
163
+ if (!wallet.privateKey) {
164
+ throw new Error('Wallet has no private key available for signing');
165
+ }
166
+ const txRequest = {
167
+ to: txDetails.to,
168
+ amount: txDetails.amount,
169
+ chain: chain,
170
+ ...(txDetails.gasPrice && { gasPrice: txDetails.gasPrice }),
171
+ ...(txDetails.gasLimit && { gasLimit: txDetails.gasLimit }),
172
+ ...(txDetails.memo && { memo: txDetails.memo }),
173
+ };
174
+ const signedTx = await provider.signTransaction(txRequest, wallet.privateKey);
175
+ spinner.succeed('Transaction signed');
176
+ if (options.json) {
177
+ console.log(JSON.stringify(signedTx, null, 2));
178
+ }
179
+ else {
180
+ displaySignedTransaction(signedTx, chain);
181
+ }
182
+ if (options.output || await shouldSaveFile()) {
183
+ const filepath = saveSignedTransaction(signedTx, agentId, chain);
184
+ console.log();
185
+ console.log(chalk.green('✓'), `Signed transaction saved to: ${filepath}`);
186
+ }
187
+ }
188
+ catch (error) {
189
+ const message = error instanceof Error ? error.message : 'Unknown error';
190
+ spinner.fail(`Failed to sign transaction: ${message}`);
191
+ }
192
+ }
193
+ /**
194
+ * Prompt user to save file
195
+ */
196
+ async function shouldSaveFile() {
197
+ const { save } = await inquirer.prompt([
198
+ {
199
+ type: 'confirm',
200
+ name: 'save',
201
+ message: 'Save signed transaction to file?',
202
+ default: true,
203
+ },
204
+ ]);
205
+ return save;
206
+ }
207
+ //# sourceMappingURL=wallet-sign.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Wallet Command
3
+ *
4
+ * Main wallet management command for SoulRecall.
5
+ * Provides CLI interface for wallet operations.
6
+ */
7
+ import { Command } from 'commander';
8
+ /**
9
+ * Create wallet command
10
+ */
11
+ export declare function walletCommand(): Command;
12
+ //# sourceMappingURL=wallet.d.ts.map