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,215 @@
1
+ /**
2
+ * Environment Manager
3
+ *
4
+ * Manages ICP environment configurations from icp.yaml files.
5
+ * Supports multiple environments (local, dev, staging, production)
6
+ * with independent settings for network, cycles, identity, and optimization.
7
+ */
8
+
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ import YAML from 'yaml';
12
+ import type {
13
+ IcpProjectConfig,
14
+ IcpEnvironmentConfig,
15
+ IcpOptimizationConfig,
16
+ } from './types.js';
17
+
18
+ /**
19
+ * Default paths to search for icp.yaml configuration.
20
+ */
21
+ const CONFIG_SEARCH_PATHS = [
22
+ 'icp.yaml',
23
+ 'icp.yml',
24
+ '.agentvault/icp.yaml',
25
+ ];
26
+
27
+ /**
28
+ * Default environment configuration when nothing is specified.
29
+ */
30
+ const DEFAULT_LOCAL_ENV: IcpEnvironmentConfig = {
31
+ name: 'local',
32
+ network: { type: 'local' },
33
+ cycles: { initial: '100T' },
34
+ };
35
+
36
+ /**
37
+ * Default optimization settings.
38
+ */
39
+ const DEFAULT_OPTIMIZATION: IcpOptimizationConfig = {
40
+ enabled: true,
41
+ level: 3,
42
+ shrink: true,
43
+ removeDebug: true,
44
+ wasmOptFlags: ['--O3', '--dce', '--strip-debug'],
45
+ };
46
+
47
+ /**
48
+ * Find the icp.yaml configuration file by walking up from a starting directory.
49
+ *
50
+ * @param startDir - Directory to start searching from
51
+ * @returns Absolute path to icp.yaml, or null if not found
52
+ */
53
+ export function findConfigFile(startDir?: string): string | null {
54
+ const searchDir = startDir ? path.resolve(startDir) : process.cwd();
55
+
56
+ // Check each search path in the starting directory
57
+ for (const relPath of CONFIG_SEARCH_PATHS) {
58
+ const fullPath = path.join(searchDir, relPath);
59
+ if (fs.existsSync(fullPath)) {
60
+ return fullPath;
61
+ }
62
+ }
63
+
64
+ // Walk up the directory tree
65
+ const parent = path.dirname(searchDir);
66
+ if (parent !== searchDir) {
67
+ return findConfigFile(parent);
68
+ }
69
+
70
+ return null;
71
+ }
72
+
73
+ /**
74
+ * Load and parse icp.yaml configuration.
75
+ *
76
+ * @param configPath - Path to icp.yaml (if null, will search for it)
77
+ * @returns Parsed configuration, or null if not found
78
+ */
79
+ export function loadConfig(configPath?: string): IcpProjectConfig | null {
80
+ const resolvedPath = configPath ?? findConfigFile();
81
+ if (!resolvedPath || !fs.existsSync(resolvedPath)) {
82
+ return null;
83
+ }
84
+
85
+ try {
86
+ const content = fs.readFileSync(resolvedPath, 'utf-8');
87
+ const parsed = YAML.parse(content) as IcpProjectConfig;
88
+ return parsed;
89
+ } catch (error) {
90
+ const message = error instanceof Error ? error.message : 'Unknown error';
91
+ throw new Error(`Failed to parse icp.yaml at ${resolvedPath}: ${message}`);
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Get the configuration for a specific environment.
97
+ *
98
+ * Falls back to 'local' default if the environment is not defined.
99
+ *
100
+ * @param envName - Environment name
101
+ * @param config - Project configuration (will be loaded if not provided)
102
+ * @returns Environment configuration
103
+ */
104
+ export function getEnvironment(
105
+ envName: string,
106
+ config?: IcpProjectConfig | null,
107
+ ): IcpEnvironmentConfig {
108
+ const projectConfig = config ?? loadConfig();
109
+
110
+ if (projectConfig?.environments) {
111
+ const envConfig = projectConfig.environments[envName];
112
+ if (envConfig) {
113
+ return envConfig;
114
+ }
115
+ }
116
+
117
+ // Return defaults for known environment names
118
+ if (envName === 'local') {
119
+ return DEFAULT_LOCAL_ENV;
120
+ }
121
+
122
+ // For 'ic' or 'mainnet', return a mainnet default
123
+ if (envName === 'ic' || envName === 'mainnet') {
124
+ return {
125
+ name: envName,
126
+ network: { type: 'ic' },
127
+ cycles: { initial: '1T' },
128
+ };
129
+ }
130
+
131
+ // Unknown environment - return local defaults with a type based on name
132
+ return DEFAULT_LOCAL_ENV;
133
+ }
134
+
135
+ /**
136
+ * Get the optimization configuration.
137
+ *
138
+ * @param config - Project configuration (will be loaded if not provided)
139
+ * @returns Optimization configuration
140
+ */
141
+ export function getOptimizationConfig(
142
+ config?: IcpProjectConfig | null,
143
+ ): IcpOptimizationConfig {
144
+ const projectConfig = config ?? loadConfig();
145
+ return projectConfig?.optimization ?? DEFAULT_OPTIMIZATION;
146
+ }
147
+
148
+ /**
149
+ * List all defined environment names.
150
+ *
151
+ * @param config - Project configuration (will be loaded if not provided)
152
+ * @returns Array of environment names
153
+ */
154
+ export function listEnvironments(
155
+ config?: IcpProjectConfig | null,
156
+ ): string[] {
157
+ const projectConfig = config ?? loadConfig();
158
+ if (projectConfig?.environments) {
159
+ return Object.keys(projectConfig.environments);
160
+ }
161
+ return ['local'];
162
+ }
163
+
164
+ /**
165
+ * Write an icp.yaml configuration file.
166
+ *
167
+ * @param config - Configuration to write
168
+ * @param outputPath - Path to write to (defaults to ./icp.yaml)
169
+ */
170
+ export function writeConfig(
171
+ config: IcpProjectConfig,
172
+ outputPath?: string,
173
+ ): void {
174
+ const targetPath = outputPath ?? path.join(process.cwd(), 'icp.yaml');
175
+ const content = YAML.stringify(config, { indent: 2 });
176
+ fs.writeFileSync(targetPath, content, 'utf-8');
177
+ }
178
+
179
+ /**
180
+ * Generate a default icp.yaml configuration.
181
+ *
182
+ * @returns Default project configuration with local, dev, staging, production environments
183
+ */
184
+ export function generateDefaultConfig(): IcpProjectConfig {
185
+ return {
186
+ name: 'agentvault-project',
187
+ defaultEnvironment: 'local',
188
+ environments: {
189
+ local: {
190
+ name: 'local',
191
+ network: { type: 'local', replicaCount: 4 },
192
+ cycles: { initial: '100T' },
193
+ },
194
+ dev: {
195
+ name: 'dev',
196
+ network: { type: 'ic', replicaCount: 13 },
197
+ cycles: { initial: '1T' },
198
+ identity: 'dev-wallet',
199
+ },
200
+ staging: {
201
+ name: 'staging',
202
+ network: { type: 'ic', replicaCount: 28 },
203
+ cycles: { initial: '10T' },
204
+ identity: 'staging-wallet',
205
+ },
206
+ production: {
207
+ name: 'production',
208
+ network: { type: 'ic', replicaCount: 28 },
209
+ cycles: { initial: '100T' },
210
+ identity: 'main-wallet',
211
+ },
212
+ },
213
+ optimization: DEFAULT_OPTIMIZATION,
214
+ };
215
+ }
@@ -0,0 +1,438 @@
1
+ /**
2
+ * icp-cli Wrapper
3
+ *
4
+ * TypeScript wrapper around the icp CLI tool (v0.1.0).
5
+ * The binary name is `icp` (not `icp-cli`).
6
+ *
7
+ * Provides typed interfaces for build, deploy, canister operations,
8
+ * cycles management, identity management, network management,
9
+ * token operations, sync, and environment queries.
10
+ */
11
+
12
+ import { execa } from 'execa';
13
+ import type {
14
+ IcpCliResult,
15
+ IcpBuildOptions,
16
+ IcpDeployOptions,
17
+ IcpCanisterStatusOptions,
18
+ IcpCanisterCallOptions,
19
+ IcpCyclesBalanceOptions,
20
+ IcpCyclesMintOptions,
21
+ IcpCyclesTransferOptions,
22
+ IcpIdentityListOptions,
23
+ IcpIdentityNewOptions,
24
+ IcpIdentityExportOptions,
25
+ IcpIdentityImportOptions,
26
+ IcpNetworkStartOptions,
27
+ IcpNetworkStopOptions,
28
+ IcpSyncOptions,
29
+ IcpTokenBalanceOptions,
30
+ IcpTokenTransferOptions,
31
+ IcpEnvironmentListOptions,
32
+ IcpCommonOptions,
33
+ } from './types.js';
34
+
35
+ const ICP_BIN = 'icp';
36
+
37
+ /**
38
+ * Build common arguments from IcpCommonOptions.
39
+ */
40
+ function buildCommonArgs(options: IcpCommonOptions): string[] {
41
+ const args: string[] = [];
42
+ if (options.environment) {
43
+ args.push('-e', options.environment);
44
+ }
45
+ if (options.projectRoot) {
46
+ args.push('--project-root-override', options.projectRoot);
47
+ }
48
+ if (options.identity) {
49
+ args.push('--identity', options.identity);
50
+ }
51
+ if (options.identityPasswordFile) {
52
+ args.push('--identity-password-file', options.identityPasswordFile);
53
+ }
54
+ if (options.debug) {
55
+ args.push('--debug');
56
+ }
57
+ return args;
58
+ }
59
+
60
+ /**
61
+ * Execute an icp command and return the result.
62
+ *
63
+ * @param args - Command-line arguments (after 'icp')
64
+ * @param timeoutMs - Timeout in milliseconds (default 120s)
65
+ * @param cwd - Working directory
66
+ * @returns Structured result
67
+ */
68
+ async function runIcp(
69
+ args: string[],
70
+ timeoutMs = 120_000,
71
+ cwd?: string,
72
+ ): Promise<IcpCliResult> {
73
+ try {
74
+ const result = await execa(ICP_BIN, args, {
75
+ reject: false,
76
+ timeout: timeoutMs,
77
+ cwd,
78
+ });
79
+ return {
80
+ success: result.exitCode === 0,
81
+ stdout: result.stdout,
82
+ stderr: result.stderr,
83
+ exitCode: result.exitCode ?? 1,
84
+ };
85
+ } catch (error) {
86
+ const message = error instanceof Error ? error.message : 'Unknown error';
87
+ return {
88
+ success: false,
89
+ stdout: '',
90
+ stderr: message,
91
+ exitCode: 1,
92
+ };
93
+ }
94
+ }
95
+
96
+ // ─── Build ─────────────────────────────────────────────────────────────────
97
+
98
+ /**
99
+ * Build canisters using icp build.
100
+ *
101
+ * @param options - Build options
102
+ * @returns Command result
103
+ */
104
+ export async function build(options: IcpBuildOptions = {}): Promise<IcpCliResult> {
105
+ const args = ['build', ...buildCommonArgs(options)];
106
+ if (options.canisters && options.canisters.length > 0) {
107
+ args.push(...options.canisters);
108
+ }
109
+ return runIcp(args, 300_000, options.projectRoot);
110
+ }
111
+
112
+ // ─── Deploy ────────────────────────────────────────────────────────────────
113
+
114
+ /**
115
+ * Deploy project to an environment.
116
+ *
117
+ * @param options - Deploy options
118
+ * @returns Command result
119
+ */
120
+ export async function deploy(options: IcpDeployOptions = {}): Promise<IcpCliResult> {
121
+ const args = ['deploy', ...buildCommonArgs(options)];
122
+ if (options.mode) {
123
+ args.push('-m', options.mode);
124
+ }
125
+ if (options.canisters && options.canisters.length > 0) {
126
+ args.push(...options.canisters);
127
+ }
128
+ return runIcp(args, 300_000, options.projectRoot);
129
+ }
130
+
131
+ // ─── Canister Operations ───────────────────────────────────────────────────
132
+
133
+ /**
134
+ * Get canister status.
135
+ *
136
+ * @param options - Canister status options
137
+ * @returns Command result with status in stdout
138
+ */
139
+ export async function canisterStatus(options: IcpCanisterStatusOptions): Promise<IcpCliResult> {
140
+ const args = ['canister', 'status', options.canister, ...buildCommonArgs(options)];
141
+ return runIcp(args, 30_000, options.projectRoot);
142
+ }
143
+
144
+ /**
145
+ * Call a canister method.
146
+ *
147
+ * @param options - Canister call options
148
+ * @returns Command result with response in stdout
149
+ */
150
+ export async function canisterCall(options: IcpCanisterCallOptions): Promise<IcpCliResult> {
151
+ const args = ['canister', 'call', options.canister, options.method, ...buildCommonArgs(options)];
152
+ if (options.args) {
153
+ args.push(options.args);
154
+ }
155
+ return runIcp(args, 30_000, options.projectRoot);
156
+ }
157
+
158
+ /**
159
+ * List canisters in the project.
160
+ *
161
+ * @param options - Common options
162
+ * @returns Command result with canister list in stdout
163
+ */
164
+ export async function canisterList(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
165
+ const args = ['canister', 'list', ...buildCommonArgs(options)];
166
+ return runIcp(args, 15_000, options.projectRoot);
167
+ }
168
+
169
+ /**
170
+ * Start a stopped canister.
171
+ *
172
+ * @param canister - Canister ID or name
173
+ * @param options - Common options
174
+ * @returns Command result
175
+ */
176
+ export async function canisterStart(canister: string, options: IcpCommonOptions = {}): Promise<IcpCliResult> {
177
+ const args = ['canister', 'start', canister, ...buildCommonArgs(options)];
178
+ return runIcp(args, 30_000, options.projectRoot);
179
+ }
180
+
181
+ /**
182
+ * Stop a running canister.
183
+ *
184
+ * @param canister - Canister ID or name
185
+ * @param options - Common options
186
+ * @returns Command result
187
+ */
188
+ export async function canisterStop(canister: string, options: IcpCommonOptions = {}): Promise<IcpCliResult> {
189
+ const args = ['canister', 'stop', canister, ...buildCommonArgs(options)];
190
+ return runIcp(args, 30_000, options.projectRoot);
191
+ }
192
+
193
+ /**
194
+ * Delete a canister.
195
+ *
196
+ * @param canister - Canister ID or name
197
+ * @param options - Common options
198
+ * @returns Command result
199
+ */
200
+ export async function canisterDelete(canister: string, options: IcpCommonOptions = {}): Promise<IcpCliResult> {
201
+ const args = ['canister', 'delete', canister, ...buildCommonArgs(options)];
202
+ return runIcp(args, 30_000, options.projectRoot);
203
+ }
204
+
205
+ // ─── Cycles Management ────────────────────────────────────────────────────
206
+
207
+ /**
208
+ * Check cycle balance of a canister.
209
+ *
210
+ * @param options - Cycles balance options
211
+ * @returns Command result with balance in stdout
212
+ */
213
+ export async function cyclesBalance(options: IcpCyclesBalanceOptions): Promise<IcpCliResult> {
214
+ const args = ['cycles', 'balance', options.canister, ...buildCommonArgs(options)];
215
+ return runIcp(args, 15_000, options.projectRoot);
216
+ }
217
+
218
+ /**
219
+ * Mint cycles.
220
+ *
221
+ * @param options - Mint options
222
+ * @returns Command result
223
+ */
224
+ export async function cyclesMint(options: IcpCyclesMintOptions): Promise<IcpCliResult> {
225
+ const args = ['cycles', 'mint', options.amount, ...buildCommonArgs(options)];
226
+ return runIcp(args, 30_000, options.projectRoot);
227
+ }
228
+
229
+ /**
230
+ * Transfer cycles to a canister.
231
+ *
232
+ * @param options - Transfer options
233
+ * @returns Command result
234
+ */
235
+ export async function cyclesTransfer(options: IcpCyclesTransferOptions): Promise<IcpCliResult> {
236
+ const args = ['cycles', 'transfer', options.amount, '--to', options.to, ...buildCommonArgs(options)];
237
+ return runIcp(args, 30_000, options.projectRoot);
238
+ }
239
+
240
+ // ─── Identity Management ──────────────────────────────────────────────────
241
+
242
+ /**
243
+ * List available identities.
244
+ *
245
+ * @param options - Common options
246
+ * @returns Command result with identity list in stdout
247
+ */
248
+ export async function identityList(options: IcpIdentityListOptions = {}): Promise<IcpCliResult> {
249
+ const args = ['identity', 'list', ...buildCommonArgs(options)];
250
+ return runIcp(args, 15_000, options.projectRoot);
251
+ }
252
+
253
+ /**
254
+ * Create a new identity.
255
+ *
256
+ * @param options - New identity options
257
+ * @returns Command result
258
+ */
259
+ export async function identityNew(options: IcpIdentityNewOptions): Promise<IcpCliResult> {
260
+ const args = ['identity', 'new', ...(options.name ? [options.name] : []), ...buildCommonArgs(options)];
261
+ return runIcp(args, 15_000, options.projectRoot);
262
+ }
263
+
264
+ /**
265
+ * Export an identity.
266
+ *
267
+ * @param options - Export options
268
+ * @returns Command result with PEM data in stdout
269
+ */
270
+ export async function identityExport(options: IcpIdentityExportOptions): Promise<IcpCliResult> {
271
+ const args = ['identity', 'export', ...(options.name ? [options.name] : []), ...buildCommonArgs(options)];
272
+ return runIcp(args, 15_000, options.projectRoot);
273
+ }
274
+
275
+ /**
276
+ * Import an identity from a PEM file.
277
+ *
278
+ * @param options - Import options
279
+ * @returns Command result
280
+ */
281
+ export async function identityImport(options: IcpIdentityImportOptions): Promise<IcpCliResult> {
282
+ const args = ['identity', 'import', ...(options.name ? [options.name] : []), ...(options.pemFile ? [options.pemFile] : []), ...buildCommonArgs(options)];
283
+ return runIcp(args, 15_000, options.projectRoot);
284
+ }
285
+
286
+ /**
287
+ * Get the principal of the current or named identity.
288
+ *
289
+ * @param options - Common options (use identity field to specify which identity)
290
+ * @returns Command result with principal in stdout
291
+ */
292
+ export async function identityPrincipal(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
293
+ const args = ['identity', 'principal', ...buildCommonArgs(options)];
294
+ return runIcp(args, 15_000, options.projectRoot);
295
+ }
296
+
297
+ /**
298
+ * Get the default identity name.
299
+ *
300
+ * @param options - Common options
301
+ * @returns Command result with default identity name in stdout
302
+ */
303
+ export async function identityDefault(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
304
+ const args = ['identity', 'default', ...buildCommonArgs(options)];
305
+ return runIcp(args, 15_000, options.projectRoot);
306
+ }
307
+
308
+ // ─── Network Management ───────────────────────────────────────────────────
309
+
310
+ /**
311
+ * Start a local test network.
312
+ *
313
+ * @param options - Network start options
314
+ * @returns Command result
315
+ */
316
+ export async function networkStart(options: IcpNetworkStartOptions = {}): Promise<IcpCliResult> {
317
+ const args = ['network', 'start', ...buildCommonArgs(options)];
318
+ if (options.network) {
319
+ args.push(options.network);
320
+ }
321
+ return runIcp(args, 60_000, options.projectRoot);
322
+ }
323
+
324
+ /**
325
+ * Stop a local test network.
326
+ *
327
+ * @param options - Network stop options
328
+ * @returns Command result
329
+ */
330
+ export async function networkStop(options: IcpNetworkStopOptions = {}): Promise<IcpCliResult> {
331
+ const args = ['network', 'stop', ...buildCommonArgs(options)];
332
+ if (options.network) {
333
+ args.push(options.network);
334
+ }
335
+ return runIcp(args, 30_000, options.projectRoot);
336
+ }
337
+
338
+ /**
339
+ * Get network status.
340
+ *
341
+ * @param options - Common options
342
+ * @returns Command result with status in stdout
343
+ */
344
+ export async function networkStatus(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
345
+ const args = ['network', 'status', ...buildCommonArgs(options)];
346
+ return runIcp(args, 15_000, options.projectRoot);
347
+ }
348
+
349
+ /**
350
+ * List available networks.
351
+ *
352
+ * @param options - Common options
353
+ * @returns Command result with network list in stdout
354
+ */
355
+ export async function networkList(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
356
+ const args = ['network', 'list', ...buildCommonArgs(options)];
357
+ return runIcp(args, 15_000, options.projectRoot);
358
+ }
359
+
360
+ /**
361
+ * Ping a network to check connectivity.
362
+ *
363
+ * @param options - Common options
364
+ * @returns Command result
365
+ */
366
+ export async function networkPing(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
367
+ const args = ['network', 'ping', ...buildCommonArgs(options)];
368
+ return runIcp(args, 15_000, options.projectRoot);
369
+ }
370
+
371
+ // ─── Sync ──────────────────────────────────────────────────────────────────
372
+
373
+ /**
374
+ * Synchronize canisters with the network.
375
+ *
376
+ * @param options - Sync options
377
+ * @returns Command result
378
+ */
379
+ export async function sync(options: IcpSyncOptions = {}): Promise<IcpCliResult> {
380
+ const args = ['sync', ...buildCommonArgs(options)];
381
+ return runIcp(args, 120_000, options.projectRoot);
382
+ }
383
+
384
+ // ─── Token Operations ─────────────────────────────────────────────────────
385
+
386
+ /**
387
+ * Get token balance.
388
+ *
389
+ * @param options - Token balance options
390
+ * @returns Command result with balance in stdout
391
+ */
392
+ export async function tokenBalance(options: IcpTokenBalanceOptions = {}): Promise<IcpCliResult> {
393
+ const args = ['token', 'balance', ...buildCommonArgs(options)];
394
+ if (options.canister) {
395
+ args.push('--canister', options.canister);
396
+ }
397
+ return runIcp(args, 15_000, options.projectRoot);
398
+ }
399
+
400
+ /**
401
+ * Transfer tokens.
402
+ *
403
+ * @param options - Token transfer options
404
+ * @returns Command result
405
+ */
406
+ export async function tokenTransfer(options: IcpTokenTransferOptions): Promise<IcpCliResult> {
407
+ const args = ['token', 'transfer', options.amount, '--to', options.to, ...buildCommonArgs(options)];
408
+ if (options.canister) {
409
+ args.push('--canister', options.canister);
410
+ }
411
+ return runIcp(args, 30_000, options.projectRoot);
412
+ }
413
+
414
+ // ─── Environment ──────────────────────────────────────────────────────────
415
+
416
+ /**
417
+ * List project environments.
418
+ *
419
+ * @param options - Common options
420
+ * @returns Command result with environments in stdout
421
+ */
422
+ export async function environmentList(options: IcpEnvironmentListOptions = {}): Promise<IcpCliResult> {
423
+ const args = ['environment', 'list', ...buildCommonArgs(options)];
424
+ return runIcp(args, 15_000, options.projectRoot);
425
+ }
426
+
427
+ // ─── Project ──────────────────────────────────────────────────────────────
428
+
429
+ /**
430
+ * Show project information (effective YAML config).
431
+ *
432
+ * @param options - Common options
433
+ * @returns Command result with project info in stdout
434
+ */
435
+ export async function projectShow(options: IcpCommonOptions = {}): Promise<IcpCliResult> {
436
+ const args = ['project', 'show', ...buildCommonArgs(options)];
437
+ return runIcp(args, 15_000, options.projectRoot);
438
+ }