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,188 @@
1
+ /**
2
+ * Package command - Compile agent to WASM for deployment
3
+ */
4
+ import { Command } from 'commander';
5
+ import chalk from 'chalk';
6
+ import ora from 'ora';
7
+ import * as path from 'node:path';
8
+ import { packageAgent, getPackageSummary } from '../../src/packaging/index.js';
9
+ /**
10
+ * Format file size for display
11
+ */
12
+ function formatSize(bytes) {
13
+ if (bytes < 1024) {
14
+ return `${bytes} B`;
15
+ }
16
+ if (bytes < 1024 * 1024) {
17
+ return `${(bytes / 1024).toFixed(1)} KB`;
18
+ }
19
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
20
+ }
21
+ /**
22
+ * Display package preview (dry-run)
23
+ */
24
+ export function displayPreview(sourcePath) {
25
+ const { config, validation } = getPackageSummary(sourcePath);
26
+ console.log(chalk.bold('\nPackage Preview\n'));
27
+ console.log(chalk.cyan('Agent Configuration:'));
28
+ console.log(` Name: ${chalk.bold(config.name)}`);
29
+ console.log(` Type: ${chalk.bold(config.type)}`);
30
+ console.log(` Source: ${config.sourcePath}`);
31
+ console.log(` Entry Point: ${config.entryPoint ?? chalk.yellow('not detected')}`);
32
+ console.log(` Version: ${config.version ?? chalk.yellow('not specified')}`);
33
+ // Display agent settings for Clawdbot agents if available
34
+ if (config.type === 'clawdbot' && 'settings' in config) {
35
+ const settings = config.settings;
36
+ console.log();
37
+ console.log(chalk.cyan('Agent Settings:'));
38
+ if (settings.model) {
39
+ console.log(` Model: ${chalk.bold(settings.model)}`);
40
+ }
41
+ if (settings.temperature !== undefined) {
42
+ console.log(` Temperature: ${chalk.bold(String(settings.temperature))}`);
43
+ }
44
+ if (settings.maxTokens !== undefined) {
45
+ console.log(` Max Tokens: ${chalk.bold(String(settings.maxTokens))}`);
46
+ }
47
+ }
48
+ console.log();
49
+ if (validation.warnings.length > 0) {
50
+ console.log(chalk.yellow('Warnings:'));
51
+ for (const warning of validation.warnings) {
52
+ console.log(chalk.yellow(` âš  ${warning}`));
53
+ }
54
+ console.log();
55
+ }
56
+ if (validation.errors.length > 0) {
57
+ console.log(chalk.red('Errors:'));
58
+ for (const error of validation.errors) {
59
+ console.log(chalk.red(` ✖ ${error.message}`));
60
+ }
61
+ console.log();
62
+ }
63
+ console.log(chalk.cyan('Output Files:'));
64
+ console.log(` ${config.name}.wasm - Compiled WebAssembly module`);
65
+ console.log(` ${config.name}.wat - WebAssembly text format`);
66
+ console.log(` ${config.name}.state.json - Initial agent state`);
67
+ }
68
+ /**
69
+ * Display package result
70
+ */
71
+ export function displayResult(result) {
72
+ console.log();
73
+ console.log(chalk.green('✓'), 'Agent packaged successfully!');
74
+ console.log();
75
+ console.log(chalk.cyan('Compilation:'));
76
+ console.log(` Target: ${chalk.bold(result.target.toUpperCase())}`);
77
+ console.log(` Duration: ${result.duration ? `${result.duration}ms` : 'N/A'}`);
78
+ console.log();
79
+ console.log(chalk.cyan('Output Files:'));
80
+ console.log(` WASM: ${result.wasmPath} (${formatSize(result.wasmSize)})`);
81
+ console.log(` WAT: ${result.watPath}`);
82
+ console.log(` State: ${result.statePath}`);
83
+ if (result.jsBundlePath) {
84
+ console.log(` JS Bundle: ${result.jsBundlePath}`);
85
+ }
86
+ if (result.sourceMapPath) {
87
+ console.log(` Source Map: ${result.sourceMapPath}`);
88
+ }
89
+ if (result.manifestPath) {
90
+ console.log(` Manifest: ${result.manifestPath}`);
91
+ }
92
+ // Display optimization results if available
93
+ if (result.originalWasmSize !== undefined) {
94
+ console.log(chalk.cyan('Optimization:'));
95
+ console.log(` Original: ${formatSize(result.originalWasmSize)}`);
96
+ console.log(` Optimized: ${formatSize(result.wasmSize)}`);
97
+ if (result.optimizationReductionPercent !== undefined) {
98
+ console.log(` Reduction: ${result.optimizationReductionPercent}%`);
99
+ }
100
+ if (result.candidValidationPassed !== undefined) {
101
+ const status = result.candidValidationPassed
102
+ ? chalk.green('passed')
103
+ : chalk.red('failed');
104
+ console.log(` Candid Validation: ${status}`);
105
+ }
106
+ if (result.optimizationWarnings && result.optimizationWarnings.length > 0) {
107
+ for (const warning of result.optimizationWarnings) {
108
+ console.log(chalk.yellow(` Warning: ${warning}`));
109
+ }
110
+ }
111
+ console.log();
112
+ }
113
+ console.log(chalk.cyan('Next steps:'));
114
+ console.log(' 1. Review the generated files');
115
+ console.log(' 2. Run', chalk.bold('soulrecall deploy'), 'to upload to ICP');
116
+ }
117
+ /**
118
+ * Execute the package command
119
+ */
120
+ export async function executePackage(sourcePath, options) {
121
+ // Handle dry-run mode
122
+ if (options.dryRun) {
123
+ displayPreview(sourcePath);
124
+ return null;
125
+ }
126
+ const spinner = ora('Packaging agent...').start();
127
+ try {
128
+ // Prepare package options
129
+ const packageOptions = {
130
+ sourcePath,
131
+ outputPath: options.output ? path.resolve(options.output) : undefined,
132
+ force: options.force,
133
+ skipValidation: options.skipValidation,
134
+ target: options.target,
135
+ debug: options.debug,
136
+ optimize: options.optimize,
137
+ icWasmOptimize: options.icWasmOptimize,
138
+ icWasmShrink: options.icWasmShrink,
139
+ candidInterface: options.validate,
140
+ memoryLimit: options.memoryLimit,
141
+ computeQuota: options.computeQuota,
142
+ };
143
+ // Execute packaging
144
+ const result = await packageAgent(packageOptions);
145
+ spinner.succeed(`Agent '${result.config.name}' packaged successfully!`);
146
+ displayResult(result);
147
+ return result;
148
+ }
149
+ catch (error) {
150
+ const message = error instanceof Error ? error.message : 'Unknown error';
151
+ spinner.fail(`Packaging failed: ${message}`);
152
+ throw error;
153
+ }
154
+ }
155
+ /**
156
+ * Create the package command
157
+ */
158
+ export function packageCommand() {
159
+ const command = new Command('package');
160
+ command
161
+ .description('Compile agent to WASM for deployment to ICP')
162
+ .argument('[source]', 'path to agent source directory', '.')
163
+ .option('-o, --output <path>', 'output directory for compiled files')
164
+ .option('-f, --force', 'overwrite existing output files')
165
+ .option('--skip-validation', 'skip validation checks')
166
+ .option('--dry-run', 'show what would be packaged without executing')
167
+ .option('-t, --target <target>', 'compilation target (wasmedge|motoko|pure-wasm)', 'wasmedge')
168
+ .option('--debug', 'enable debugging features (source maps, verbose output)')
169
+ .option('--optimize <level>', 'optimization level (0-3)', '2')
170
+ .option('--ic-wasm-optimize', 'optimize WASM with ic-wasm (requires ic-wasm)')
171
+ .option('--ic-wasm-shrink', 'shrink WASM with ic-wasm (requires ic-wasm)')
172
+ .option('--validate <did-file>', 'validate WASM endpoints against Candid .did file')
173
+ .option('--memory-limit <limit>', 'set canister memory limit (e.g. 4GiB)')
174
+ .option('--compute-quota <quota>', 'set canister compute quota')
175
+ .action(async (source, options) => {
176
+ console.log(chalk.bold('\n📦 SoulRecall Package\n'));
177
+ try {
178
+ await executePackage(source, options);
179
+ }
180
+ catch (error) {
181
+ const message = error instanceof Error ? error.message : 'Unknown error';
182
+ console.error(chalk.red(`\nError: ${message}`));
183
+ process.exit(1);
184
+ }
185
+ });
186
+ return command;
187
+ }
188
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Profile CLI command
3
+ *
4
+ * Provides command for profiling canister performance
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const profileCmd: Command;
8
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Profile CLI command
3
+ *
4
+ * Provides command for profiling canister performance
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import fs from 'node:fs';
10
+ export const profileCmd = new Command('profile');
11
+ profileCmd
12
+ .description('[Experimental] Profile canister performance')
13
+ .argument('<canister-id>', 'Canister ID')
14
+ .option('-d, --duration <seconds>', 'Profile duration in seconds', '30')
15
+ .option('--export <file>', 'Export profile data to file')
16
+ .option('--format <format>', 'Export format (json, flamegraph)', 'json')
17
+ .action(async (canisterId, options) => {
18
+ console.log(chalk.yellow('[Experimental] This feature is under active development and may change.'));
19
+ const duration = parseInt(options.duration, 10);
20
+ const spinner = ora(`Profiling ${canisterId} for ${duration}s...`).start();
21
+ try {
22
+ await new Promise((resolve) => setTimeout(resolve, 1000));
23
+ const mockResult = {
24
+ samples: 100,
25
+ duration,
26
+ methodStats: new Map([
27
+ ['query', { count: 60, totalDuration: 1200, avgDuration: 20, maxDuration: 45 }],
28
+ ['update', { count: 30, totalDuration: 1800, avgDuration: 60, maxDuration: 120 }],
29
+ ['heartbeat', { count: 10, totalDuration: 100, avgDuration: 10, maxDuration: 15 }],
30
+ ]),
31
+ memorySnapshots: [1024, 1152, 1088, 1200, 1184],
32
+ };
33
+ spinner.succeed(chalk.green('Profiling completed'));
34
+ console.log(chalk.bold('\nProfile Results:'));
35
+ console.log(chalk.gray(` Duration: ${mockResult.duration}s`));
36
+ console.log(chalk.gray(` Samples: ${mockResult.samples}`));
37
+ console.log();
38
+ console.log(chalk.bold('Method Statistics:'));
39
+ for (const [method, stats] of mockResult.methodStats) {
40
+ console.log(`\n ${chalk.cyan(method)}:`);
41
+ console.log(chalk.gray(` Calls: ${stats.count}`));
42
+ console.log(chalk.gray(` Total: ${stats.totalDuration}ms`));
43
+ console.log(chalk.gray(` Avg: ${stats.avgDuration.toFixed(2)}ms`));
44
+ console.log(chalk.gray(` Max: ${stats.maxDuration}ms`));
45
+ }
46
+ console.log();
47
+ console.log(chalk.bold('Memory Snapshots (KB):'));
48
+ console.log(chalk.gray(` ${mockResult.memorySnapshots.join(' → ')}`));
49
+ if (options.export) {
50
+ const exportData = {
51
+ samples: mockResult.samples,
52
+ duration: mockResult.duration,
53
+ methodStats: Object.fromEntries(mockResult.methodStats),
54
+ memorySnapshots: mockResult.memorySnapshots,
55
+ };
56
+ const exportSpinner = ora(`Exporting to ${options.export}...`).start();
57
+ if (options.format === 'json') {
58
+ fs.writeFileSync(options.export, JSON.stringify(exportData, null, 2), 'utf8');
59
+ }
60
+ else {
61
+ fs.writeFileSync(options.export, 'Flamegraph export not yet implemented', 'utf8');
62
+ }
63
+ exportSpinner.succeed(chalk.green(`Profile exported to ${options.export}`));
64
+ }
65
+ console.log();
66
+ console.log(chalk.yellow('Profiling is in mock mode.'));
67
+ console.log(chalk.gray('Real profiling requires soulrecall instrument and trace collection.'));
68
+ }
69
+ catch (error) {
70
+ spinner.fail(chalk.red('Failed to profile canister'));
71
+ const message = error instanceof Error ? error.message : 'Unknown error';
72
+ console.error(chalk.red(message));
73
+ process.exit(1);
74
+ }
75
+ });
76
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Promote CLI command
3
+ *
4
+ * Provides commands for promoting canisters between environments
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const promoteCmd: Command;
8
+ //# sourceMappingURL=promote.d.ts.map
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Promote CLI command
3
+ *
4
+ * Provides commands for promoting canisters between environments
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import { promoteCanister, getLatestDeployment, getAllDeployments } from '../../src/deployment/promotion.js';
10
+ export const promoteCmd = new Command('promote');
11
+ promoteCmd
12
+ .description('Promote canisters between environments')
13
+ .argument('<agent-name>', 'Agent name to promote')
14
+ .option('-f, --from <env>', 'Source environment')
15
+ .option('-t, --to <env>', 'Target environment')
16
+ .option('--target-canister <id>', 'Target canister ID (optional)')
17
+ .option('--blue-green', 'Enable blue-green deployment', false)
18
+ .option('-w, --wasm-path <path>', 'Path to WASM file for actual deployment')
19
+ .option('--skip-deploy', 'Skip actual deploy, only update history')
20
+ .action(async (agentName, options) => {
21
+ if (!options.from) {
22
+ console.error(chalk.red('Error: --from is required'));
23
+ process.exit(1);
24
+ }
25
+ if (!options.to) {
26
+ console.error(chalk.red('Error: --to is required'));
27
+ process.exit(1);
28
+ }
29
+ const spinner = ora(`Promoting ${agentName} from ${options.from} to ${options.to}...`).start();
30
+ try {
31
+ const sourceDeployment = getLatestDeployment(agentName, options.from);
32
+ if (!sourceDeployment) {
33
+ spinner.fail(chalk.red(`No deployment found for ${agentName} in ${options.from}`));
34
+ process.exit(1);
35
+ }
36
+ console.log(chalk.gray(`\nSource deployment:`));
37
+ console.log(chalk.gray(` Environment: ${sourceDeployment.environment}`));
38
+ console.log(chalk.gray(` Canister ID: ${sourceDeployment.canisterId}`));
39
+ console.log(chalk.gray(` WASM Hash: ${sourceDeployment.wasmHash}`));
40
+ console.log(chalk.gray(` Version: ${sourceDeployment.version}`));
41
+ console.log(chalk.gray(` Deployed: ${sourceDeployment.timestamp.toISOString()}`));
42
+ console.log();
43
+ const result = await promoteCanister(agentName, options.from, options.to, {
44
+ targetCanisterId: options.targetCanister,
45
+ blueGreen: options.blueGreen,
46
+ wasmPath: options.wasmPath,
47
+ skipDeploy: options.skipDeploy,
48
+ });
49
+ spinner.succeed(chalk.green(`Promoted ${agentName} from ${options.from} to ${options.to}`));
50
+ console.log(chalk.bold('\nNew deployment:'));
51
+ console.log(chalk.gray(` Environment: ${result.environment}`));
52
+ console.log(chalk.gray(` Canister ID: ${result.canisterId}`));
53
+ console.log(chalk.gray(` WASM Hash: ${result.wasmHash}`));
54
+ console.log(chalk.gray(` Version: ${result.version}`));
55
+ console.log(chalk.gray(` Deployed: ${result.timestamp.toISOString()}`));
56
+ if (options.blueGreen) {
57
+ console.log(chalk.yellow('\nNote: Blue-green deployment enabled. You may need to manually switch traffic to the new canister.'));
58
+ }
59
+ }
60
+ catch (error) {
61
+ spinner.fail(chalk.red('Failed to promote canister'));
62
+ const message = error instanceof Error ? error.message : 'Unknown error';
63
+ console.error(chalk.red(message));
64
+ process.exit(1);
65
+ }
66
+ });
67
+ promoteCmd
68
+ .command('list')
69
+ .description('List deployment history for an agent')
70
+ .argument('<agent-name>', 'Agent name')
71
+ .action(async (agentName) => {
72
+ const deployments = getAllDeployments(agentName);
73
+ if (deployments.length === 0) {
74
+ console.log(chalk.yellow(`No deployments found for ${agentName}`));
75
+ return;
76
+ }
77
+ console.log(chalk.bold(`Deployment history for ${agentName}:`));
78
+ console.log();
79
+ for (const deployment of deployments) {
80
+ const statusColor = deployment.success ? chalk.green : chalk.red;
81
+ console.log(`${statusColor(deployment.success ? '✓' : '✗')} Version ${deployment.version}`);
82
+ console.log(chalk.gray(` Environment: ${deployment.environment}`));
83
+ console.log(chalk.gray(` Canister ID: ${deployment.canisterId}`));
84
+ console.log(chalk.gray(` WASM Hash: ${deployment.wasmHash}`));
85
+ console.log(chalk.gray(` Timestamp: ${deployment.timestamp.toISOString()}`));
86
+ console.log();
87
+ }
88
+ });
89
+ //# sourceMappingURL=promote.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Rebuild command - Rebuild local agent from canister state
3
+ */
4
+ import { Command } from 'commander';
5
+ export interface RebuildCommandOptions {
6
+ output?: string;
7
+ force?: boolean;
8
+ skipCompile?: boolean;
9
+ target?: 'wasmedge' | 'motoko' | 'pure-wasm';
10
+ debug?: boolean;
11
+ optimize?: number;
12
+ }
13
+ export interface RebuildAnswers {
14
+ confirm: boolean;
15
+ }
16
+ export declare function executeRebuild(stateFile: string, options: RebuildCommandOptions): Promise<void>;
17
+ /**
18
+ * Create rebuild command
19
+ */
20
+ export declare function rebuildCommand(): Command;
21
+ //# sourceMappingURL=rebuild.d.ts.map
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Rebuild command - Rebuild local agent from canister state
3
+ */
4
+ import { Command } from 'commander';
5
+ import chalk from 'chalk';
6
+ import ora from 'ora';
7
+ import inquirer from 'inquirer';
8
+ import * as fs from 'node:fs';
9
+ import * as path from 'node:path';
10
+ import { compileToWasm } from '../../src/packaging/compiler.js';
11
+ export async function executeRebuild(stateFile, options) {
12
+ const resolvedPath = path.resolve(stateFile);
13
+ // Validate state file exists
14
+ if (!fs.existsSync(resolvedPath)) {
15
+ throw new Error(`State file not found: ${resolvedPath}`);
16
+ }
17
+ const spinner = ora('Reading agent state...').start();
18
+ let state;
19
+ try {
20
+ // Read and parse state
21
+ const content = fs.readFileSync(resolvedPath, 'utf-8');
22
+ state = JSON.parse(content);
23
+ spinner.succeed('Agent state loaded successfully!');
24
+ console.log();
25
+ console.log(chalk.cyan('Agent Configuration:'));
26
+ console.log(` Name: ${chalk.bold(state.config.name)}`);
27
+ console.log(` Type: ${state.config.type}`);
28
+ console.log(` Source: ${state.config.sourcePath}`);
29
+ console.log(` Version: ${state.config.version ?? 'N/A'}`);
30
+ console.log();
31
+ console.log(chalk.cyan('State Info:'));
32
+ console.log(` Memories: ${state.memories?.length || 0}`);
33
+ console.log(` Tasks: ${state.tasks?.length || 0}`);
34
+ console.log(` Context: ${Object.keys(state.context || {}).length} entries`);
35
+ console.log();
36
+ console.log(chalk.yellow('Agent tasks can be resumed'));
37
+ console.log('Context is preserved');
38
+ spinner.stop();
39
+ }
40
+ catch (error) {
41
+ spinner.stop();
42
+ const message = error instanceof Error ? error.message : 'Unknown error';
43
+ throw new Error(`Failed to parse state file: ${message}`);
44
+ }
45
+ // Check if source directory exists
46
+ if (!fs.existsSync(state.config.sourcePath)) {
47
+ console.log();
48
+ console.log(chalk.yellow('âš '), 'Source directory not found:', state.config.sourcePath);
49
+ console.log();
50
+ console.log('You need to provide a source code to rebuild agent.');
51
+ console.log('Options:');
52
+ console.log(' 1. Clone original repository');
53
+ console.log(' 2. Provide a new source directory');
54
+ spinner.stop();
55
+ return;
56
+ }
57
+ // Confirm rebuild
58
+ if (!options.force) {
59
+ const { confirm } = await inquirer.prompt([
60
+ {
61
+ type: 'confirm',
62
+ name: 'confirm',
63
+ message: 'Rebuild agent with this configuration?',
64
+ default: true,
65
+ },
66
+ ]);
67
+ if (!confirm) {
68
+ console.log(chalk.yellow('\nRebuild cancelled.'));
69
+ spinner.stop();
70
+ return;
71
+ }
72
+ }
73
+ // Skip compilation if requested
74
+ if (options.skipCompile) {
75
+ console.log();
76
+ console.log(chalk.green('✓'), 'Rebuild skipped compilation step.');
77
+ console.log();
78
+ console.log(chalk.cyan('Agent state ready for use'));
79
+ console.log('Memories can be restored');
80
+ spinner.stop();
81
+ return;
82
+ }
83
+ // Compile agent to WASM
84
+ const compileSpinner = ora('Compiling agent to WASM...').start();
85
+ try {
86
+ const compileOptions = {
87
+ sourcePath: state.config.sourcePath,
88
+ target: options.target ?? 'wasmedge',
89
+ debug: options.debug ?? false,
90
+ optimize: options.optimize ?? 2,
91
+ };
92
+ const result = await compileToWasm(state.config, compileOptions, path.dirname(resolvedPath));
93
+ compileSpinner.succeed(`Agent compiled successfully!`);
94
+ console.log();
95
+ console.log(chalk.cyan('Output Files:'));
96
+ console.log(` WASM: ${result.wasmPath}`);
97
+ console.log(` WAT: ${result.watPath}`);
98
+ console.log(` State: ${result.statePath}`);
99
+ console.log();
100
+ console.log(chalk.green('✓'), 'Agent rebuilt successfully!');
101
+ console.log();
102
+ console.log(chalk.cyan('Next steps:'));
103
+ console.log(' 1. Test rebuilt agent locally');
104
+ console.log(' 2. Deploy with:', chalk.bold('soulrecall deploy'));
105
+ }
106
+ catch (error) {
107
+ compileSpinner.fail('Compilation failed');
108
+ const message = error instanceof Error ? error.message : 'Unknown error';
109
+ spinner.fail(`Rebuild failed: ${message}`);
110
+ throw error;
111
+ }
112
+ }
113
+ /**
114
+ * Create rebuild command
115
+ */
116
+ export function rebuildCommand() {
117
+ const command = new Command('rebuild');
118
+ command
119
+ .description('Rebuild local agent from canister state')
120
+ .argument('<state-file>', 'agent state file (JSON)')
121
+ .option('-o, --output <path>', 'output directory for rebuilt agent')
122
+ .option('-f, --force', 'skip confirmation prompts')
123
+ .option('--skip-compile', 'skip WASM compilation')
124
+ .option('-t, --target <target>', 'compilation target (wasmedge|motoko|pure-wasm)', 'wasmedge')
125
+ .option('--debug', 'enable debugging features')
126
+ .option('--optimize <level>', 'optimization level (0-3)', '2')
127
+ .action(async (stateFile, options) => {
128
+ console.log(chalk.bold('\n🔧 SoulRecall Rebuild\n'));
129
+ try {
130
+ await executeRebuild(stateFile, options);
131
+ }
132
+ catch (error) {
133
+ const message = error instanceof Error ? error.message : 'Unknown error';
134
+ console.error(chalk.red(`\nError: ${message}`));
135
+ process.exit(1);
136
+ }
137
+ });
138
+ return command;
139
+ }
140
+ //# sourceMappingURL=rebuild.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Rollback CLI command
3
+ *
4
+ * Provides commands for rolling back canisters to previous versions
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const rollbackCmd: Command;
8
+ //# sourceMappingURL=rollback.d.ts.map
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Rollback CLI command
3
+ *
4
+ * Provides commands for rolling back canisters to previous versions
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import { getDeploymentForRollback, getDeploymentsByTimeRange, getAllDeployments, } from '../../src/deployment/promotion.js';
10
+ import { deploy } from '../../src/icp/icpcli.js';
11
+ export const rollbackCmd = new Command('rollback');
12
+ rollbackCmd
13
+ .description('Rollback canisters to previous versions')
14
+ .argument('<agent-name>', 'Agent name to rollback')
15
+ .option('-e, --env <env>', 'Environment to rollback', 'production')
16
+ .option('-v, --version <version>', 'Version to rollback to')
17
+ .option('-t, --to <timestamp>', 'Rollback to timestamp')
18
+ .option('--dry-run', 'Show what would be rolled back without executing', false)
19
+ .action(async (agentName, options) => {
20
+ if (!options.version && !options.to) {
21
+ console.error(chalk.red('Error: --version or --to is required'));
22
+ process.exit(1);
23
+ }
24
+ const spinner = ora(`Finding deployment to rollback...`).start();
25
+ try {
26
+ let targetDeployment;
27
+ if (options.version) {
28
+ const version = parseInt(options.version, 10);
29
+ targetDeployment = getDeploymentForRollback(agentName, options.env, version);
30
+ if (!targetDeployment) {
31
+ spinner.fail(chalk.red(`Version ${version} not found for ${agentName} in ${options.env}`));
32
+ process.exit(1);
33
+ }
34
+ }
35
+ else {
36
+ const toTimestamp = new Date(options.to);
37
+ const fromTimestamp = new Date(toTimestamp.getTime() - 30 * 24 * 60 * 60 * 1000);
38
+ const deployments = getDeploymentsByTimeRange(agentName, options.env, fromTimestamp, toTimestamp);
39
+ if (deployments.length === 0) {
40
+ spinner.fail(chalk.red(`No deployments found for ${agentName} in ${options.env} before ${options.to}`));
41
+ process.exit(1);
42
+ }
43
+ targetDeployment = deployments[0];
44
+ }
45
+ if (!targetDeployment) {
46
+ spinner.fail(chalk.red('No deployment found'));
47
+ process.exit(1);
48
+ }
49
+ spinner.succeed(chalk.green('Found deployment to rollback to'));
50
+ console.log(chalk.bold('\nTarget deployment:'));
51
+ console.log(chalk.gray(` Environment: ${targetDeployment.environment}`));
52
+ console.log(chalk.gray(` Canister ID: ${targetDeployment.canisterId}`));
53
+ console.log(chalk.gray(` WASM Hash: ${targetDeployment.wasmHash}`));
54
+ console.log(chalk.gray(` Version: ${targetDeployment.version}`));
55
+ console.log(chalk.gray(` Timestamp: ${targetDeployment.timestamp.toISOString()}`));
56
+ console.log();
57
+ if (options.dryRun) {
58
+ console.log(chalk.yellow('Dry run: No changes will be made'));
59
+ console.log(chalk.gray(`To perform the rollback, run without --dry-run`));
60
+ return;
61
+ }
62
+ const confirmSpinner = ora(`Rolling back ${agentName} to version ${targetDeployment.version}...`).start();
63
+ const result = await deploy({
64
+ environment: options.env,
65
+ projectRoot: process.cwd(),
66
+ });
67
+ if (!result.success) {
68
+ confirmSpinner.fail(chalk.red('Rollback failed'));
69
+ console.error(chalk.red(result.stderr));
70
+ process.exit(1);
71
+ }
72
+ confirmSpinner.succeed(chalk.green(`Rolled back ${agentName} to version ${targetDeployment.version}`));
73
+ console.log(result.stdout);
74
+ }
75
+ catch (error) {
76
+ spinner.fail(chalk.red('Failed to rollback'));
77
+ const message = error instanceof Error ? error.message : 'Unknown error';
78
+ console.error(chalk.red(message));
79
+ process.exit(1);
80
+ }
81
+ });
82
+ rollbackCmd
83
+ .command('list')
84
+ .description('List available rollback versions')
85
+ .argument('<agent-name>', 'Agent name')
86
+ .option('-e, --env <env>', 'Environment to list versions for', 'production')
87
+ .action(async (agentName, options) => {
88
+ const deployments = getAllDeployments(agentName);
89
+ const envDeployments = deployments
90
+ .filter((d) => d.environment === options.env && d.success)
91
+ .sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
92
+ if (envDeployments.length === 0) {
93
+ console.log(chalk.yellow(`No deployments found for ${agentName} in ${options.env}`));
94
+ return;
95
+ }
96
+ console.log(chalk.bold(`Available rollback versions for ${agentName} (${options.env}):`));
97
+ console.log();
98
+ for (const deployment of envDeployments) {
99
+ const relativeTime = formatRelativeTime(deployment.timestamp);
100
+ console.log(`${chalk.gray('→')} Version ${deployment.version} ${chalk.gray(`(${relativeTime})`)}`);
101
+ console.log(chalk.gray(` Canister: ${deployment.canisterId}`));
102
+ console.log(chalk.gray(` WASM: ${deployment.wasmHash.substring(0, 16)}...`));
103
+ console.log();
104
+ }
105
+ });
106
+ function formatRelativeTime(date) {
107
+ const now = new Date();
108
+ const diffMs = now.getTime() - date.getTime();
109
+ const diffMins = Math.floor(diffMs / 60000);
110
+ const diffHours = Math.floor(diffMins / 60);
111
+ const diffDays = Math.floor(diffHours / 24);
112
+ if (diffMins < 1)
113
+ return 'just now';
114
+ if (diffMins < 60)
115
+ return `${diffMins}m ago`;
116
+ if (diffHours < 24)
117
+ return `${diffHours}h ago`;
118
+ return `${diffDays}d ago`;
119
+ }
120
+ //# sourceMappingURL=rollback.js.map