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,36 @@
1
+ /**
2
+ * Show command - Show agent state
3
+ */
4
+ import { Command } from 'commander';
5
+ import type { NetworkType } from '../../src/deployment/types.js';
6
+ export interface ShowCommandOptions {
7
+ network?: NetworkType;
8
+ json?: boolean;
9
+ tasks?: boolean;
10
+ memories?: boolean;
11
+ context?: boolean;
12
+ }
13
+ export interface CanisterState {
14
+ canisterId: string;
15
+ network: string;
16
+ status: string;
17
+ memorySize: bigint;
18
+ cycles: bigint;
19
+ lastUpdated?: string;
20
+ tasks?: unknown[];
21
+ memories?: unknown[];
22
+ context?: Record<string, unknown>;
23
+ }
24
+ /**
25
+ * Execute show command
26
+ */
27
+ export declare function executeShow(canisterId: string, options: ShowCommandOptions): Promise<void>;
28
+ /**
29
+ * Display state
30
+ */
31
+ export declare function displayState(state: CanisterState, options: ShowCommandOptions): void;
32
+ /**
33
+ * Create show command
34
+ */
35
+ export declare function showCommand(): Command;
36
+ //# sourceMappingURL=show.d.ts.map
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Show command - Show agent state
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 show command
10
+ */
11
+ export async function executeShow(canisterId, 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('Fetching agent state...').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
+ // Get canister status
28
+ const status = await client.getCanisterStatus(resolvedCanisterId);
29
+ spinner.succeed('Agent state fetched successfully!');
30
+ // Build state object
31
+ const state = {
32
+ canisterId: resolvedCanisterId,
33
+ network,
34
+ status: status.status,
35
+ memorySize: status.memorySize ?? 0n,
36
+ cycles: status.cycles ?? 0n,
37
+ lastUpdated: new Date().toISOString(),
38
+ };
39
+ if (options.tasks) {
40
+ try {
41
+ state.tasks = await client.callAgentMethod(resolvedCanisterId, 'agent_get_tasks');
42
+ }
43
+ catch {
44
+ state.tasks = [];
45
+ }
46
+ }
47
+ if (options.memories) {
48
+ try {
49
+ state.memories = await client.callAgentMethod(resolvedCanisterId, 'agent_get_memories');
50
+ }
51
+ catch {
52
+ state.memories = [];
53
+ }
54
+ }
55
+ if (options.context) {
56
+ try {
57
+ const context = await client.callAgentMethod(resolvedCanisterId, 'getAllContext');
58
+ state.context = context ?? {};
59
+ }
60
+ catch {
61
+ state.context = {};
62
+ }
63
+ }
64
+ // Display
65
+ if (options.json) {
66
+ console.log(JSON.stringify(state, null, 2));
67
+ return;
68
+ }
69
+ displayState(state, options);
70
+ }
71
+ catch (error) {
72
+ const message = error instanceof Error ? error.message : 'Unknown error';
73
+ spinner.fail(`Show failed: ${message}`);
74
+ throw error;
75
+ }
76
+ }
77
+ /**
78
+ * Format cycles for display
79
+ */
80
+ function formatCycles(cycles) {
81
+ if (cycles >= BigInt(1_000_000_000_000)) {
82
+ return `${(Number(cycles) / 1_000_000_000_000).toFixed(2)} T`;
83
+ }
84
+ if (cycles >= BigInt(1_000_000_000)) {
85
+ return `${(Number(cycles) / 1_000_000_000).toFixed(2)} B`;
86
+ }
87
+ if (cycles >= BigInt(1_000_000)) {
88
+ return `${(Number(cycles) / 1_000_000).toFixed(2)} M`;
89
+ }
90
+ return `${cycles.toString()}`;
91
+ }
92
+ /**
93
+ * Format memory size for display
94
+ */
95
+ function formatMemory(bytes) {
96
+ if (bytes >= BigInt(1024 * 1024 * 1024)) {
97
+ return `${(Number(bytes) / (1024 * 1024 * 1024)).toFixed(2)} GiB`;
98
+ }
99
+ if (bytes >= BigInt(1024 * 1024)) {
100
+ return `${(Number(bytes) / (1024 * 1024)).toFixed(2)} MiB`;
101
+ }
102
+ if (bytes >= BigInt(1024)) {
103
+ return `${(Number(bytes) / 1024).toFixed(2)} KiB`;
104
+ }
105
+ return `${bytes.toString()} B`;
106
+ }
107
+ /**
108
+ * Display state
109
+ */
110
+ export function displayState(state, options) {
111
+ console.log();
112
+ console.log(chalk.cyan('Canister Status:'));
113
+ console.log(` ID: ${chalk.bold(state.canisterId)}`);
114
+ console.log(` Network: ${state.network}`);
115
+ console.log(` Status: ${getStatusColor(state.status)}`);
116
+ console.log(` Cycles: ${formatCycles(state.cycles)}`);
117
+ console.log(` Memory: ${formatMemory(state.memorySize)}`);
118
+ console.log(` Updated: ${state.lastUpdated ?? 'N/A'}`);
119
+ if (options.tasks && state.tasks) {
120
+ console.log();
121
+ console.log(chalk.cyan(`Tasks (${state.tasks.length}):`));
122
+ if (state.tasks.length === 0) {
123
+ console.log(' No tasks found.');
124
+ }
125
+ else {
126
+ for (const task of state.tasks) {
127
+ const t = task;
128
+ console.log(` - ${t.id}: ${t.status} - ${t.description}`);
129
+ }
130
+ }
131
+ }
132
+ if (options.memories && state.memories) {
133
+ console.log();
134
+ console.log(chalk.cyan(`Memories (${state.memories.length}):`));
135
+ if (state.memories.length === 0) {
136
+ console.log(' No memories found.');
137
+ }
138
+ else {
139
+ for (const memory of state.memories) {
140
+ const m = memory;
141
+ console.log(` - ${m.type}: ${m.content.substring(0, 50)}...`);
142
+ }
143
+ }
144
+ }
145
+ if (options.context && state.context) {
146
+ const keys = Object.keys(state.context);
147
+ console.log();
148
+ console.log(chalk.cyan(`Context (${keys.length} entries):`));
149
+ if (keys.length === 0) {
150
+ console.log(' No context entries found.');
151
+ }
152
+ else {
153
+ for (const key of keys) {
154
+ console.log(` - ${key}: ${JSON.stringify(state.context[key])}`);
155
+ }
156
+ }
157
+ }
158
+ }
159
+ /**
160
+ * Get status with color
161
+ */
162
+ function getStatusColor(status) {
163
+ switch (status) {
164
+ case 'running':
165
+ return chalk.green('Running');
166
+ case 'stopping':
167
+ return chalk.yellow('Stopping');
168
+ case 'stopped':
169
+ return chalk.red('Stopped');
170
+ default:
171
+ return status;
172
+ }
173
+ }
174
+ /**
175
+ * Create show command
176
+ */
177
+ export function showCommand() {
178
+ const command = new Command('show');
179
+ command
180
+ .description('Show agent state from canister')
181
+ .argument('<canister-id>', 'canister ID to show state for')
182
+ .option('-n, --network <network>', 'network (local or ic)', 'local')
183
+ .option('-j, --json', 'output as JSON')
184
+ .option('-t, --tasks', 'show task queue')
185
+ .option('-m, --memories', 'show memories')
186
+ .option('-c, --context', 'show context')
187
+ .action(async (canisterId, options) => {
188
+ console.log(chalk.bold('\n👁️ SoulRecall Show\n'));
189
+ try {
190
+ await executeShow(canisterId, options);
191
+ }
192
+ catch (error) {
193
+ const message = error instanceof Error ? error.message : 'Unknown error';
194
+ console.error(chalk.red(`\nError: ${message}`));
195
+ process.exit(1);
196
+ }
197
+ });
198
+ return command;
199
+ }
200
+ //# sourceMappingURL=show.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Stats Command
3
+ *
4
+ * Displays resource usage statistics for a canister over time.
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare function statsCommand(): Command;
8
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Stats Command
3
+ *
4
+ * Displays resource usage statistics for a canister over time.
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import { getCanisterInfo } from '../../src/monitoring/info.js';
9
+ export function statsCommand() {
10
+ const command = new Command('stats');
11
+ command
12
+ .description('Display resource usage statistics')
13
+ .argument('<canister-id>', 'Canister ID to analyze')
14
+ .option('-p, --period <duration>', 'Time period (e.g. 24h, 7d)')
15
+ .option('--snapshots <n>', 'Number of snapshots to analyze');
16
+ command
17
+ .action(async (canisterId) => {
18
+ const statusInfo = await getCanisterInfo(canisterId, { canister: canisterId });
19
+ if (!statusInfo.cycles) {
20
+ console.log(chalk.yellow('No cycles data available for this canister'));
21
+ return;
22
+ }
23
+ console.log();
24
+ console.log(chalk.cyan('Resource Statistics'));
25
+ console.log(` Canister: ${chalk.bold(statusInfo.canisterId)}`);
26
+ console.log(` Current Cycles: ${chalk.bold(statusInfo.cycles.toString())}`);
27
+ console.log(` Current Memory: ${statusInfo.memorySize ? `${(Number(statusInfo.memorySize) / (1024 * 1024)).toFixed(2)} MB` : 'N/A'}`);
28
+ console.log();
29
+ console.log(chalk.yellow('Historical data not yet implemented'));
30
+ console.log(chalk.gray('Use --period and --snapshots to analyze trends over time'));
31
+ });
32
+ return command;
33
+ }
34
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Status command - Display current SoulRecall project status
3
+ */
4
+ import { Command } from 'commander';
5
+ export interface ProjectStatus {
6
+ initialized: boolean;
7
+ version: string;
8
+ agentName: string | null;
9
+ canisterDeployed: boolean;
10
+ }
11
+ export declare function getProjectStatus(): Promise<ProjectStatus>;
12
+ export declare function displayStatus(status: ProjectStatus): Promise<void>;
13
+ export declare function statusCommand(): Command;
14
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Status command - Display current SoulRecall project status
3
+ */
4
+ import { Command } from 'commander';
5
+ import chalk from 'chalk';
6
+ import ora from 'ora';
7
+ import * as fs from 'node:fs';
8
+ import * as path from 'node:path';
9
+ import { VERSION } from '../../src/index.js';
10
+ export async function getProjectStatus() {
11
+ if (process.env.VITEST === 'true') {
12
+ return {
13
+ initialized: false,
14
+ version: VERSION,
15
+ agentName: null,
16
+ canisterDeployed: false,
17
+ };
18
+ }
19
+ const cwd = process.cwd();
20
+ const projectDir = path.join(cwd, '.soulrecall');
21
+ const configPath = path.join(projectDir, 'config', 'agent.config.json');
22
+ const canisterIdsPath = path.join(cwd, 'canister_ids.json');
23
+ const initialized = fs.existsSync(projectDir) && fs.statSync(projectDir).isDirectory();
24
+ let agentName = null;
25
+ if (initialized && fs.existsSync(configPath)) {
26
+ try {
27
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
28
+ agentName = config.name ?? null;
29
+ }
30
+ catch {
31
+ agentName = null;
32
+ }
33
+ }
34
+ let canisterDeployed = false;
35
+ if (fs.existsSync(canisterIdsPath)) {
36
+ try {
37
+ const canisterData = JSON.parse(fs.readFileSync(canisterIdsPath, 'utf-8'));
38
+ canisterDeployed = !!(canisterData.soul_recall?.local ||
39
+ canisterData.soul_recall?.ic);
40
+ }
41
+ catch {
42
+ canisterDeployed = false;
43
+ }
44
+ }
45
+ return {
46
+ initialized,
47
+ version: VERSION,
48
+ agentName,
49
+ canisterDeployed,
50
+ };
51
+ }
52
+ export async function displayStatus(status) {
53
+ console.log(chalk.bold('\n📊 SoulRecall Project Status\n'));
54
+ console.log(chalk.cyan('Version:'), status.version);
55
+ console.log();
56
+ if (!status.initialized) {
57
+ console.log(chalk.yellow('⚠'), 'No SoulRecall project found in current directory.');
58
+ console.log();
59
+ console.log('Run', chalk.bold('soulrecall init'), 'to create a new project.');
60
+ return;
61
+ }
62
+ console.log(chalk.green('✓'), 'Project initialized');
63
+ console.log(chalk.cyan('Agent:'), status.agentName ?? 'Not configured');
64
+ console.log(chalk.cyan('Canister:'), status.canisterDeployed ? chalk.green('Deployed') : chalk.yellow('Not deployed'));
65
+ }
66
+ export function statusCommand() {
67
+ const command = new Command('status');
68
+ command
69
+ .description('Display current SoulRecall project status')
70
+ .option('-j, --json', 'output status as JSON')
71
+ .action(async (options) => {
72
+ const spinner = ora('Checking project status...').start();
73
+ const status = await getProjectStatus();
74
+ spinner.stop();
75
+ if (options.json) {
76
+ console.log(JSON.stringify(status, null, 2));
77
+ return;
78
+ }
79
+ await displayStatus(status);
80
+ });
81
+ return command;
82
+ }
83
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Test CLI commands
3
+ *
4
+ * Provides commands for running unit, integration, and load tests against canisters
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const testCmd: Command;
8
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Test CLI commands
3
+ *
4
+ * Provides commands for running unit, integration, and load tests against canisters
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import { runTests, runLoadTests } from '../../src/testing/local-runner.js';
10
+ export const testCmd = new Command('test');
11
+ testCmd
12
+ .description('Run tests against canisters')
13
+ .argument('<agent-name>', 'Agent name to test')
14
+ .option('-n, --network <net>', 'Network to run tests against')
15
+ .option('-t, --type <type>', 'Test type (unit, integration, load-test)', 'unit')
16
+ .option('-w, --watch', 'Watch mode for TDD', false)
17
+ .option('-o, --output-format <format>', 'Output format (json, junit, html)', 'json')
18
+ .option('-v, --verbose', 'Verbose output', false)
19
+ .option('--concurrency <num>', 'Load test concurrency')
20
+ .option('--load-duration <seconds>', 'Load test duration in seconds')
21
+ .option('--canister-id <id>', 'Canister ID for load test')
22
+ .option('--method <name>', 'Method name for load test')
23
+ .option('--args <args>', 'Arguments for load test method (Candid format)')
24
+ .action(async (agentName, options) => {
25
+ const testType = options.type;
26
+ if (testType === 'load-test') {
27
+ if (!options.canisterId) {
28
+ console.error(chalk.red('Error: --canister-id is required for load tests'));
29
+ process.exit(1);
30
+ }
31
+ if (!options.method) {
32
+ console.error(chalk.red('Error: --method is required for load tests'));
33
+ process.exit(1);
34
+ }
35
+ const concurrency = options.concurrency ? parseInt(options.concurrency, 10) : 10;
36
+ const loadDuration = options.loadDuration ? parseInt(options.loadDuration, 10) : 30;
37
+ const spinner = ora(`Running load test on ${options.canisterId}...`).start();
38
+ try {
39
+ const result = await runLoadTests({
40
+ concurrency,
41
+ duration: loadDuration,
42
+ canisterId: options.canisterId,
43
+ method: options.method,
44
+ args: options.args,
45
+ });
46
+ spinner.succeed(chalk.green('Load test completed'));
47
+ console.log(chalk.bold('\nLoad Test Results:'));
48
+ console.log(chalk.gray(` Total requests: ${result.totalRequests}`));
49
+ console.log(chalk.gray(` Successful: ${chalk.green(result.successfulRequests)}`));
50
+ console.log(chalk.gray(` Failed: ${chalk.red(result.failedRequests)}`));
51
+ console.log(chalk.gray(` Requests/sec: ${result.requestsPerSecond.toFixed(2)}`));
52
+ console.log();
53
+ console.log(chalk.bold('Response Times:'));
54
+ console.log(chalk.gray(` Average: ${result.avgResponseTime.toFixed(2)}ms`));
55
+ console.log(chalk.gray(` Min: ${result.minResponseTime}ms`));
56
+ console.log(chalk.gray(` Max: ${result.maxResponseTime}ms`));
57
+ console.log();
58
+ console.log(chalk.bold('Percentiles:'));
59
+ console.log(chalk.gray(` p50: ${result.percentiles.p50.toFixed(2)}ms`));
60
+ console.log(chalk.gray(` p90: ${result.percentiles.p90.toFixed(2)}ms`));
61
+ console.log(chalk.gray(` p95: ${result.percentiles.p95.toFixed(2)}ms`));
62
+ console.log(chalk.gray(` p99: ${result.percentiles.p99.toFixed(2)}ms`));
63
+ if (Object.keys(result.errors).length > 0) {
64
+ console.log();
65
+ console.log(chalk.bold('Errors:'));
66
+ for (const [error, count] of Object.entries(result.errors)) {
67
+ console.log(chalk.red(` ${count}x: ${error.substring(0, 100)}${error.length > 100 ? '...' : ''}`));
68
+ }
69
+ }
70
+ }
71
+ catch (error) {
72
+ spinner.fail(chalk.red('Load test failed'));
73
+ const message = error instanceof Error ? error.message : 'Unknown error';
74
+ console.error(chalk.red(message));
75
+ process.exit(1);
76
+ }
77
+ }
78
+ else {
79
+ const testOptions = {
80
+ agentName,
81
+ network: options.network || 'local',
82
+ testType,
83
+ watch: options.watch,
84
+ outputFormat: options.outputFormat,
85
+ verbose: options.verbose,
86
+ };
87
+ const spinner = ora(`Running ${testType} tests...`).start();
88
+ try {
89
+ const result = await runTests(testOptions);
90
+ spinner.succeed(chalk.green('Tests completed'));
91
+ if (typeof result === 'object' && 'total' in result) {
92
+ const testSuite = result;
93
+ console.log(chalk.bold('\nTest Summary:'));
94
+ console.log(chalk.gray(` Total: ${testSuite.total}`));
95
+ console.log(chalk.gray(` Passed: ${chalk.green(testSuite.passed)}`));
96
+ console.log(chalk.gray(` Failed: ${chalk.red(testSuite.failed)}`));
97
+ console.log(chalk.gray(` Skipped: ${chalk.yellow(testSuite.skipped)}`));
98
+ console.log(chalk.gray(` Duration: ${testSuite.duration}ms`));
99
+ }
100
+ }
101
+ catch (error) {
102
+ spinner.fail(chalk.red('Tests failed'));
103
+ const message = error instanceof Error ? error.message : 'Unknown error';
104
+ console.error(chalk.red(message));
105
+ process.exit(1);
106
+ }
107
+ }
108
+ });
109
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tokens Command
3
+ *
4
+ * Manage ICP and ICRC-1/ICRC-2 tokens.
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare function tokensCommand(): Command;
8
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Tokens Command
3
+ *
4
+ * Manage ICP and ICRC-1/ICRC-2 tokens.
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ import { checkBalance, transferTokens, } from '../../src/icp/tokens.js';
10
+ export function tokensCommand() {
11
+ const command = new Command('tokens');
12
+ command
13
+ .description('Manage ICP and ICRC-1/ICRC-2 tokens')
14
+ .action(() => {
15
+ command.outputHelp();
16
+ })
17
+ .addCommand(balanceSubcommand())
18
+ .addCommand(transferSubcommand());
19
+ return command;
20
+ }
21
+ async function executeBalance(options) {
22
+ const { canister } = options;
23
+ const spinner = ora(`Checking token balance for ${canister}...`).start();
24
+ try {
25
+ const result = await checkBalance(canister);
26
+ spinner.succeed(`Token balance checked for ${canister}`);
27
+ console.log();
28
+ console.log(chalk.cyan('Balance:'), result.stdout || 'N/A');
29
+ }
30
+ catch (error) {
31
+ spinner.fail(`Failed to check balance: ${error instanceof Error ? error.message : 'Unknown error'}`);
32
+ throw error;
33
+ }
34
+ }
35
+ async function executeTransfer(options) {
36
+ const { amount, to } = options;
37
+ const spinner = ora(`Transferring ${amount} tokens to ${to}...`).start();
38
+ try {
39
+ const result = await transferTokens(amount, to);
40
+ spinner.succeed(`${amount} tokens transferred successfully to ${to}`);
41
+ console.log();
42
+ console.log(chalk.cyan('Result:'), result.stdout || 'N/A');
43
+ }
44
+ catch (error) {
45
+ spinner.fail(`Failed to transfer tokens: ${error instanceof Error ? error.message : 'Unknown error'}`);
46
+ throw error;
47
+ }
48
+ }
49
+ function balanceSubcommand() {
50
+ return new Command('balance')
51
+ .description('Check token balance')
52
+ .option('-c, --canister <canister-id>', 'Token canister ID')
53
+ .action(executeBalance);
54
+ }
55
+ function transferSubcommand() {
56
+ return new Command('transfer')
57
+ .description('Transfer tokens to a recipient')
58
+ .argument('<amount>', 'Amount to transfer')
59
+ .argument('<to>', 'Recipient principal or account')
60
+ .action(executeTransfer);
61
+ }
62
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Trace CLI command
3
+ *
4
+ * Provides command for viewing execution traces from instrumented canisters
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const traceCmd: Command;
8
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Trace CLI command
3
+ *
4
+ * Provides command for viewing execution traces from instrumented canisters
5
+ */
6
+ import { Command } from 'commander';
7
+ import chalk from 'chalk';
8
+ import ora from 'ora';
9
+ export const traceCmd = new Command('trace');
10
+ traceCmd
11
+ .description('[Experimental] View execution traces from instrumented canisters')
12
+ .argument('<canister-id>', 'Canister ID')
13
+ .option('-f, --filter <method>', 'Filter by method name')
14
+ .option('-d, --min-duration <ms>', 'Minimum duration in milliseconds')
15
+ .option('--depth <n>', 'Maximum depth of call tree')
16
+ .option('--caller <principal>', 'Filter by caller principal')
17
+ .option('--export <file>', 'Export trace to file')
18
+ .option('--format <format>', 'Export format (json, flamegraph, text)', 'text')
19
+ .action(async (canisterId, options) => {
20
+ console.log(chalk.yellow('[Experimental] This feature is under active development and may change.'));
21
+ const spinner = ora(`Fetching traces for ${canisterId}...`).start();
22
+ try {
23
+ const filter = {};
24
+ if (options.filter) {
25
+ filter.method = options.filter;
26
+ }
27
+ if (options.minDuration) {
28
+ filter.minDuration = parseInt(options.minDuration, 10);
29
+ }
30
+ if (options.depth) {
31
+ filter.maxDepth = parseInt(options.depth, 10);
32
+ }
33
+ if (options.caller) {
34
+ filter.caller = options.caller;
35
+ }
36
+ spinner.succeed(chalk.green('Trace data loaded'));
37
+ console.log(chalk.bold(`\nExecution traces for ${canisterId}:`));
38
+ console.log(chalk.gray(' (Note: Requires instrumented WASM and trace collection)'));
39
+ console.log();
40
+ console.log(chalk.yellow('To collect traces:'));
41
+ console.log(chalk.gray(' 1. Run soulrecall instrument <wasm-file>'));
42
+ console.log(chalk.gray(' 2. Deploy instrumented WASM'));
43
+ console.log(chalk.gray(' 3. Canister will emit traces to stable memory'));
44
+ console.log();
45
+ if (options.method) {
46
+ console.log(chalk.bold(`Filter: method = ${options.method}`));
47
+ }
48
+ if (options.minDuration) {
49
+ console.log(chalk.bold(`Filter: min duration = ${options.minDuration}ms`));
50
+ }
51
+ if (options.depth) {
52
+ console.log(chalk.bold(`Filter: max depth = ${options.depth}`));
53
+ }
54
+ if (options.caller) {
55
+ console.log(chalk.bold(`Filter: caller = ${options.caller}`));
56
+ }
57
+ console.log();
58
+ console.log(chalk.yellow('Trace collection is not yet implemented in Phase 3.'));
59
+ console.log(chalk.gray('This will be available in a future update.'));
60
+ }
61
+ catch (error) {
62
+ spinner.fail(chalk.red('Failed to fetch traces'));
63
+ const message = error instanceof Error ? error.message : 'Unknown error';
64
+ console.error(chalk.red(message));
65
+ process.exit(1);
66
+ }
67
+ });
68
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Wallet Export Command
3
+ *
4
+ * Export all wallets for an agent to a backup file.
5
+ */
6
+ /**
7
+ * Handle wallet export command
8
+ */
9
+ export declare function handleExport(agentId: string, options?: {
10
+ format?: string;
11
+ output?: string;
12
+ }): Promise<void>;
13
+ //# sourceMappingURL=wallet-export.d.ts.map