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,380 @@
1
+ /**
2
+ * Wallet Storage Module
3
+ *
4
+ * Manages encrypted wallet persistence in ~/.agentvault/wallets/
5
+ * Provides per-agent wallet isolation and encryption.
6
+ */
7
+
8
+ import * as fs from 'node:fs';
9
+ import * as path from 'node:path';
10
+ import * as os from 'node:os';
11
+ import {
12
+ serializeWallet,
13
+ deserializeWallet,
14
+ validateCborData,
15
+ } from './cbor-serializer.js';
16
+ import type {
17
+ WalletData,
18
+ WalletStorageOptions,
19
+ } from './types.js';
20
+
21
+ /**
22
+ * Get base directory for wallet storage
23
+ *
24
+ * @param options - Storage options
25
+ * @returns Wallet base directory
26
+ */
27
+ export function getWalletBaseDir(options: WalletStorageOptions = {}): string {
28
+ const baseDir = options.baseDir || path.join(os.homedir(), '.agentvault', 'wallets');
29
+ return baseDir;
30
+ }
31
+
32
+ /**
33
+ * Get agent-specific wallet directory
34
+ *
35
+ * @param agentId - Agent ID
36
+ * @param options - Storage options
37
+ * @returns Agent wallet directory
38
+ */
39
+ export function getAgentWalletDir(
40
+ agentId: string,
41
+ options: WalletStorageOptions = {}
42
+ ): string {
43
+ const baseDir = getWalletBaseDir(options);
44
+ return path.join(baseDir, agentId);
45
+ }
46
+
47
+ /**
48
+ * Get wallet file path
49
+ *
50
+ * @param agentId - Agent ID
51
+ * @param walletId - Wallet ID
52
+ * @param options - Storage options
53
+ * @returns Wallet file path
54
+ */
55
+ export function getWalletFilePath(
56
+ agentId: string,
57
+ walletId: string,
58
+ options: WalletStorageOptions = {}
59
+ ): string {
60
+ const agentDir = getAgentWalletDir(agentId, options);
61
+ return path.join(agentDir, `${walletId}.wallet`);
62
+ }
63
+
64
+ /**
65
+ * Ensure wallet directories exist
66
+ *
67
+ * @param agentId - Agent ID
68
+ * @param options - Storage options
69
+ */
70
+ export function ensureWalletDirectories(
71
+ agentId: string,
72
+ options: WalletStorageOptions = {}
73
+ ): void {
74
+ const agentDir = getAgentWalletDir(agentId, options);
75
+
76
+ if (!fs.existsSync(agentDir)) {
77
+ fs.mkdirSync(agentDir, { recursive: true });
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Save wallet to encrypted storage
83
+ *
84
+ * @param wallet - Wallet data to save
85
+ * @param options - Storage options
86
+ */
87
+ export function saveWallet(
88
+ wallet: WalletData,
89
+ options: WalletStorageOptions = {}
90
+ ): void {
91
+ // Ensure directories exist
92
+ ensureWalletDirectories(wallet.agentId, options);
93
+
94
+ // Serialize wallet to CBOR
95
+ const serialized = serializeWallet(wallet);
96
+
97
+ // Get wallet file path
98
+ const walletPath = getWalletFilePath(wallet.agentId, wallet.id, options);
99
+
100
+ // Write wallet file
101
+ fs.writeFileSync(walletPath, Buffer.from(serialized));
102
+ }
103
+
104
+ /**
105
+ * Load wallet from storage
106
+ *
107
+ * @param agentId - Agent ID
108
+ * @param walletId - Wallet ID
109
+ * @param options - Storage options
110
+ * @returns Loaded wallet data or null if not found
111
+ */
112
+ export function loadWallet(
113
+ agentId: string,
114
+ walletId: string,
115
+ options: WalletStorageOptions = {}
116
+ ): WalletData | null {
117
+ const walletPath = getWalletFilePath(agentId, walletId, options);
118
+
119
+ // Check if wallet file exists
120
+ if (!fs.existsSync(walletPath)) {
121
+ return null;
122
+ }
123
+
124
+ // Read wallet file
125
+ const data = fs.readFileSync(walletPath);
126
+
127
+ // Validate CBOR data
128
+ if (!validateCborData(new Uint8Array(data))) {
129
+ throw new Error(`Invalid wallet data: ${walletId}`);
130
+ }
131
+
132
+ // Deserialize wallet
133
+ const wallet = deserializeWallet(new Uint8Array(data));
134
+
135
+ return wallet;
136
+ }
137
+
138
+ /**
139
+ * Delete wallet from storage
140
+ *
141
+ * @param agentId - Agent ID
142
+ * @param walletId - Wallet ID
143
+ * @param options - Storage options
144
+ */
145
+ export function deleteWallet(
146
+ agentId: string,
147
+ walletId: string,
148
+ options: WalletStorageOptions = {}
149
+ ): void {
150
+ const walletPath = getWalletFilePath(agentId, walletId, options);
151
+
152
+ // Check if wallet file exists
153
+ if (fs.existsSync(walletPath)) {
154
+ fs.unlinkSync(walletPath);
155
+ }
156
+ }
157
+
158
+ /**
159
+ * List all wallets for an agent
160
+ *
161
+ * @param agentId - Agent ID
162
+ * @param options - Storage options
163
+ * @returns Array of wallet IDs
164
+ */
165
+ export function listWallets(
166
+ agentId: string,
167
+ options: WalletStorageOptions = {}
168
+ ): string[] {
169
+ const agentDir = getAgentWalletDir(agentId, options);
170
+
171
+ // Check if agent directory exists
172
+ if (!fs.existsSync(agentDir)) {
173
+ return [];
174
+ }
175
+
176
+ // Read all wallet files
177
+ const files = fs.readdirSync(agentDir);
178
+
179
+ // Filter and extract wallet IDs
180
+ const walletIds = files
181
+ .filter((file) => file.endsWith('.wallet'))
182
+ .map((file) => file.replace('.wallet', ''));
183
+
184
+ return walletIds;
185
+ }
186
+
187
+ /**
188
+ * List all agents with wallets
189
+ *
190
+ * @param options - Storage options
191
+ * @returns Array of agent IDs
192
+ */
193
+ export function listAgents(options: WalletStorageOptions = {}): string[] {
194
+ const baseDir = getWalletBaseDir(options);
195
+
196
+ // Check if base directory exists
197
+ if (!fs.existsSync(baseDir)) {
198
+ return [];
199
+ }
200
+
201
+ // Read all agent directories
202
+ const agents = fs.readdirSync(baseDir);
203
+
204
+ // Filter out non-directories
205
+ const agentIds = agents.filter((agent) => {
206
+ const agentPath = path.join(baseDir, agent);
207
+ return fs.statSync(agentPath).isDirectory();
208
+ });
209
+
210
+ return agentIds;
211
+ }
212
+
213
+ /**
214
+ * Check if wallet exists
215
+ *
216
+ * @param agentId - Agent ID
217
+ * @param walletId - Wallet ID
218
+ * @param options - Storage options
219
+ * @returns True if wallet exists
220
+ */
221
+ export function walletExists(
222
+ agentId: string,
223
+ walletId: string,
224
+ options: WalletStorageOptions = {}
225
+ ): boolean {
226
+ const walletPath = getWalletFilePath(agentId, walletId, options);
227
+ return fs.existsSync(walletPath);
228
+ }
229
+
230
+ /**
231
+ * Get wallet file stats
232
+ *
233
+ * @param agentId - Agent ID
234
+ * @param walletId - Wallet ID
235
+ * @param options - Storage options
236
+ * @returns Wallet file stats or null if not found
237
+ */
238
+ export function getWalletStats(
239
+ agentId: string,
240
+ walletId: string,
241
+ options: WalletStorageOptions = {}
242
+ ): {
243
+ size: number;
244
+ modified: Date;
245
+ created: Date;
246
+ } | null {
247
+ const walletPath = getWalletFilePath(agentId, walletId, options);
248
+
249
+ if (!fs.existsSync(walletPath)) {
250
+ return null;
251
+ }
252
+
253
+ const stats = fs.statSync(walletPath);
254
+
255
+ return {
256
+ size: stats.size,
257
+ modified: stats.mtime,
258
+ created: stats.birthtime,
259
+ };
260
+ }
261
+
262
+ /**
263
+ * Backup all wallets for an agent
264
+ *
265
+ * @param agentId - Agent ID
266
+ * @param backupPath - Path to save backup
267
+ * @param options - Storage options
268
+ */
269
+ export function backupWallets(
270
+ agentId: string,
271
+ backupPath: string,
272
+ options: WalletStorageOptions = {}
273
+ ): void {
274
+ const agentDir = getAgentWalletDir(agentId, options);
275
+
276
+ if (!fs.existsSync(agentDir)) {
277
+ throw new Error(`No wallets found for agent: ${agentId}`);
278
+ }
279
+
280
+ // Create backup directory
281
+ const backupDir = path.join(backupPath, agentId);
282
+ if (!fs.existsSync(backupDir)) {
283
+ fs.mkdirSync(backupDir, { recursive: true });
284
+ }
285
+
286
+ // Copy all wallet files
287
+ const files = fs.readdirSync(agentDir);
288
+ for (const file of files) {
289
+ const srcPath = path.join(agentDir, file);
290
+ const destPath = path.join(backupDir, file);
291
+ fs.copyFileSync(srcPath, destPath);
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Restore wallets from backup
297
+ *
298
+ * @param agentId - Agent ID
299
+ * @param backupPath - Path to backup directory
300
+ * @param options - Storage options
301
+ */
302
+ export function restoreWallets(
303
+ agentId: string,
304
+ backupPath: string,
305
+ options: WalletStorageOptions = {}
306
+ ): void {
307
+ const agentDir = getAgentWalletDir(agentId, options);
308
+
309
+ if (!fs.existsSync(backupPath)) {
310
+ throw new Error(`Backup directory not found: ${backupPath}`);
311
+ }
312
+
313
+ // Ensure agent directory exists
314
+ ensureWalletDirectories(agentId, options);
315
+
316
+ // Copy all wallet files from backup
317
+ const files = fs.readdirSync(backupPath);
318
+ for (const file of files) {
319
+ if (file.endsWith('.wallet')) {
320
+ const srcPath = path.join(backupPath, file);
321
+ const destPath = path.join(agentDir, file);
322
+ fs.copyFileSync(srcPath, destPath);
323
+ }
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Clear all wallets for an agent
329
+ *
330
+ * @param agentId - Agent ID
331
+ * @param options - Storage options
332
+ */
333
+ export function clearWallets(
334
+ agentId: string,
335
+ options: WalletStorageOptions = {}
336
+ ): void {
337
+ const agentDir = getAgentWalletDir(agentId, options);
338
+
339
+ if (!fs.existsSync(agentDir)) {
340
+ return; // Nothing to clear
341
+ }
342
+
343
+ // Delete all wallet files
344
+ const files = fs.readdirSync(agentDir);
345
+ for (const file of files) {
346
+ const filePath = path.join(agentDir, file);
347
+ fs.unlinkSync(filePath);
348
+ }
349
+ }
350
+
351
+ /**
352
+ * Get total storage size for an agent
353
+ *
354
+ * @param agentId - Agent ID
355
+ * @param options - Storage options
356
+ * @returns Total size in bytes
357
+ */
358
+ export function getWalletStorageSize(
359
+ agentId: string,
360
+ options: WalletStorageOptions = {}
361
+ ): number {
362
+ const agentDir = getAgentWalletDir(agentId, options);
363
+
364
+ if (!fs.existsSync(agentDir)) {
365
+ return 0;
366
+ }
367
+
368
+ let totalSize = 0;
369
+ const files = fs.readdirSync(agentDir);
370
+
371
+ for (const file of files) {
372
+ const filePath = path.join(agentDir, file);
373
+ const stats = fs.statSync(filePath);
374
+ if (stats.isFile() && file.endsWith('.wallet')) {
375
+ totalSize += stats.size;
376
+ }
377
+ }
378
+
379
+ return totalSize;
380
+ }
package/vercel.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://openapi.vercel.sh/vercel.json",
3
+ "buildCommand": "npm run build",
4
+ "outputDirectory": "build",
5
+ "installCommand": "npm install",
6
+ "framework": null,
7
+ "regions": ["iad1"]
8
+ }