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,26 @@
1
+ /**
2
+ * Exec command - Run agent on-chain
3
+ */
4
+ import { Command } from 'commander';
5
+ import type { NetworkType } from '../../src/deployment/types.js';
6
+ export interface ExecCommandOptions {
7
+ network?: NetworkType;
8
+ async?: boolean;
9
+ polling?: boolean;
10
+ }
11
+ export interface TaskResult {
12
+ taskId: string;
13
+ status: 'pending' | 'running' | 'completed' | 'failed';
14
+ result?: unknown;
15
+ error?: string;
16
+ cyclesUsed?: bigint;
17
+ }
18
+ /**
19
+ * Execute exec command
20
+ */
21
+ export declare function executeExec(canisterId: string, task: string, options: ExecCommandOptions): Promise<TaskResult>;
22
+ /**
23
+ * Create exec command
24
+ */
25
+ export declare function execCommand(): Command;
26
+ //# sourceMappingURL=exec.d.ts.map
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Exec command - Run agent on-chain
3
+ */
4
+ import { Command } from 'commander';
5
+ import chalk from 'chalk';
6
+ import ora from 'ora';
7
+ import { createICPClient } from '../../src/deployment/icpClient.js';
8
+ /**
9
+ * Execute exec command
10
+ */
11
+ export async function executeExec(canisterId, task, options) {
12
+ const network = options.network ?? 'local';
13
+ const resolvedCanisterId = canisterId.trim();
14
+ // Validate canister ID
15
+ if (!/^[a-z0-9-]{27}$/.test(resolvedCanisterId)) {
16
+ throw new Error(`Invalid canister ID format: ${resolvedCanisterId}. Expected 27 characters of alphanumeric and hyphens.`);
17
+ }
18
+ const spinner = ora('Executing task on canister...').start();
19
+ try {
20
+ // Create ICP client
21
+ const client = createICPClient({ network });
22
+ // Check connection
23
+ const connectionCheck = await client.checkConnection();
24
+ if (!connectionCheck.connected) {
25
+ throw new Error(`Failed to connect to ${network} network: ${connectionCheck.error ?? 'Unknown error'}`);
26
+ }
27
+ // Check canister status
28
+ spinner.text = 'Checking canister status...';
29
+ const status = await client.getCanisterStatus(resolvedCanisterId);
30
+ if (status.status !== 'running') {
31
+ throw new Error(`Canister is not running. Status: ${status.status}`);
32
+ }
33
+ // Submit task to canister
34
+ spinner.text = 'Submitting task...';
35
+ const executionResult = await client.callAgentMethod(resolvedCanisterId, 'execute', [task]);
36
+ const taskId = `task_${Date.now()}`;
37
+ spinner.succeed('Task submitted successfully!');
38
+ console.log();
39
+ console.log(chalk.cyan('Task Info:'));
40
+ console.log(` Canister: ${chalk.bold(resolvedCanisterId)}`);
41
+ console.log(` Network: ${network}`);
42
+ console.log(` Task ID: ${taskId}`);
43
+ console.log(` Command: ${task}`);
44
+ // Poll for completion if requested
45
+ if (options.polling && !options.async) {
46
+ const newSpinner = ora('Waiting for task completion...');
47
+ return await pollForCompletion(client, resolvedCanisterId, taskId, executionResult, newSpinner);
48
+ }
49
+ // Return async result
50
+ return {
51
+ taskId,
52
+ status: 'pending',
53
+ result: executionResult,
54
+ };
55
+ }
56
+ catch (error) {
57
+ const message = error instanceof Error ? error.message : 'Unknown error';
58
+ spinner.fail(`Execution failed: ${message}`);
59
+ throw error;
60
+ }
61
+ }
62
+ /**
63
+ * Poll for task completion
64
+ */
65
+ async function pollForCompletion(_client, _canisterId, taskId, executionResult, spinner) {
66
+ spinner.start('Finalizing task result...');
67
+ spinner.succeed('Task completed!');
68
+ console.log();
69
+ console.log(chalk.green('✓'), 'Task executed successfully!');
70
+ return {
71
+ taskId,
72
+ status: 'completed',
73
+ result: executionResult,
74
+ };
75
+ }
76
+ /**
77
+ * Create exec command
78
+ */
79
+ export function execCommand() {
80
+ const command = new Command('exec');
81
+ command
82
+ .description('Run agent task on-chain')
83
+ .argument('<canister-id>', 'canister ID to execute on')
84
+ .argument('<task>', 'task/command to execute')
85
+ .option('-n, --network <network>', 'network (local or ic)', 'local')
86
+ .option('-a, --async', 'return immediately without waiting for completion')
87
+ .option('-p, --polling', 'poll for task completion (default: true)')
88
+ .action(async (canisterId, task, options) => {
89
+ console.log(chalk.bold('\n⚡ SoulRecall Exec\n'));
90
+ try {
91
+ const result = await executeExec(canisterId, task, options);
92
+ if (options.async || options.polling === false) {
93
+ console.log();
94
+ console.log(chalk.cyan('Task Info:'));
95
+ console.log(` Task ID: ${result.taskId}`);
96
+ console.log(` Status: ${result.status}`);
97
+ console.log();
98
+ console.log('Use', chalk.bold('soulrecall show'), 'to check task status.');
99
+ }
100
+ }
101
+ catch (error) {
102
+ const message = error instanceof Error ? error.message : 'Unknown error';
103
+ console.error(chalk.red(`\nError: ${message}`));
104
+ process.exit(1);
105
+ }
106
+ });
107
+ return command;
108
+ }
109
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Fetch command - Download agent state from canister
3
+ */
4
+ import { Command } from 'commander';
5
+ import type { NetworkType } from '../../src/deployment/types.js';
6
+ export interface FetchCommandOptions {
7
+ network?: NetworkType;
8
+ output?: string;
9
+ decrypt?: boolean;
10
+ }
11
+ export interface FetchAnswers {
12
+ seedPhrase?: string;
13
+ confirm: boolean;
14
+ }
15
+ /**
16
+ * Execute the fetch command
17
+ */
18
+ export declare function executeFetch(canisterId: string, options: FetchCommandOptions): Promise<void>;
19
+ /**
20
+ * Create the fetch command
21
+ */
22
+ export declare function fetchCommand(): Command;
23
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Fetch command - Download agent state from canister
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 { createICPClient } from '../../src/deployment/icpClient.js';
11
+ /**
12
+ * Execute the fetch command
13
+ */
14
+ export async function executeFetch(canisterId, options) {
15
+ const network = options.network ?? 'local';
16
+ const resolvedCanisterId = canisterId.trim();
17
+ // Validate canister ID format
18
+ if (!/^[a-z0-9-]{27}$/.test(resolvedCanisterId)) {
19
+ throw new Error(`Invalid canister ID format: ${resolvedCanisterId}. Expected 27 characters of alphanumeric and hyphens.`);
20
+ }
21
+ // Determine output path
22
+ const outputPath = options.output ?? path.resolve(process.cwd(), `${resolvedCanisterId}.state.json`);
23
+ // Check if output already exists
24
+ if (fs.existsSync(outputPath) && !options.decrypt) {
25
+ const { overwrite } = await inquirer.prompt([
26
+ {
27
+ type: 'confirm',
28
+ name: 'overwrite',
29
+ message: `Output file ${outputPath} already exists. Overwrite?`,
30
+ default: false,
31
+ },
32
+ ]);
33
+ if (!overwrite) {
34
+ console.log(chalk.yellow('\nFetch cancelled.'));
35
+ return;
36
+ }
37
+ }
38
+ const spinner = ora('Fetching agent state from canister...').start();
39
+ try {
40
+ // Create ICP client
41
+ const client = createICPClient({ network });
42
+ // Check connection
43
+ const connectionCheck = await client.checkConnection();
44
+ if (!connectionCheck.connected) {
45
+ throw new Error(`Failed to connect to ${network} network: ${connectionCheck.error ?? 'Unknown error'}`);
46
+ }
47
+ // Fetch state from canister
48
+ spinner.text = 'Querying canister state...';
49
+ const canisterStatus = await client.getCanisterStatus(resolvedCanisterId);
50
+ const [agentStateResult, memoriesResult, tasksResult, contextResult] = await Promise.allSettled([
51
+ client.callAgentMethod(resolvedCanisterId, 'agent_get_state'),
52
+ client.callAgentMethod(resolvedCanisterId, 'agent_get_memories'),
53
+ client.callAgentMethod(resolvedCanisterId, 'agent_get_tasks'),
54
+ client.callAgentMethod(resolvedCanisterId, 'getAllContext'),
55
+ ]);
56
+ const stateData = {
57
+ canisterId: resolvedCanisterId,
58
+ network,
59
+ fetchedAt: new Date().toISOString(),
60
+ canisterStatus,
61
+ state: {
62
+ initialized: canisterStatus.exists,
63
+ data: {
64
+ agentState: agentStateResult.status === 'fulfilled' ? agentStateResult.value : null,
65
+ memories: memoriesResult.status === 'fulfilled' ? memoriesResult.value : [],
66
+ tasks: tasksResult.status === 'fulfilled' ? tasksResult.value : [],
67
+ context: contextResult.status === 'fulfilled' ? contextResult.value : {},
68
+ },
69
+ },
70
+ };
71
+ spinner.succeed('Agent state fetched successfully!');
72
+ console.log();
73
+ console.log(chalk.cyan('Canister Info:'));
74
+ console.log(` ID: ${chalk.bold(stateData.canisterId)}`);
75
+ console.log(` Network: ${stateData.network}`);
76
+ console.log(` Fetched: ${stateData.fetchedAt}`);
77
+ // Write state to file
78
+ if (!options.decrypt) {
79
+ fs.writeFileSync(outputPath, JSON.stringify(stateData, null, 2), 'utf-8');
80
+ console.log();
81
+ console.log(chalk.green('✓'), 'State saved to:', chalk.bold(outputPath));
82
+ console.log();
83
+ console.log(chalk.cyan('Next steps:'));
84
+ console.log(' 1. Decrypt the state:', chalk.bold('soulrecall decrypt'), `<${outputPath}>`);
85
+ console.log(' 2. Rebuild the agent:', chalk.bold('soulrecall rebuild'));
86
+ }
87
+ // Handle decryption if requested
88
+ if (options.decrypt) {
89
+ await handleDecryption(stateData, outputPath);
90
+ }
91
+ }
92
+ catch (error) {
93
+ const message = error instanceof Error ? error.message : 'Unknown error';
94
+ spinner.fail(`Fetch failed: ${message}`);
95
+ throw error;
96
+ }
97
+ }
98
+ /**
99
+ * Handle decryption of fetched state
100
+ */
101
+ async function handleDecryption(stateData, outputPath) {
102
+ console.log();
103
+ console.log(chalk.cyan('Decryption required.'));
104
+ await inquirer.prompt([
105
+ {
106
+ type: 'password',
107
+ name: 'seedPhrase',
108
+ message: 'Enter your seed phrase:',
109
+ validate: (input) => {
110
+ if (!input.trim()) {
111
+ return 'Seed phrase is required';
112
+ }
113
+ const words = input.trim().split(/\s+/);
114
+ if (words.length !== 12 && words.length !== 24) {
115
+ return 'Seed phrase must be 12 or 24 words';
116
+ }
117
+ return true;
118
+ },
119
+ },
120
+ ]);
121
+ const spinner = ora('Decrypting state...').start();
122
+ try {
123
+ // Stub: In a real implementation, this would decrypt using VetKeys
124
+ const decryptedState = stateData;
125
+ spinner.succeed('State decrypted successfully!');
126
+ fs.writeFileSync(outputPath, JSON.stringify(decryptedState, null, 2), 'utf-8');
127
+ console.log();
128
+ console.log(chalk.green('✓'), 'Decrypted state saved to:', chalk.bold(outputPath));
129
+ console.log();
130
+ console.log(chalk.cyan('Next steps:'));
131
+ console.log(' 1. Review the decrypted state');
132
+ console.log(' 2. Rebuild the agent:', chalk.bold('soulrecall rebuild'));
133
+ }
134
+ catch (error) {
135
+ const message = error instanceof Error ? error.message : 'Unknown error';
136
+ spinner.fail(`Decryption failed: ${message}`);
137
+ throw error;
138
+ }
139
+ }
140
+ /**
141
+ * Create the fetch command
142
+ */
143
+ export function fetchCommand() {
144
+ const command = new Command('fetch');
145
+ command
146
+ .description('Download agent state from canister')
147
+ .argument('<canister-id>', 'canister ID to fetch state from')
148
+ .option('-n, --network <network>', 'network (local or ic)', 'local')
149
+ .option('-o, --output <path>', 'output file path')
150
+ .option('-d, --decrypt', 'decrypt state after fetching')
151
+ .action(async (canisterId, options) => {
152
+ console.log(chalk.bold('\n📥 SoulRecall Fetch\n'));
153
+ try {
154
+ await executeFetch(canisterId, options);
155
+ }
156
+ catch (error) {
157
+ const message = error instanceof Error ? error.message : 'Unknown error';
158
+ console.error(chalk.red(`\nError: ${message}`));
159
+ process.exit(1);
160
+ }
161
+ });
162
+ return command;
163
+ }
164
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Health Command
3
+ *
4
+ * Checks canister health and displays alerts.
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare function healthCommand(): Command;
8
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Health Command
3
+ *
4
+ * Checks canister health and displays alerts.
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import { checkHealth, getRecentAlerts } from '../../src/monitoring/index.js';
10
+ export function healthCommand() {
11
+ const command = new Command('health');
12
+ command
13
+ .description('Check canister health and display alerts')
14
+ .argument('<canister-id>', 'Canister ID to check')
15
+ .option('-t, --thresholds <json>', 'Health check thresholds as JSON')
16
+ .option('-i, --interval <ms>', 'Polling interval in milliseconds')
17
+ .option('--max-alerts <n>', 'Maximum alerts to display')
18
+ .option('--clear', 'Clear all alerts for canister')
19
+ .option('-w, --watch', 'Watch canister health continuously');
20
+ command
21
+ .action(async (canisterId, options) => {
22
+ const thresholds = options.thresholds ? JSON.parse(options.thresholds) : undefined;
23
+ const monitoringOpts = {
24
+ canister: canisterId,
25
+ thresholds,
26
+ pollInterval: options.interval ? parseInt(options.interval) : undefined,
27
+ maxSnapshots: options.maxAlerts ? parseInt(options.maxAlerts) : 10,
28
+ };
29
+ const spinner = ora('Checking canister health...').start();
30
+ try {
31
+ const statusInfo = await checkHealth(canisterId, monitoringOpts);
32
+ spinner.succeed('Health check completed');
33
+ displayHealth(statusInfo);
34
+ const alerts = await getRecentAlerts(canisterId, monitoringOpts.maxSnapshots || 10);
35
+ if (alerts.length > 0) {
36
+ console.log();
37
+ console.log(chalk.cyan('Recent Alerts:'));
38
+ for (const alert of alerts) {
39
+ const severityColor = alert.severity === 'critical'
40
+ ? chalk.red
41
+ : alert.severity === 'warning'
42
+ ? chalk.yellow
43
+ : chalk.gray;
44
+ console.log(` [${new Date(alert.timestamp).toISOString()}]`, ` ${severityColor(alert.severity)} ${alert.severity.toUpperCase()}:`, ` Canister: ${alert.canisterId}`, ` Metric: ${alert.metric}`, ` Value: ${alert.value}`, ` Threshold: ${alert.threshold}`);
45
+ }
46
+ }
47
+ else {
48
+ console.log(chalk.gray('No recent alerts'));
49
+ }
50
+ }
51
+ catch (error) {
52
+ const message = error instanceof Error ? error.message : 'Unknown error';
53
+ spinner.fail(`Health check failed: ${message}`);
54
+ throw error;
55
+ }
56
+ });
57
+ return command;
58
+ }
59
+ function displayHealth(statusInfo) {
60
+ console.log();
61
+ console.log(chalk.cyan('Canister Status:'), chalk.bold(statusInfo.status));
62
+ console.log();
63
+ console.log(chalk.cyan('Health Check:'), statusInfo.health === 'healthy' ? chalk.green('Passed') : chalk.red('Failed'));
64
+ if (statusInfo.memorySize !== undefined) {
65
+ const memoryMB = Number(statusInfo.memorySize) / (1024 * 1024);
66
+ console.log(chalk.cyan('Memory:'), chalk.bold(`${memoryMB.toFixed(2)} MB`));
67
+ }
68
+ if (statusInfo.cycles !== undefined) {
69
+ console.log(chalk.cyan('Cycles:'), chalk.bold(statusInfo.cycles.toString()));
70
+ }
71
+ }
72
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Identity Command
3
+ *
4
+ * Manages identities for ICP operations.
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare function identityCommand(): Command;
8
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Identity Command
3
+ *
4
+ * Manages identities for ICP operations.
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import { listIdentities, createIdentity, exportIdentity, getIdentityPrincipal, importIdentity, setDefaultIdentity, } from '../../src/icp/identity.js';
10
+ export function identityCommand() {
11
+ const command = new Command('identity');
12
+ command
13
+ .description('Manage ICP identities')
14
+ .action(() => {
15
+ command.outputHelp();
16
+ })
17
+ .addCommand(listSubcommand())
18
+ .addCommand(createSubcommand())
19
+ .addCommand(exportSubcommand())
20
+ .addCommand(importSubcommand())
21
+ .addCommand(principalSubcommand())
22
+ .addCommand(defaultSubcommand());
23
+ return command;
24
+ }
25
+ async function executeList() {
26
+ const spinner = ora('Listing identities...').start();
27
+ try {
28
+ const result = await listIdentities();
29
+ spinner.succeed('Identities listed successfully');
30
+ console.log();
31
+ console.log(chalk.cyan('Available Identities:'));
32
+ console.log(result.stdout || 'No identities found');
33
+ }
34
+ catch (error) {
35
+ spinner.fail(`Failed to list identities: ${error instanceof Error ? error.message : 'Unknown error'}`);
36
+ throw error;
37
+ }
38
+ }
39
+ async function executeCreate(options) {
40
+ const { name } = options;
41
+ const spinner = ora('Creating identity...').start();
42
+ try {
43
+ await createIdentity(name);
44
+ spinner.succeed(`Identity '${name}' created successfully`);
45
+ }
46
+ catch (error) {
47
+ spinner.fail(`Failed to create identity: ${error instanceof Error ? error.message : 'Unknown error'}`);
48
+ throw error;
49
+ }
50
+ }
51
+ async function executeExport(options) {
52
+ const { name } = options;
53
+ const spinner = ora('Exporting identity...').start();
54
+ try {
55
+ const result = await exportIdentity(name);
56
+ spinner.succeed(`Identity '${name}' exported successfully`);
57
+ console.log();
58
+ console.log(chalk.cyan('PEM Content:'));
59
+ console.log(result.stdout || 'No PEM content returned');
60
+ }
61
+ catch (error) {
62
+ spinner.fail(`Failed to export identity: ${error instanceof Error ? error.message : 'Unknown error'}`);
63
+ throw error;
64
+ }
65
+ }
66
+ async function executeImport(options) {
67
+ const { name, pemFile } = options;
68
+ const spinner = ora('Importing identity...').start();
69
+ try {
70
+ await importIdentity(name, pemFile);
71
+ spinner.succeed(`Identity '${name}' imported successfully`);
72
+ console.log(chalk.cyan('Imported from:'), pemFile);
73
+ }
74
+ catch (error) {
75
+ spinner.fail(`Failed to import identity: ${error instanceof Error ? error.message : 'Unknown error'}`);
76
+ throw error;
77
+ }
78
+ }
79
+ async function executePrincipal(options) {
80
+ const { name } = options;
81
+ const spinner = ora('Getting identity principal...').start();
82
+ try {
83
+ const result = await getIdentityPrincipal(name);
84
+ spinner.succeed(`Identity '${name}' principal: ${result || 'N/A'}`);
85
+ }
86
+ catch (error) {
87
+ spinner.fail(`Failed to get identity principal: ${error instanceof Error ? error.message : 'Unknown error'}`);
88
+ throw error;
89
+ }
90
+ }
91
+ async function executeSetDefault(options) {
92
+ const { name } = options;
93
+ const spinner = ora('Setting default identity...').start();
94
+ try {
95
+ await setDefaultIdentity(name);
96
+ spinner.succeed(`Identity '${name}' set as default`);
97
+ }
98
+ catch (error) {
99
+ spinner.fail(`Failed to set default identity: ${error instanceof Error ? error.message : 'Unknown error'}`);
100
+ throw error;
101
+ }
102
+ }
103
+ function listSubcommand() {
104
+ return new Command('list')
105
+ .description('List all ICP identities')
106
+ .action(executeList);
107
+ }
108
+ function createSubcommand() {
109
+ return new Command('create')
110
+ .description('Create a new ICP identity')
111
+ .argument('<name>', 'Identity name')
112
+ .action(executeCreate);
113
+ }
114
+ function exportSubcommand() {
115
+ return new Command('export')
116
+ .description('Export identity to PEM file')
117
+ .argument('<name>', 'Identity name')
118
+ .argument('[pem-file]', 'Path to PEM file')
119
+ .action(executeExport);
120
+ }
121
+ function importSubcommand() {
122
+ return new Command('import')
123
+ .description('Import identity from PEM file')
124
+ .argument('<name>', 'Identity name')
125
+ .argument('[pem-file]', 'Path to PEM file')
126
+ .action(executeImport);
127
+ }
128
+ function principalSubcommand() {
129
+ return new Command('principal')
130
+ .description('Get the principal of an identity')
131
+ .argument('[name]', 'Identity name (optional)')
132
+ .action(executePrincipal);
133
+ }
134
+ function defaultSubcommand() {
135
+ return new Command('default')
136
+ .description('Set the default identity')
137
+ .argument('<name>', 'Identity name')
138
+ .action(executeSetDefault);
139
+ }
140
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const inferenceCmd: Command;
3
+ export { inferenceCmd };
4
+ //# sourceMappingURL=inference.d.ts.map