agentvault 1.0.0 → 1.0.2
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.
- package/.claude/settings.local.json +9 -0
- package/README.md +1 -1
- package/dist/cli/commands/approve.js +5 -5
- package/dist/cli/commands/archive.js +5 -5
- package/dist/cli/commands/backup.js +5 -5
- package/dist/cli/commands/cloud-backup.js +12 -12
- package/dist/cli/commands/decrypt.js +2 -2
- package/dist/cli/commands/deploy.js +1 -1
- package/dist/cli/commands/exec.js +2 -2
- package/dist/cli/commands/fetch.js +4 -4
- package/dist/cli/commands/inference.js +5 -5
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.js +16 -16
- package/dist/cli/commands/list.js +4 -4
- package/dist/cli/commands/package.js +2 -2
- package/dist/cli/commands/profile.js +1 -1
- package/dist/cli/commands/rebuild.js +2 -2
- package/dist/cli/commands/show.js +1 -1
- package/dist/cli/commands/status.d.ts +1 -1
- package/dist/cli/commands/status.js +8 -8
- package/dist/cli/commands/trace.js +1 -1
- package/dist/cli/commands/wallet-export.js +1 -1
- package/dist/cli/commands/wallet-sign.js +1 -1
- package/dist/cli/commands/wallet.d.ts +1 -1
- package/dist/cli/commands/wallet.js +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +3 -3
- package/dist/src/archival/archive-manager.d.ts +85 -0
- package/dist/src/archival/archive-manager.js +294 -0
- package/dist/src/archival/arweave-client.d.ts +88 -0
- package/dist/src/archival/arweave-client.js +223 -0
- package/dist/src/archival/index.d.ts +8 -0
- package/{src/archival/index.ts → dist/src/archival/index.js} +1 -1
- package/dist/src/backup/backup.d.ts +67 -0
- package/dist/src/backup/backup.js +231 -0
- package/dist/src/backup/index.d.ts +7 -0
- package/{src/backup/index.ts → dist/src/backup/index.js} +1 -1
- package/dist/src/cloud-storage/cloud-sync.d.ts +49 -0
- package/dist/src/cloud-storage/cloud-sync.js +372 -0
- package/dist/src/cloud-storage/index.d.ts +11 -0
- package/{src/cloud-storage/index.ts → dist/src/cloud-storage/index.js} +1 -1
- package/dist/src/cloud-storage/provider-detector.d.ts +34 -0
- package/dist/src/cloud-storage/provider-detector.js +158 -0
- package/{src/cloud-storage/types.ts → dist/src/cloud-storage/types.d.ts} +40 -53
- package/dist/src/cloud-storage/types.js +10 -0
- package/dist/src/debugging/index.d.ts +6 -0
- package/{src/debugging/index.ts → dist/src/debugging/index.js} +1 -1
- package/dist/src/debugging/logs.d.ts +32 -0
- package/dist/src/debugging/logs.js +158 -0
- package/dist/src/debugging/types.d.ts +91 -0
- package/dist/src/debugging/types.js +5 -0
- package/dist/src/deployment/deployer.d.ts +52 -0
- package/dist/src/deployment/deployer.js +211 -0
- package/dist/src/deployment/icpClient.d.ts +144 -0
- package/dist/src/deployment/icpClient.js +545 -0
- package/dist/src/deployment/index.d.ts +11 -0
- package/dist/src/deployment/index.js +14 -0
- package/dist/src/deployment/promotion.d.ts +32 -0
- package/dist/src/deployment/promotion.js +114 -0
- package/dist/src/deployment/types.d.ts +101 -0
- package/dist/src/deployment/types.js +5 -0
- package/dist/src/icp/batch.d.ts +112 -0
- package/dist/src/icp/batch.js +273 -0
- package/dist/src/icp/cycles.d.ts +29 -0
- package/{src/icp/cycles.ts → dist/src/icp/cycles.js} +8 -22
- package/dist/src/icp/environment.d.ts +60 -0
- package/dist/src/icp/environment.js +183 -0
- package/dist/src/icp/icpcli.d.ts +204 -0
- package/dist/src/icp/icpcli.js +374 -0
- package/dist/src/icp/icwasm.d.ts +94 -0
- package/dist/src/icp/icwasm.js +197 -0
- package/dist/src/icp/identity.d.ts +50 -0
- package/{src/icp/identity.ts → dist/src/icp/identity.js} +15 -28
- package/dist/src/icp/index.d.ts +16 -0
- package/dist/src/icp/index.js +20 -0
- package/dist/src/icp/optimization.d.ts +16 -0
- package/dist/src/icp/optimization.js +225 -0
- package/dist/src/icp/tokens.d.ts +24 -0
- package/{src/icp/tokens.ts → dist/src/icp/tokens.js} +5 -12
- package/dist/src/icp/tool-detector.d.ts +31 -0
- package/dist/src/icp/tool-detector.js +104 -0
- package/dist/src/icp/types.d.ts +493 -0
- package/dist/src/icp/types.js +7 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +18 -0
- package/dist/src/inference/bittensor-client.d.ts +108 -0
- package/dist/src/inference/bittensor-client.js +224 -0
- package/dist/src/inference/index.d.ts +8 -0
- package/{src/inference/index.ts → dist/src/inference/index.js} +1 -1
- package/dist/src/inference/inference-manager.d.ts +76 -0
- package/dist/src/inference/inference-manager.js +228 -0
- package/dist/src/metrics/index.d.ts +7 -0
- package/{src/metrics/index.ts → dist/src/metrics/index.js} +1 -1
- package/dist/src/metrics/metrics.d.ts +39 -0
- package/dist/src/metrics/metrics.js +129 -0
- package/dist/src/monitoring/alerting.d.ts +51 -0
- package/dist/src/monitoring/alerting.js +169 -0
- package/dist/src/monitoring/health.d.ts +40 -0
- package/dist/src/monitoring/health.js +164 -0
- package/dist/src/monitoring/index.d.ts +10 -0
- package/dist/src/monitoring/index.js +12 -0
- package/dist/src/monitoring/info.d.ts +15 -0
- package/dist/src/monitoring/info.js +109 -0
- package/dist/src/monitoring/types.d.ts +93 -0
- package/dist/src/monitoring/types.js +7 -0
- package/dist/src/network/index.d.ts +5 -0
- package/{src/network/index.ts → dist/src/network/index.js} +1 -1
- package/dist/src/network/network-config.d.ts +31 -0
- package/dist/src/network/network-config.js +109 -0
- package/dist/src/packaging/compiler.d.ts +61 -0
- package/dist/src/packaging/compiler.js +562 -0
- package/dist/src/packaging/config-persistence.d.ts +46 -0
- package/dist/src/packaging/config-persistence.js +108 -0
- package/dist/src/packaging/config-schemas.d.ts +115 -0
- package/dist/src/packaging/config-schemas.js +43 -0
- package/dist/src/packaging/detector.d.ts +26 -0
- package/dist/src/packaging/detector.js +193 -0
- package/dist/src/packaging/index.d.ts +16 -0
- package/dist/src/packaging/index.js +22 -0
- package/dist/src/packaging/packager.d.ts +31 -0
- package/dist/src/packaging/packager.js +90 -0
- package/dist/src/packaging/parsers/clawdbot.d.ts +19 -0
- package/dist/src/packaging/parsers/clawdbot.js +231 -0
- package/dist/src/packaging/parsers/cline.d.ts +26 -0
- package/dist/src/packaging/parsers/cline.js +185 -0
- package/dist/src/packaging/parsers/generic.d.ts +27 -0
- package/dist/src/packaging/parsers/generic.js +228 -0
- package/dist/src/packaging/parsers/goose.d.ts +26 -0
- package/dist/src/packaging/parsers/goose.js +175 -0
- package/dist/src/packaging/parsers/index.d.ts +11 -0
- package/{src/packaging/parsers/index.ts → dist/src/packaging/parsers/index.js} +1 -1
- package/dist/src/packaging/serializer.d.ts +108 -0
- package/dist/src/packaging/serializer.js +153 -0
- package/dist/src/packaging/types.d.ts +131 -0
- package/dist/src/packaging/types.js +5 -0
- package/dist/src/packaging/wasmedge-compiler.d.ts +76 -0
- package/dist/src/packaging/wasmedge-compiler.js +349 -0
- package/dist/src/security/index.d.ts +11 -0
- package/{src/security/index.ts → dist/src/security/index.js} +1 -4
- package/dist/src/security/multisig.d.ts +102 -0
- package/dist/src/security/multisig.js +283 -0
- package/dist/src/security/types.d.ts +207 -0
- package/dist/src/security/types.js +217 -0
- package/dist/src/security/vetkeys.d.ts +179 -0
- package/dist/src/security/vetkeys.js +499 -0
- package/dist/src/testing/index.d.ts +6 -0
- package/{src/testing/index.ts → dist/src/testing/index.js} +1 -1
- package/dist/src/testing/local-runner.d.ts +23 -0
- package/dist/src/testing/local-runner.js +226 -0
- package/dist/src/testing/types.d.ts +98 -0
- package/dist/src/testing/types.js +5 -0
- package/dist/src/wallet/cbor-serializer.d.ts +82 -0
- package/dist/src/wallet/cbor-serializer.js +282 -0
- package/dist/src/wallet/chain-dispatcher.d.ts +112 -0
- package/dist/src/wallet/chain-dispatcher.js +241 -0
- package/dist/src/wallet/cross-chain-aggregator.d.ts +119 -0
- package/dist/src/wallet/cross-chain-aggregator.js +235 -0
- package/dist/src/wallet/index.d.ts +16 -0
- package/dist/src/wallet/index.js +22 -0
- package/dist/src/wallet/key-derivation.d.ts +117 -0
- package/dist/src/wallet/key-derivation.js +325 -0
- package/dist/src/wallet/providers/base-provider.d.ts +111 -0
- package/dist/src/wallet/providers/base-provider.js +58 -0
- package/dist/src/wallet/providers/cketh-provider.d.ts +104 -0
- package/dist/src/wallet/providers/cketh-provider.js +343 -0
- package/dist/src/wallet/providers/polkadot-provider.d.ts +115 -0
- package/dist/src/wallet/providers/polkadot-provider.js +407 -0
- package/dist/src/wallet/providers/solana-provider.d.ts +102 -0
- package/dist/src/wallet/providers/solana-provider.js +393 -0
- package/dist/src/wallet/transaction-queue.d.ts +133 -0
- package/dist/src/wallet/transaction-queue.js +195 -0
- package/dist/src/wallet/types.d.ts +167 -0
- package/dist/src/wallet/types.js +5 -0
- package/dist/src/wallet/vetkeys-adapter.d.ts +134 -0
- package/dist/src/wallet/vetkeys-adapter.js +313 -0
- package/dist/src/wallet/wallet-manager.d.ts +202 -0
- package/dist/src/wallet/wallet-manager.js +451 -0
- package/dist/src/wallet/wallet-storage.d.ts +131 -0
- package/dist/src/wallet/wallet-storage.js +274 -0
- package/macos-wallet-app/AgentVaultWallet/App/AgentVaultWalletApp.swift +54 -0
- package/macos-wallet-app/AgentVaultWallet/Models/AppState.swift +102 -0
- package/macos-wallet-app/AgentVaultWallet/Models/Chain.swift +121 -0
- package/macos-wallet-app/AgentVaultWallet/Models/Wallet.swift +98 -0
- package/macos-wallet-app/AgentVaultWallet/Resources/AgentVaultWallet.entitlements +27 -0
- package/macos-wallet-app/AgentVaultWallet/Resources/Info.plist +69 -0
- package/macos-wallet-app/AgentVaultWallet/Services/BackupService.swift +270 -0
- package/macos-wallet-app/AgentVaultWallet/Services/CLIBridge.swift +367 -0
- package/macos-wallet-app/AgentVaultWallet/Services/CryptoService.swift +157 -0
- package/macos-wallet-app/AgentVaultWallet/Services/FileService.swift +120 -0
- package/macos-wallet-app/AgentVaultWallet/Services/KeychainService.swift +219 -0
- package/macos-wallet-app/AgentVaultWallet/Utilities/Constants.swift +44 -0
- package/macos-wallet-app/AgentVaultWallet/Utilities/Extensions.swift +115 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/BackupViewModel.swift +237 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/CreateWalletViewModel.swift +137 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/ImportWalletViewModel.swift +179 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/WalletStore.swift +286 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Backup/BackupView.swift +235 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Backup/RestoreView.swift +316 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Create/CreateWalletFlow.swift +438 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Import/ImportWalletFlow.swift +399 -0
- package/macos-wallet-app/AgentVaultWallet/Views/MainView.swift +134 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Settings/SettingsView.swift +276 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Sidebar/SidebarView.swift +133 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Wallet/DashboardView.swift +233 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Wallet/WalletDetailView.swift +281 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Wallet/WalletListView.swift +280 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Welcome/WelcomeView.swift +176 -0
- package/macos-wallet-app/Makefile +47 -0
- package/macos-wallet-app/project.yml +40 -0
- package/macos-wallet-app/setup.sh +73 -0
- package/package.json +10 -2
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-28-967Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-29-032Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-373Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-428Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-132Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-247Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-216Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-283Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-772Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-793Z.json +0 -28
- package/backups/test-backup.json +0 -28
- package/scripts/dev-dashboard.mjs +0 -84
- package/site/README.md +0 -63
- package/site/docusaurus.config.ts +0 -148
- package/site/package-lock.json +0 -18383
- package/site/package.json +0 -47
- package/site/sidebars.ts +0 -86
- package/site/static/.gitkeep +0 -0
- package/site/static/img/logo.svg +0 -28
- package/site/static/img/og-image.svg +0 -35
- package/src/archival/archive-manager.ts +0 -372
- package/src/archival/arweave-client.ts +0 -289
- package/src/backup/backup.ts +0 -315
- package/src/cloud-storage/cloud-sync.ts +0 -461
- package/src/cloud-storage/provider-detector.ts +0 -198
- package/src/debugging/logs.ts +0 -193
- package/src/debugging/types.ts +0 -100
- package/src/deployment/deployer.ts +0 -274
- package/src/deployment/icpClient.ts +0 -620
- package/src/deployment/index.ts +0 -46
- package/src/deployment/promotion.ts +0 -161
- package/src/deployment/types.ts +0 -111
- package/src/icp/batch.ts +0 -374
- package/src/icp/environment.ts +0 -215
- package/src/icp/icpcli.ts +0 -438
- package/src/icp/icwasm.ts +0 -222
- package/src/icp/index.ts +0 -94
- package/src/icp/optimization.ts +0 -242
- package/src/icp/tool-detector.ts +0 -110
- package/src/icp/types.ts +0 -574
- package/src/index.ts +0 -25
- package/src/inference/bittensor-client.ts +0 -304
- package/src/inference/inference-manager.ts +0 -327
- package/src/metrics/metrics.ts +0 -186
- package/src/monitoring/alerting.ts +0 -190
- package/src/monitoring/health.ts +0 -197
- package/src/monitoring/index.ts +0 -38
- package/src/monitoring/info.ts +0 -114
- package/src/monitoring/types.ts +0 -99
- package/src/network/network-config.ts +0 -129
- package/src/packaging/compiler.ts +0 -647
- package/src/packaging/config-persistence.ts +0 -135
- package/src/packaging/config-schemas.ts +0 -156
- package/src/packaging/detector.ts +0 -220
- package/src/packaging/index.ts +0 -90
- package/src/packaging/packager.ts +0 -118
- package/src/packaging/parsers/clawdbot.ts +0 -278
- package/src/packaging/parsers/cline.ts +0 -223
- package/src/packaging/parsers/generic.ts +0 -266
- package/src/packaging/parsers/goose.ts +0 -214
- package/src/packaging/serializer.ts +0 -260
- package/src/packaging/types.ts +0 -144
- package/src/packaging/wasmedge-compiler.ts +0 -406
- package/src/security/multisig.ts +0 -415
- package/src/security/types.ts +0 -416
- package/src/security/vetkeys.ts +0 -655
- package/src/testing/local-runner.ts +0 -264
- package/src/testing/types.ts +0 -104
- package/src/wallet/cbor-serializer.ts +0 -323
- package/src/wallet/chain-dispatcher.ts +0 -313
- package/src/wallet/cross-chain-aggregator.ts +0 -346
- package/src/wallet/index.ts +0 -76
- package/src/wallet/key-derivation.ts +0 -425
- package/src/wallet/providers/base-provider.ts +0 -154
- package/src/wallet/providers/cketh-provider.ts +0 -434
- package/src/wallet/providers/polkadot-provider.ts +0 -503
- package/src/wallet/providers/solana-provider.ts +0 -490
- package/src/wallet/transaction-queue.ts +0 -284
- package/src/wallet/types.ts +0 -178
- package/src/wallet/vetkeys-adapter.ts +0 -431
- package/src/wallet/wallet-manager.ts +0 -597
- package/src/wallet/wallet-storage.ts +0 -380
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Management
|
|
3
|
+
*
|
|
4
|
+
* Provides identity management via icp-cli.
|
|
5
|
+
* List identities, create new identities,
|
|
6
|
+
* import/export identities and manage default identity.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* List all available identities.
|
|
10
|
+
*
|
|
11
|
+
* @returns Command result with identity list
|
|
12
|
+
*/
|
|
13
|
+
export declare function listIdentities(): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new identity.
|
|
16
|
+
*
|
|
17
|
+
* @param name - Identity name
|
|
18
|
+
* @returns Command result
|
|
19
|
+
*/
|
|
20
|
+
export declare function createIdentity(name: string): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Export an identity to PEM file.
|
|
23
|
+
*
|
|
24
|
+
* @param name - Identity name
|
|
25
|
+
* @returns Command result with PEM content
|
|
26
|
+
*/
|
|
27
|
+
export declare function exportIdentity(name: string): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the principal of a default or named identity.
|
|
30
|
+
*
|
|
31
|
+
* @param name - Identity name (if null, use default)
|
|
32
|
+
* @returns Command result with principal
|
|
33
|
+
*/
|
|
34
|
+
export declare function getIdentityPrincipal(name?: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Import an identity from a PEM file.
|
|
37
|
+
*
|
|
38
|
+
* @param name - Identity name to import
|
|
39
|
+
* @param pemFile - Path to PEM file
|
|
40
|
+
* @returns Command result
|
|
41
|
+
*/
|
|
42
|
+
export declare function importIdentity(name: string, pemFile: string): Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Set a default identity.
|
|
45
|
+
*
|
|
46
|
+
* @param name - Identity name to set as default
|
|
47
|
+
* @returns Command result
|
|
48
|
+
*/
|
|
49
|
+
export declare function setDefaultIdentity(name: string): Promise<any>;
|
|
50
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -5,56 +5,43 @@
|
|
|
5
5
|
* List identities, create new identities,
|
|
6
6
|
* import/export identities and manage default identity.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
identityList,
|
|
11
|
-
identityNew,
|
|
12
|
-
identityExport,
|
|
13
|
-
identityPrincipal,
|
|
14
|
-
identityImport,
|
|
15
|
-
identityDefault,
|
|
16
|
-
} from './icpcli.js';
|
|
17
|
-
|
|
8
|
+
import { identityList, identityNew, identityExport, identityPrincipal, identityImport, identityDefault, } from './icpcli.js';
|
|
18
9
|
/**
|
|
19
10
|
* List all available identities.
|
|
20
11
|
*
|
|
21
12
|
* @returns Command result with identity list
|
|
22
13
|
*/
|
|
23
|
-
export async function listIdentities()
|
|
24
|
-
|
|
14
|
+
export async function listIdentities() {
|
|
15
|
+
return identityList({});
|
|
25
16
|
}
|
|
26
|
-
|
|
27
17
|
/**
|
|
28
18
|
* Create a new identity.
|
|
29
19
|
*
|
|
30
20
|
* @param name - Identity name
|
|
31
21
|
* @returns Command result
|
|
32
22
|
*/
|
|
33
|
-
export async function createIdentity(name
|
|
34
|
-
|
|
23
|
+
export async function createIdentity(name) {
|
|
24
|
+
return identityNew({ name });
|
|
35
25
|
}
|
|
36
|
-
|
|
37
26
|
/**
|
|
38
27
|
* Export an identity to PEM file.
|
|
39
28
|
*
|
|
40
29
|
* @param name - Identity name
|
|
41
30
|
* @returns Command result with PEM content
|
|
42
31
|
*/
|
|
43
|
-
export async function exportIdentity(name
|
|
44
|
-
|
|
32
|
+
export async function exportIdentity(name) {
|
|
33
|
+
return identityExport({ name });
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
/**
|
|
48
36
|
* Get the principal of a default or named identity.
|
|
49
37
|
*
|
|
50
38
|
* @param name - Identity name (if null, use default)
|
|
51
39
|
* @returns Command result with principal
|
|
52
40
|
*/
|
|
53
|
-
export async function getIdentityPrincipal(name
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
export async function getIdentityPrincipal(name) {
|
|
42
|
+
const result = await identityPrincipal({ name });
|
|
43
|
+
return result.stdout || '';
|
|
56
44
|
}
|
|
57
|
-
|
|
58
45
|
/**
|
|
59
46
|
* Import an identity from a PEM file.
|
|
60
47
|
*
|
|
@@ -62,16 +49,16 @@ export async function getIdentityPrincipal(name?: string): Promise<string> {
|
|
|
62
49
|
* @param pemFile - Path to PEM file
|
|
63
50
|
* @returns Command result
|
|
64
51
|
*/
|
|
65
|
-
export async function importIdentity(name
|
|
66
|
-
|
|
52
|
+
export async function importIdentity(name, pemFile) {
|
|
53
|
+
return identityImport({ name, pemFile });
|
|
67
54
|
}
|
|
68
|
-
|
|
69
55
|
/**
|
|
70
56
|
* Set a default identity.
|
|
71
57
|
*
|
|
72
58
|
* @param name - Identity name to set as default
|
|
73
59
|
* @returns Command result
|
|
74
60
|
*/
|
|
75
|
-
export async function setDefaultIdentity(name
|
|
76
|
-
|
|
61
|
+
export async function setDefaultIdentity(name) {
|
|
62
|
+
return identityDefault({ name });
|
|
77
63
|
}
|
|
64
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ICP Tools Integration Module
|
|
3
|
+
*
|
|
4
|
+
* Provides typed wrappers around ic-wasm and icp-cli tooling,
|
|
5
|
+
* auto-detection of available tools, an optimization pipeline,
|
|
6
|
+
* and environment management.
|
|
7
|
+
*/
|
|
8
|
+
export type { ToolName, ToolInfo, ToolchainStatus, IcWasmOptLevel, IcWasmOptimizeOptions, IcWasmShrinkOptions, IcWasmResourceOptions, IcWasmMetadataOptions, IcWasmCheckEndpointsOptions, IcWasmInstrumentOptions, IcWasmResult, IcWasmInfo, MetadataVisibility, IcWasmOptimizationResult, IcWasmOptimizationPipelineOptions, IcWasmOptimizationPipelineResult, IcpEnvironment, IcpDeployMode, IcpCommonOptions, IcpBuildOptions, IcpDeployOptions, IcpCanisterStatusOptions, IcpCanisterCallOptions, IcpCyclesBalanceOptions, IcpCyclesMintOptions, IcpCyclesTransferOptions, IcpIdentityListOptions, IcpIdentityNewOptions, IcpIdentityExportOptions, IcpIdentityImportOptions, IcpNetworkStartOptions, IcpNetworkStopOptions, IcpSyncOptions, IcpTokenBalanceOptions, IcpTokenTransferOptions, IcpEnvironmentListOptions, IcpCliResult, IcpNetworkConfig, IcpCyclesConfig, IcpEnvironmentConfig, IcpOptimizationConfig, IcpProjectConfig, } from './types.js';
|
|
9
|
+
export type { CanisterHealthStatus, AlertSeverity, CanisterStatusInfo, MonitoringAlert, HealthThresholds, MonitoringOptions, ResourceUsageSnapshot, } from '../monitoring/types.js';
|
|
10
|
+
export { detectTool, detectToolchain, requireTool, } from './tool-detector.js';
|
|
11
|
+
export * as icwasm from './icwasm.js';
|
|
12
|
+
export * as icpcli from './icpcli.js';
|
|
13
|
+
export { runOptimizationPipeline } from './optimization.js';
|
|
14
|
+
export { findConfigFile, loadConfig, getEnvironment, getOptimizationConfig, listEnvironments, writeConfig, generateDefaultConfig, } from './environment.js';
|
|
15
|
+
export * from './batch.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ICP Tools Integration Module
|
|
3
|
+
*
|
|
4
|
+
* Provides typed wrappers around ic-wasm and icp-cli tooling,
|
|
5
|
+
* auto-detection of available tools, an optimization pipeline,
|
|
6
|
+
* and environment management.
|
|
7
|
+
*/
|
|
8
|
+
// Tool detection
|
|
9
|
+
export { detectTool, detectToolchain, requireTool, } from './tool-detector.js';
|
|
10
|
+
// ic-wasm wrapper
|
|
11
|
+
export * as icwasm from './icwasm.js';
|
|
12
|
+
// icp-cli wrapper
|
|
13
|
+
export * as icpcli from './icpcli.js';
|
|
14
|
+
// Optimization pipeline
|
|
15
|
+
export { runOptimizationPipeline } from './optimization.js';
|
|
16
|
+
// Environment management
|
|
17
|
+
export { findConfigFile, loadConfig, getEnvironment, getOptimizationConfig, listEnvironments, writeConfig, generateDefaultConfig, } from './environment.js';
|
|
18
|
+
// Batched canister operations
|
|
19
|
+
export * from './batch.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimization Pipeline
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates ic-wasm optimize, shrink, resource limiting, metadata
|
|
5
|
+
* injection, and Candid validation into a single pipeline that runs
|
|
6
|
+
* after WASM generation in the packaging step.
|
|
7
|
+
*/
|
|
8
|
+
import type { IcWasmOptimizationPipelineOptions, IcWasmOptimizationPipelineResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Run the full optimization pipeline on a WASM file.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Pipeline options
|
|
13
|
+
* @returns Pipeline result with metrics
|
|
14
|
+
*/
|
|
15
|
+
export declare function runOptimizationPipeline(options: IcWasmOptimizationPipelineOptions): Promise<IcWasmOptimizationPipelineResult>;
|
|
16
|
+
//# sourceMappingURL=optimization.d.ts.map
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimization Pipeline
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates ic-wasm optimize, shrink, resource limiting, metadata
|
|
5
|
+
* injection, and Candid validation into a single pipeline that runs
|
|
6
|
+
* after WASM generation in the packaging step.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'node:fs';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
import { detectTool } from './tool-detector.js';
|
|
11
|
+
import * as icwasm from './icwasm.js';
|
|
12
|
+
/**
|
|
13
|
+
* Run the full optimization pipeline on a WASM file.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Pipeline options
|
|
16
|
+
* @returns Pipeline result with metrics
|
|
17
|
+
*/
|
|
18
|
+
export async function runOptimizationPipeline(options) {
|
|
19
|
+
const startTime = Date.now();
|
|
20
|
+
const steps = [];
|
|
21
|
+
const warnings = [];
|
|
22
|
+
let currentInput = options.input;
|
|
23
|
+
// Verify input exists
|
|
24
|
+
if (!fs.existsSync(options.input)) {
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
outputPath: options.output,
|
|
28
|
+
originalSize: 0,
|
|
29
|
+
finalSize: 0,
|
|
30
|
+
reductionPercent: 0,
|
|
31
|
+
totalDurationMs: Date.now() - startTime,
|
|
32
|
+
steps: [],
|
|
33
|
+
warnings: [`Input file not found: ${options.input}`],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const originalSize = fs.statSync(options.input).size;
|
|
37
|
+
// Check if ic-wasm is available
|
|
38
|
+
const icWasmTool = await detectTool('ic-wasm');
|
|
39
|
+
if (!icWasmTool.available) {
|
|
40
|
+
// No optimization possible - copy input to output
|
|
41
|
+
fs.copyFileSync(options.input, options.output);
|
|
42
|
+
warnings.push('ic-wasm not found; skipping optimization. Install with: cargo install ic-wasm');
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
outputPath: options.output,
|
|
46
|
+
originalSize,
|
|
47
|
+
finalSize: originalSize,
|
|
48
|
+
reductionPercent: 0,
|
|
49
|
+
totalDurationMs: Date.now() - startTime,
|
|
50
|
+
steps: [],
|
|
51
|
+
warnings,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Create temp directory for intermediate files
|
|
55
|
+
const tempDir = path.join(path.dirname(options.output), '.icp-optimize-tmp');
|
|
56
|
+
if (!fs.existsSync(tempDir)) {
|
|
57
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
let tempCounter = 0;
|
|
60
|
+
function nextTemp() {
|
|
61
|
+
return path.join(tempDir, `step_${++tempCounter}.wasm`);
|
|
62
|
+
}
|
|
63
|
+
// Step 1: Shrink
|
|
64
|
+
if (options.shrink !== false) {
|
|
65
|
+
const stepStart = Date.now();
|
|
66
|
+
const tempOut = nextTemp();
|
|
67
|
+
const result = await icwasm.shrink({ input: currentInput, output: tempOut });
|
|
68
|
+
const step = {
|
|
69
|
+
step: 'shrink',
|
|
70
|
+
success: result.success,
|
|
71
|
+
durationMs: Date.now() - stepStart,
|
|
72
|
+
sizeAfter: undefined,
|
|
73
|
+
error: undefined,
|
|
74
|
+
};
|
|
75
|
+
if (result.success && fs.existsSync(tempOut)) {
|
|
76
|
+
step.sizeAfter = fs.statSync(tempOut).size;
|
|
77
|
+
currentInput = tempOut;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
step.error = result.stderr || 'Shrink failed';
|
|
81
|
+
warnings.push(`Shrink step failed: ${step.error}`);
|
|
82
|
+
}
|
|
83
|
+
steps.push(step);
|
|
84
|
+
}
|
|
85
|
+
// Step 2: Optimize
|
|
86
|
+
if (options.optimize !== false) {
|
|
87
|
+
const stepStart = Date.now();
|
|
88
|
+
const tempOut = nextTemp();
|
|
89
|
+
const level = options.optimizeLevel ?? 'O3';
|
|
90
|
+
const result = await icwasm.optimize({
|
|
91
|
+
input: currentInput,
|
|
92
|
+
output: tempOut,
|
|
93
|
+
level,
|
|
94
|
+
});
|
|
95
|
+
const step = {
|
|
96
|
+
step: `optimize (${level})`,
|
|
97
|
+
success: result.success,
|
|
98
|
+
durationMs: Date.now() - stepStart,
|
|
99
|
+
sizeAfter: undefined,
|
|
100
|
+
error: undefined,
|
|
101
|
+
};
|
|
102
|
+
if (result.success && fs.existsSync(tempOut)) {
|
|
103
|
+
step.sizeAfter = fs.statSync(tempOut).size;
|
|
104
|
+
currentInput = tempOut;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
step.error = result.stderr || 'Optimize failed';
|
|
108
|
+
warnings.push(`Optimize step failed: ${step.error}`);
|
|
109
|
+
}
|
|
110
|
+
steps.push(step);
|
|
111
|
+
}
|
|
112
|
+
// Step 3: Resource limits
|
|
113
|
+
if (options.resourceLimits && Object.keys(options.resourceLimits).length > 0) {
|
|
114
|
+
for (const [name, value] of Object.entries(options.resourceLimits)) {
|
|
115
|
+
const stepStart = Date.now();
|
|
116
|
+
const tempOut = nextTemp();
|
|
117
|
+
const result = await icwasm.setResource({
|
|
118
|
+
input: currentInput,
|
|
119
|
+
output: tempOut,
|
|
120
|
+
name,
|
|
121
|
+
value,
|
|
122
|
+
});
|
|
123
|
+
const step = {
|
|
124
|
+
step: `resource (${name}=${value})`,
|
|
125
|
+
success: result.success,
|
|
126
|
+
durationMs: Date.now() - stepStart,
|
|
127
|
+
sizeAfter: undefined,
|
|
128
|
+
error: undefined,
|
|
129
|
+
};
|
|
130
|
+
if (result.success && fs.existsSync(tempOut)) {
|
|
131
|
+
step.sizeAfter = fs.statSync(tempOut).size;
|
|
132
|
+
currentInput = tempOut;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
step.error = result.stderr || 'Resource limit failed';
|
|
136
|
+
warnings.push(`Resource limit '${name}' failed: ${step.error}`);
|
|
137
|
+
}
|
|
138
|
+
steps.push(step);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Step 4: Metadata injection
|
|
142
|
+
if (options.metadata && options.metadata.length > 0) {
|
|
143
|
+
for (const meta of options.metadata) {
|
|
144
|
+
const stepStart = Date.now();
|
|
145
|
+
const tempOut = nextTemp();
|
|
146
|
+
const result = await icwasm.setMetadata({
|
|
147
|
+
input: currentInput,
|
|
148
|
+
output: tempOut,
|
|
149
|
+
name: meta.name,
|
|
150
|
+
data: meta.data,
|
|
151
|
+
visibility: meta.visibility,
|
|
152
|
+
});
|
|
153
|
+
const step = {
|
|
154
|
+
step: `metadata (${meta.name})`,
|
|
155
|
+
success: result.success,
|
|
156
|
+
durationMs: Date.now() - stepStart,
|
|
157
|
+
sizeAfter: undefined,
|
|
158
|
+
error: undefined,
|
|
159
|
+
};
|
|
160
|
+
if (result.success && fs.existsSync(tempOut)) {
|
|
161
|
+
step.sizeAfter = fs.statSync(tempOut).size;
|
|
162
|
+
currentInput = tempOut;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
step.error = result.stderr || 'Metadata set failed';
|
|
166
|
+
warnings.push(`Metadata '${meta.name}' failed: ${step.error}`);
|
|
167
|
+
}
|
|
168
|
+
steps.push(step);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Step 5: Candid validation (does not produce output, just validates)
|
|
172
|
+
let validationPassed;
|
|
173
|
+
if (options.candidInterface) {
|
|
174
|
+
const stepStart = Date.now();
|
|
175
|
+
const result = await icwasm.checkEndpoints({
|
|
176
|
+
input: currentInput,
|
|
177
|
+
candidInterface: options.candidInterface,
|
|
178
|
+
});
|
|
179
|
+
validationPassed = result.success;
|
|
180
|
+
const step = {
|
|
181
|
+
step: 'check-endpoints',
|
|
182
|
+
success: result.success,
|
|
183
|
+
durationMs: Date.now() - stepStart,
|
|
184
|
+
sizeAfter: undefined,
|
|
185
|
+
error: undefined,
|
|
186
|
+
};
|
|
187
|
+
if (!result.success) {
|
|
188
|
+
step.error = result.stderr || 'Endpoint validation failed';
|
|
189
|
+
warnings.push(`Candid validation failed: ${step.error}`);
|
|
190
|
+
}
|
|
191
|
+
steps.push(step);
|
|
192
|
+
}
|
|
193
|
+
// Move final result to output path
|
|
194
|
+
if (currentInput !== options.input) {
|
|
195
|
+
fs.copyFileSync(currentInput, options.output);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// No steps modified the file; copy input to output
|
|
199
|
+
fs.copyFileSync(options.input, options.output);
|
|
200
|
+
}
|
|
201
|
+
const finalSize = fs.statSync(options.output).size;
|
|
202
|
+
// Cleanup temp directory
|
|
203
|
+
try {
|
|
204
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
// Ignore cleanup errors
|
|
208
|
+
}
|
|
209
|
+
const reductionPercent = originalSize > 0
|
|
210
|
+
? Math.round(((originalSize - finalSize) / originalSize) * 100)
|
|
211
|
+
: 0;
|
|
212
|
+
const allStepsSucceeded = steps.every((s) => s.success);
|
|
213
|
+
return {
|
|
214
|
+
success: allStepsSucceeded,
|
|
215
|
+
outputPath: options.output,
|
|
216
|
+
originalSize,
|
|
217
|
+
finalSize,
|
|
218
|
+
reductionPercent,
|
|
219
|
+
totalDurationMs: Date.now() - startTime,
|
|
220
|
+
steps,
|
|
221
|
+
validationPassed,
|
|
222
|
+
warnings,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=optimization.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Operations
|
|
3
|
+
*
|
|
4
|
+
* Provides token operations via icp-cli.
|
|
5
|
+
* Supports ICP and ICRC-1/ICRC-2 tokens.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Check token balance for a canister.
|
|
9
|
+
*
|
|
10
|
+
* @param canister - Token canister ID
|
|
11
|
+
* @param options - Common ICP options
|
|
12
|
+
* @returns Command result with balance
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkBalance(canister: string): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Transfer tokens to a recipient.
|
|
17
|
+
*
|
|
18
|
+
* @param amount - Amount to transfer
|
|
19
|
+
* @param to - Recipient principal or account
|
|
20
|
+
* @param options - Common ICP options
|
|
21
|
+
* @returns Command result
|
|
22
|
+
*/
|
|
23
|
+
export declare function transferTokens(amount: string, to: string): Promise<any>;
|
|
24
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* Provides token operations via icp-cli.
|
|
5
5
|
* Supports ICP and ICRC-1/ICRC-2 tokens.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import { tokenBalance, tokenTransfer } from './icpcli.js';
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Check token balance for a canister.
|
|
12
10
|
*
|
|
@@ -14,12 +12,9 @@ import { tokenBalance, tokenTransfer } from './icpcli.js';
|
|
|
14
12
|
* @param options - Common ICP options
|
|
15
13
|
* @returns Command result with balance
|
|
16
14
|
*/
|
|
17
|
-
export async function checkBalance(
|
|
18
|
-
|
|
19
|
-
): Promise<any> {
|
|
20
|
-
return tokenBalance({ canister });
|
|
15
|
+
export async function checkBalance(canister) {
|
|
16
|
+
return tokenBalance({ canister });
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
/**
|
|
24
19
|
* Transfer tokens to a recipient.
|
|
25
20
|
*
|
|
@@ -28,9 +23,7 @@ export async function checkBalance(
|
|
|
28
23
|
* @param options - Common ICP options
|
|
29
24
|
* @returns Command result
|
|
30
25
|
*/
|
|
31
|
-
export async function transferTokens(
|
|
32
|
-
|
|
33
|
-
to: string,
|
|
34
|
-
): Promise<any> {
|
|
35
|
-
return tokenTransfer({ amount, to });
|
|
26
|
+
export async function transferTokens(amount, to) {
|
|
27
|
+
return tokenTransfer({ amount, to });
|
|
36
28
|
}
|
|
29
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Detector
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects availability of ICP tools (ic-wasm, icp, dfx)
|
|
5
|
+
* on the current system. Used for hybrid compatibility strategy:
|
|
6
|
+
* prefer icp-cli when available, fall back to dfx.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolName, ToolInfo, ToolchainStatus } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Detect whether a single tool is installed and get its version.
|
|
11
|
+
*
|
|
12
|
+
* @param name - Tool binary name
|
|
13
|
+
* @returns ToolInfo with availability, path, and version
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectTool(name: ToolName): Promise<ToolInfo>;
|
|
16
|
+
/**
|
|
17
|
+
* Detect all ICP tools and determine the preferred toolchain.
|
|
18
|
+
*
|
|
19
|
+
* @returns Complete toolchain status
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectToolchain(): Promise<ToolchainStatus>;
|
|
22
|
+
/**
|
|
23
|
+
* Require a specific tool, throwing a descriptive error if not found.
|
|
24
|
+
*
|
|
25
|
+
* @param name - Tool to require
|
|
26
|
+
* @param purpose - Human-readable description of why it's needed
|
|
27
|
+
* @returns ToolInfo (guaranteed available)
|
|
28
|
+
* @throws Error if tool is not available
|
|
29
|
+
*/
|
|
30
|
+
export declare function requireTool(name: ToolName, purpose: string): Promise<ToolInfo>;
|
|
31
|
+
//# sourceMappingURL=tool-detector.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Detector
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects availability of ICP tools (ic-wasm, icp, dfx)
|
|
5
|
+
* on the current system. Used for hybrid compatibility strategy:
|
|
6
|
+
* prefer icp-cli when available, fall back to dfx.
|
|
7
|
+
*/
|
|
8
|
+
import { execaCommand } from 'execa';
|
|
9
|
+
/**
|
|
10
|
+
* Detect whether a single tool is installed and get its version.
|
|
11
|
+
*
|
|
12
|
+
* @param name - Tool binary name
|
|
13
|
+
* @returns ToolInfo with availability, path, and version
|
|
14
|
+
*/
|
|
15
|
+
export async function detectTool(name) {
|
|
16
|
+
const result = { name, available: false };
|
|
17
|
+
// Locate the binary
|
|
18
|
+
try {
|
|
19
|
+
const whichResult = await execaCommand(`which ${name}`, {
|
|
20
|
+
reject: false,
|
|
21
|
+
timeout: 5000,
|
|
22
|
+
});
|
|
23
|
+
if (whichResult.exitCode === 0 && whichResult.stdout.trim()) {
|
|
24
|
+
result.path = whichResult.stdout.trim();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
// Get the version
|
|
34
|
+
try {
|
|
35
|
+
const versionResult = await execaCommand(`${name} --version`, {
|
|
36
|
+
reject: false,
|
|
37
|
+
timeout: 5000,
|
|
38
|
+
});
|
|
39
|
+
if (versionResult.exitCode === 0) {
|
|
40
|
+
const output = versionResult.stdout.trim() || versionResult.stderr.trim();
|
|
41
|
+
// Extract version number from output like "ic-wasm 0.9.11" or "icp 0.1.0" or "dfx 0.25.0"
|
|
42
|
+
const match = output.match(/(\d+\.\d+\.\d+)/);
|
|
43
|
+
if (match) {
|
|
44
|
+
result.version = match[1];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
result.version = output;
|
|
48
|
+
}
|
|
49
|
+
result.available = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Binary exists but version check failed - still mark as available
|
|
54
|
+
result.available = !!result.path;
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Detect all ICP tools and determine the preferred toolchain.
|
|
60
|
+
*
|
|
61
|
+
* @returns Complete toolchain status
|
|
62
|
+
*/
|
|
63
|
+
export async function detectToolchain() {
|
|
64
|
+
const [icWasm, icp, dfx] = await Promise.all([
|
|
65
|
+
detectTool('ic-wasm'),
|
|
66
|
+
detectTool('icp'),
|
|
67
|
+
detectTool('dfx'),
|
|
68
|
+
]);
|
|
69
|
+
let preferredDeployTool = null;
|
|
70
|
+
if (icp.available) {
|
|
71
|
+
preferredDeployTool = 'icp';
|
|
72
|
+
}
|
|
73
|
+
else if (dfx.available) {
|
|
74
|
+
preferredDeployTool = 'dfx';
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
icWasm,
|
|
78
|
+
icp,
|
|
79
|
+
dfx,
|
|
80
|
+
preferredDeployTool,
|
|
81
|
+
canOptimize: icWasm.available,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Require a specific tool, throwing a descriptive error if not found.
|
|
86
|
+
*
|
|
87
|
+
* @param name - Tool to require
|
|
88
|
+
* @param purpose - Human-readable description of why it's needed
|
|
89
|
+
* @returns ToolInfo (guaranteed available)
|
|
90
|
+
* @throws Error if tool is not available
|
|
91
|
+
*/
|
|
92
|
+
export async function requireTool(name, purpose) {
|
|
93
|
+
const tool = await detectTool(name);
|
|
94
|
+
if (!tool.available) {
|
|
95
|
+
const installHints = {
|
|
96
|
+
'ic-wasm': 'Install with: cargo install ic-wasm',
|
|
97
|
+
'icp': 'Install from: https://github.com/dfinity/icp-cli',
|
|
98
|
+
'dfx': 'Install with: sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"',
|
|
99
|
+
};
|
|
100
|
+
throw new Error(`Tool '${name}' is required for ${purpose} but was not found.\n${installHints[name]}`);
|
|
101
|
+
}
|
|
102
|
+
return tool;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=tool-detector.js.map
|