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.
- package/.dfx/local/network-id +4 -0
- package/.next/trace +2 -0
- package/.vercel/README.txt +11 -0
- package/.vercel/project.json +1 -0
- package/AGENTS.md +43 -0
- package/CHANGELOG.md +196 -0
- package/LICENSE +21 -0
- package/PLAN_VAULT_INTEGRATION.md +318 -0
- package/README.md +253 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-28-967Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-29-032Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-373Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-428Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-132Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-247Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-216Z.json +28 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-283Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-772Z.backup +1 -0
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-793Z.json +28 -0
- package/backups/test-backup.json +28 -0
- package/dist/cli/commands/approve.d.ts +4 -0
- package/dist/cli/commands/approve.js +232 -0
- package/dist/cli/commands/archive.d.ts +4 -0
- package/dist/cli/commands/archive.js +192 -0
- package/dist/cli/commands/backup.d.ts +4 -0
- package/dist/cli/commands/backup.js +164 -0
- package/dist/cli/commands/cloud-backup.d.ts +4 -0
- package/dist/cli/commands/cloud-backup.js +221 -0
- package/dist/cli/commands/cycles.d.ts +8 -0
- package/dist/cli/commands/cycles.js +83 -0
- package/dist/cli/commands/decrypt.d.ts +16 -0
- package/dist/cli/commands/decrypt.js +101 -0
- package/dist/cli/commands/deploy.d.ts +32 -0
- package/dist/cli/commands/deploy.js +208 -0
- package/dist/cli/commands/exec.d.ts +26 -0
- package/dist/cli/commands/exec.js +109 -0
- package/dist/cli/commands/fetch.d.ts +23 -0
- package/dist/cli/commands/fetch.js +164 -0
- package/dist/cli/commands/health.d.ts +8 -0
- package/dist/cli/commands/health.js +72 -0
- package/dist/cli/commands/identity.d.ts +8 -0
- package/dist/cli/commands/identity.js +140 -0
- package/dist/cli/commands/inference.d.ts +4 -0
- package/dist/cli/commands/inference.js +225 -0
- package/dist/cli/commands/info.d.ts +8 -0
- package/dist/cli/commands/info.js +59 -0
- package/dist/cli/commands/init.d.ts +19 -0
- package/dist/cli/commands/init.js +135 -0
- package/dist/cli/commands/instrument.d.ts +8 -0
- package/dist/cli/commands/instrument.js +35 -0
- package/dist/cli/commands/list.d.ts +36 -0
- package/dist/cli/commands/list.js +173 -0
- package/dist/cli/commands/logs.d.ts +8 -0
- package/dist/cli/commands/logs.js +96 -0
- package/dist/cli/commands/monitor.d.ts +8 -0
- package/dist/cli/commands/monitor.js +84 -0
- package/dist/cli/commands/network.d.ts +14 -0
- package/dist/cli/commands/network.js +258 -0
- package/dist/cli/commands/package.d.ts +36 -0
- package/dist/cli/commands/package.js +188 -0
- package/dist/cli/commands/profile.d.ts +8 -0
- package/dist/cli/commands/profile.js +76 -0
- package/dist/cli/commands/promote.d.ts +8 -0
- package/dist/cli/commands/promote.js +89 -0
- package/dist/cli/commands/rebuild.d.ts +21 -0
- package/dist/cli/commands/rebuild.js +140 -0
- package/dist/cli/commands/rollback.d.ts +8 -0
- package/dist/cli/commands/rollback.js +120 -0
- package/dist/cli/commands/show.d.ts +36 -0
- package/dist/cli/commands/show.js +200 -0
- package/dist/cli/commands/stats.d.ts +8 -0
- package/dist/cli/commands/stats.js +34 -0
- package/dist/cli/commands/status.d.ts +14 -0
- package/dist/cli/commands/status.js +83 -0
- package/dist/cli/commands/test.d.ts +8 -0
- package/dist/cli/commands/test.js +109 -0
- package/dist/cli/commands/tokens.d.ts +8 -0
- package/dist/cli/commands/tokens.js +62 -0
- package/dist/cli/commands/trace.d.ts +8 -0
- package/dist/cli/commands/trace.js +68 -0
- package/dist/cli/commands/wallet-export.d.ts +13 -0
- package/dist/cli/commands/wallet-export.js +140 -0
- package/dist/cli/commands/wallet-history.d.ts +10 -0
- package/dist/cli/commands/wallet-history.js +127 -0
- package/dist/cli/commands/wallet-import.d.ts +10 -0
- package/dist/cli/commands/wallet-import.js +209 -0
- package/dist/cli/commands/wallet-multi-send.d.ts +17 -0
- package/dist/cli/commands/wallet-multi-send.js +195 -0
- package/dist/cli/commands/wallet-process-queue.d.ts +19 -0
- package/dist/cli/commands/wallet-process-queue.js +209 -0
- package/dist/cli/commands/wallet-sign.d.ts +13 -0
- package/dist/cli/commands/wallet-sign.js +207 -0
- package/dist/cli/commands/wallet.d.ts +12 -0
- package/dist/cli/commands/wallet.js +794 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.js +96 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.js +14 -0
- package/fixup_1_0_OSS_release.md +136 -0
- package/fixup_REALEASE_PRD.md +136 -0
- package/package.json +79 -0
- package/pnpm-workspace.yaml +5 -0
- package/scripts/dev-dashboard.mjs +84 -0
- package/site/README.md +63 -0
- package/site/docusaurus.config.ts +148 -0
- package/site/package-lock.json +18383 -0
- package/site/package.json +47 -0
- package/site/sidebars.ts +86 -0
- package/site/static/.gitkeep +0 -0
- package/site/static/img/logo.svg +28 -0
- package/site/static/img/og-image.svg +35 -0
- package/src/archival/archive-manager.ts +372 -0
- package/src/archival/arweave-client.ts +289 -0
- package/src/archival/index.ts +8 -0
- package/src/backup/backup.ts +315 -0
- package/src/backup/index.ts +7 -0
- package/src/cloud-storage/cloud-sync.ts +461 -0
- package/src/cloud-storage/index.ts +11 -0
- package/src/cloud-storage/provider-detector.ts +198 -0
- package/src/cloud-storage/types.ts +104 -0
- package/src/debugging/index.ts +6 -0
- package/src/debugging/logs.ts +193 -0
- package/src/debugging/types.ts +100 -0
- package/src/deployment/deployer.ts +274 -0
- package/src/deployment/icpClient.ts +620 -0
- package/src/deployment/index.ts +46 -0
- package/src/deployment/promotion.ts +161 -0
- package/src/deployment/types.ts +111 -0
- package/src/icp/batch.ts +374 -0
- package/src/icp/cycles.ts +50 -0
- package/src/icp/environment.ts +215 -0
- package/src/icp/icpcli.ts +438 -0
- package/src/icp/icwasm.ts +222 -0
- package/src/icp/identity.ts +77 -0
- package/src/icp/index.ts +94 -0
- package/src/icp/optimization.ts +242 -0
- package/src/icp/tokens.ts +36 -0
- package/src/icp/tool-detector.ts +110 -0
- package/src/icp/types.ts +574 -0
- package/src/index.ts +25 -0
- package/src/inference/bittensor-client.ts +304 -0
- package/src/inference/index.ts +8 -0
- package/src/inference/inference-manager.ts +327 -0
- package/src/metrics/index.ts +7 -0
- package/src/metrics/metrics.ts +186 -0
- package/src/monitoring/alerting.ts +190 -0
- package/src/monitoring/health.ts +197 -0
- package/src/monitoring/index.ts +38 -0
- package/src/monitoring/info.ts +114 -0
- package/src/monitoring/types.ts +99 -0
- package/src/network/index.ts +5 -0
- package/src/network/network-config.ts +129 -0
- package/src/packaging/compiler.ts +647 -0
- package/src/packaging/config-persistence.ts +135 -0
- package/src/packaging/config-schemas.ts +156 -0
- package/src/packaging/detector.ts +220 -0
- package/src/packaging/index.ts +90 -0
- package/src/packaging/packager.ts +118 -0
- package/src/packaging/parsers/clawdbot.ts +278 -0
- package/src/packaging/parsers/cline.ts +223 -0
- package/src/packaging/parsers/generic.ts +266 -0
- package/src/packaging/parsers/goose.ts +214 -0
- package/src/packaging/parsers/index.ts +11 -0
- package/src/packaging/serializer.ts +260 -0
- package/src/packaging/types.ts +144 -0
- package/src/packaging/wasmedge-compiler.ts +406 -0
- package/src/security/index.ts +17 -0
- package/src/security/multisig.ts +415 -0
- package/src/security/types.ts +416 -0
- package/src/security/vetkeys.ts +655 -0
- package/src/testing/index.ts +6 -0
- package/src/testing/local-runner.ts +264 -0
- package/src/testing/types.ts +104 -0
- package/src/wallet/cbor-serializer.ts +323 -0
- package/src/wallet/chain-dispatcher.ts +313 -0
- package/src/wallet/cross-chain-aggregator.ts +346 -0
- package/src/wallet/index.ts +76 -0
- package/src/wallet/key-derivation.ts +425 -0
- package/src/wallet/providers/base-provider.ts +154 -0
- package/src/wallet/providers/cketh-provider.ts +434 -0
- package/src/wallet/providers/polkadot-provider.ts +503 -0
- package/src/wallet/providers/solana-provider.ts +490 -0
- package/src/wallet/transaction-queue.ts +284 -0
- package/src/wallet/types.ts +178 -0
- package/src/wallet/vetkeys-adapter.ts +431 -0
- package/src/wallet/wallet-manager.ts +597 -0
- package/src/wallet/wallet-storage.ts +380 -0
- package/vercel.json +8 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List command - List all agents
|
|
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
|
+
/**
|
|
10
|
+
* Get list of all agents
|
|
11
|
+
*/
|
|
12
|
+
export async function getAgents(options) {
|
|
13
|
+
const agents = [];
|
|
14
|
+
// Get agents from local filesystem
|
|
15
|
+
const localAgents = await getLocalAgents();
|
|
16
|
+
if (options.local || !options.deployed) {
|
|
17
|
+
agents.push(...localAgents);
|
|
18
|
+
}
|
|
19
|
+
// In a real implementation, this would query deployed canisters
|
|
20
|
+
if (options.deployed || options.all) {
|
|
21
|
+
const deployedAgents = await getDeployedAgents();
|
|
22
|
+
agents.push(...deployedAgents);
|
|
23
|
+
}
|
|
24
|
+
return agents;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get local agents from filesystem
|
|
28
|
+
*/
|
|
29
|
+
async function getLocalAgents() {
|
|
30
|
+
const agents = [];
|
|
31
|
+
// Check for soulrecall directory
|
|
32
|
+
const agentDir = path.join(process.cwd(), '.soulrecall');
|
|
33
|
+
if (fs.existsSync(agentDir)) {
|
|
34
|
+
const agentsDir = path.join(agentDir, 'agents');
|
|
35
|
+
if (fs.existsSync(agentsDir)) {
|
|
36
|
+
const entries = fs.readdirSync(agentsDir, { withFileTypes: true });
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
if (entry.isDirectory()) {
|
|
39
|
+
const agentPath = path.join(agentsDir, entry.name);
|
|
40
|
+
const stateFile = path.join(agentPath, 'state.json');
|
|
41
|
+
if (fs.existsSync(stateFile)) {
|
|
42
|
+
try {
|
|
43
|
+
const state = JSON.parse(fs.readFileSync(stateFile, 'utf-8'));
|
|
44
|
+
agents.push({
|
|
45
|
+
name: entry.name,
|
|
46
|
+
type: state.agent?.type || 'generic',
|
|
47
|
+
sourcePath: agentPath,
|
|
48
|
+
deployed: false,
|
|
49
|
+
lastUpdated: state.metadata?.createdAt,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Skip invalid state files
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Also check for dist directories with WASM files
|
|
61
|
+
const distDir = path.join(process.cwd(), 'dist');
|
|
62
|
+
if (fs.existsSync(distDir)) {
|
|
63
|
+
const entries = fs.readdirSync(distDir);
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
if (entry.endsWith('.wasm')) {
|
|
66
|
+
const name = entry.replace('.wasm', '');
|
|
67
|
+
const stateFile = path.join(distDir, `${name}.state.json`);
|
|
68
|
+
if (fs.existsSync(stateFile)) {
|
|
69
|
+
try {
|
|
70
|
+
const state = JSON.parse(fs.readFileSync(stateFile, 'utf-8'));
|
|
71
|
+
agents.push({
|
|
72
|
+
name,
|
|
73
|
+
type: state.agent?.type || 'generic',
|
|
74
|
+
sourcePath: process.cwd(),
|
|
75
|
+
deployed: false,
|
|
76
|
+
lastUpdated: state.metadata?.createdAt,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
agents.push({
|
|
81
|
+
name,
|
|
82
|
+
type: 'generic',
|
|
83
|
+
sourcePath: process.cwd(),
|
|
84
|
+
deployed: false,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return agents;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get deployed agents (stub)
|
|
95
|
+
*/
|
|
96
|
+
async function getDeployedAgents() {
|
|
97
|
+
// Stub: In a real implementation, this would query the canister registry
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Display list of agents
|
|
102
|
+
*/
|
|
103
|
+
export function displayAgents(agents, options) {
|
|
104
|
+
if (options.json) {
|
|
105
|
+
console.log(JSON.stringify(agents, null, 2));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
console.log();
|
|
109
|
+
if (agents.length === 0) {
|
|
110
|
+
console.log(chalk.yellow('No agents found.'));
|
|
111
|
+
console.log();
|
|
112
|
+
console.log('Create a new agent with:', chalk.bold('soulrecall init'));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
console.log(chalk.cyan(`Found ${agents.length} agent(s):\n`));
|
|
116
|
+
for (const agent of agents) {
|
|
117
|
+
console.log(chalk.bold(agent.name));
|
|
118
|
+
console.log(` Type: ${agent.type}`);
|
|
119
|
+
console.log(` Source: ${agent.sourcePath}`);
|
|
120
|
+
if (agent.deployed && agent.canisterId) {
|
|
121
|
+
console.log(` Canister: ${agent.canisterId}`);
|
|
122
|
+
console.log(` Network: ${agent.network}`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.log(` Status: ${chalk.yellow('Not deployed')}`);
|
|
126
|
+
}
|
|
127
|
+
if (agent.lastUpdated) {
|
|
128
|
+
console.log(` Updated: ${agent.lastUpdated}`);
|
|
129
|
+
}
|
|
130
|
+
console.log();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Execute list command
|
|
135
|
+
*/
|
|
136
|
+
export async function executeList(options) {
|
|
137
|
+
const spinner = ora('Scanning for agents...').start();
|
|
138
|
+
try {
|
|
139
|
+
const agents = await getAgents(options);
|
|
140
|
+
spinner.succeed('Scan complete!');
|
|
141
|
+
displayAgents(agents, options);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
145
|
+
spinner.fail(`List failed: ${message}`);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Create list command
|
|
151
|
+
*/
|
|
152
|
+
export function listCommand() {
|
|
153
|
+
const command = new Command('list');
|
|
154
|
+
command
|
|
155
|
+
.description('List all agents')
|
|
156
|
+
.option('-a, --all', 'show all agents (local and deployed)')
|
|
157
|
+
.option('--deployed', 'show only deployed agents')
|
|
158
|
+
.option('--local', 'show only local agents')
|
|
159
|
+
.option('-j, --json', 'output as JSON')
|
|
160
|
+
.action(async (options) => {
|
|
161
|
+
console.log(chalk.bold('\n📋 SoulRecall List\n'));
|
|
162
|
+
try {
|
|
163
|
+
await executeList(options);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
167
|
+
console.error(chalk.red(`\nError: ${message}`));
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return command;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs CLI commands
|
|
3
|
+
*
|
|
4
|
+
* Provides commands for viewing, filtering, and exporting canister logs
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import { getLogs, exportLogs, clearLogs } from '../../src/debugging/logs.js';
|
|
10
|
+
export const logsCmd = new Command('logs');
|
|
11
|
+
logsCmd
|
|
12
|
+
.description('View and manage canister logs')
|
|
13
|
+
.argument('<canister-id>', 'Canister ID')
|
|
14
|
+
.option('-t, --tail', 'Tail logs (follow mode)', false)
|
|
15
|
+
.option('-f, --filter <pattern>', 'Filter logs by pattern')
|
|
16
|
+
.option('-l, --level <level>', 'Filter by log level (info, warning, error, debug)')
|
|
17
|
+
.option('-s, --since <time>', 'Show logs since timestamp')
|
|
18
|
+
.option('-n, --limit <num>', 'Limit number of log entries')
|
|
19
|
+
.option('-e, --export <file>', 'Export logs to file')
|
|
20
|
+
.option('--format <format>', 'Export format (json, csv)', 'json')
|
|
21
|
+
.option('--clear', 'Clear all logs for this canister', false)
|
|
22
|
+
.action(async (canisterId, options) => {
|
|
23
|
+
if (options.clear) {
|
|
24
|
+
const spinner = ora(`Clearing logs for ${canisterId}...`).start();
|
|
25
|
+
try {
|
|
26
|
+
await clearLogs(canisterId);
|
|
27
|
+
spinner.succeed(chalk.green('Logs cleared'));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
spinner.fail(chalk.red('Failed to clear logs'));
|
|
32
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
33
|
+
console.error(chalk.red(message));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const spinner = ora('Fetching logs...').start();
|
|
38
|
+
try {
|
|
39
|
+
const since = options.since ? new Date(options.since) : undefined;
|
|
40
|
+
const level = options.level;
|
|
41
|
+
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
42
|
+
const logs = await getLogs(canisterId, {
|
|
43
|
+
since,
|
|
44
|
+
level,
|
|
45
|
+
pattern: options.filter,
|
|
46
|
+
limit,
|
|
47
|
+
});
|
|
48
|
+
spinner.stop();
|
|
49
|
+
if (logs.length === 0) {
|
|
50
|
+
console.log(chalk.yellow('No logs found'));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (options.export) {
|
|
54
|
+
const exportSpinner = ora(`Exporting logs to ${options.export}...`).start();
|
|
55
|
+
try {
|
|
56
|
+
await exportLogs(canisterId, options.export, options.format);
|
|
57
|
+
exportSpinner.succeed(chalk.green(`Logs exported to ${options.export}`));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
exportSpinner.fail(chalk.red('Failed to export logs'));
|
|
62
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
63
|
+
console.error(chalk.red(message));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const levelColors = {
|
|
68
|
+
info: chalk.blue,
|
|
69
|
+
warning: chalk.yellow,
|
|
70
|
+
error: chalk.red,
|
|
71
|
+
debug: chalk.gray,
|
|
72
|
+
};
|
|
73
|
+
for (const log of logs) {
|
|
74
|
+
const levelColor = levelColors[log.level];
|
|
75
|
+
const timestamp = log.timestamp.toISOString();
|
|
76
|
+
const level = log.level.toUpperCase().padEnd(7);
|
|
77
|
+
const method = log.method ? ` [${log.method}]` : '';
|
|
78
|
+
console.log(levelColor(`${timestamp} [${level}]${method}`));
|
|
79
|
+
console.log(` ${log.message}`);
|
|
80
|
+
if (log.context && Object.keys(log.context).length > 0) {
|
|
81
|
+
console.log(chalk.gray(' Context: ' + JSON.stringify(log.context, null, 2).split('\n').join('\n ')));
|
|
82
|
+
}
|
|
83
|
+
console.log();
|
|
84
|
+
}
|
|
85
|
+
if (!options.tail) {
|
|
86
|
+
console.log(chalk.gray(`Showing ${logs.length} log entries`));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
spinner.fail(chalk.red('Failed to fetch logs'));
|
|
91
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
92
|
+
console.error(chalk.red(message));
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monitor Command
|
|
3
|
+
*
|
|
4
|
+
* Watches canister health and displays real-time metrics.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import { checkHealth, getRecentAlerts } from '../../src/monitoring/index.js';
|
|
10
|
+
export function monitorCommand() {
|
|
11
|
+
const command = new Command('monitor');
|
|
12
|
+
command
|
|
13
|
+
.description('Watch canister health in real-time')
|
|
14
|
+
.argument('<canister-id>', 'Canister ID to monitor')
|
|
15
|
+
.option('-i, --interval <ms>', 'Polling interval (default: 10s)')
|
|
16
|
+
.option('-t, --thresholds <json>', 'Health check thresholds as JSON')
|
|
17
|
+
.option('-a, --alerts', 'Display all alerts (default: latest 10)');
|
|
18
|
+
command
|
|
19
|
+
.action(async (canisterId, options) => {
|
|
20
|
+
const thresholds = options.thresholds ? JSON.parse(options.thresholds) : undefined;
|
|
21
|
+
const monitoringOpts = {
|
|
22
|
+
canister: canisterId,
|
|
23
|
+
thresholds,
|
|
24
|
+
pollInterval: options.interval ? parseInt(options.interval) : 10000,
|
|
25
|
+
maxSnapshots: options.alerts ? parseInt(options.alerts) : 10,
|
|
26
|
+
};
|
|
27
|
+
const spinner = ora(`Monitoring canister ${canisterId}...`).start();
|
|
28
|
+
try {
|
|
29
|
+
await checkHealth(canisterId, monitoringOpts);
|
|
30
|
+
spinner.succeed(`Monitoring ${canisterId} started`);
|
|
31
|
+
console.log(chalk.gray(`Press Ctrl+C to stop monitoring`));
|
|
32
|
+
const pollInterval = monitoringOpts.pollInterval || 10000;
|
|
33
|
+
console.log(chalk.cyan(`Polling every ${(pollInterval / 1000).toFixed(1)}s`));
|
|
34
|
+
while (true) {
|
|
35
|
+
const statusInfo = await checkHealth(canisterId, monitoringOpts);
|
|
36
|
+
if (statusInfo.status === 'stopped') {
|
|
37
|
+
console.log(chalk.yellow('Canister stopped - stopping monitoring'));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
displayStatus(statusInfo);
|
|
41
|
+
if (monitoringOpts.generateAlerts !== false) {
|
|
42
|
+
const alerts = await getRecentAlerts(canisterId, monitoringOpts.maxSnapshots);
|
|
43
|
+
if (alerts.length > 0) {
|
|
44
|
+
displayAlerts(alerts);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
52
|
+
console.log(chalk.gray('\nMonitoring stopped'));
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
spinner.fail(`Monitoring error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return command;
|
|
62
|
+
}
|
|
63
|
+
function displayStatus(statusInfo) {
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(chalk.cyan('Status:'), statusInfo.status);
|
|
66
|
+
console.log(chalk.cyan('Memory:'), statusInfo.memorySize ? `${(Number(statusInfo.memorySize) / (1024 * 1024)).toFixed(2)} MB` : 'N/A');
|
|
67
|
+
console.log(chalk.cyan('Cycles:'), statusInfo.cycles ? statusInfo.cycles.toString() : 'N/A');
|
|
68
|
+
console.log(chalk.cyan('Health:'), statusInfo.health);
|
|
69
|
+
}
|
|
70
|
+
function displayAlerts(alerts) {
|
|
71
|
+
console.log();
|
|
72
|
+
console.log(chalk.cyan('Recent Alerts:'));
|
|
73
|
+
for (const alert of alerts) {
|
|
74
|
+
const severityColor = alert.severity === 'critical'
|
|
75
|
+
? chalk.red
|
|
76
|
+
: alert.severity === 'warning'
|
|
77
|
+
? chalk.yellow
|
|
78
|
+
: chalk.gray;
|
|
79
|
+
const timestamp = new Date(alert.timestamp).toISOString();
|
|
80
|
+
const truncatedMetric = alert.metric.length > 30 ? `${alert.metric.substring(0, 30)}...` : alert.metric;
|
|
81
|
+
console.log(` [${timestamp}]`, ` ${severityColor(alert.severity)} ${alert.severity.toUpperCase()}:`, ` Canister: ${alert.canisterId}`, ` ${truncatedMetric}`, ` Value: ${alert.value}`, ` Threshold: ${alert.threshold}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=monitor.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network management CLI commands
|
|
3
|
+
*
|
|
4
|
+
* Provides commands for managing local ICP networks:
|
|
5
|
+
* - create: Create a new network configuration
|
|
6
|
+
* - start: Start a local network
|
|
7
|
+
* - stop: Stop a running network
|
|
8
|
+
* - status: Get network status
|
|
9
|
+
* - list: List all networks
|
|
10
|
+
* - ping: Check network connectivity
|
|
11
|
+
*/
|
|
12
|
+
import { Command } from 'commander';
|
|
13
|
+
export declare const networkCmd: Command;
|
|
14
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network management CLI commands
|
|
3
|
+
*
|
|
4
|
+
* Provides commands for managing local ICP networks:
|
|
5
|
+
* - create: Create a new network configuration
|
|
6
|
+
* - start: Start a local network
|
|
7
|
+
* - stop: Stop a running network
|
|
8
|
+
* - status: Get network status
|
|
9
|
+
* - list: List all networks
|
|
10
|
+
* - ping: Check network connectivity
|
|
11
|
+
*/
|
|
12
|
+
import { Command } from 'commander';
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
import ora from 'ora';
|
|
15
|
+
import { networkStart, networkStop, networkStatus, networkList, networkPing, } from '../../src/icp/icpcli.js';
|
|
16
|
+
import { createNetworkConfig, getNetworkConfig, listNetworkConfigs, setNetworkStatus, } from '../../src/network/network-config.js';
|
|
17
|
+
export const networkCmd = new Command('network');
|
|
18
|
+
networkCmd
|
|
19
|
+
.description('Manage ICP networks');
|
|
20
|
+
const createCmd = new Command('create');
|
|
21
|
+
createCmd
|
|
22
|
+
.description('Create a new network configuration')
|
|
23
|
+
.option('-n, --name <name>', 'Network name (required)')
|
|
24
|
+
.option('-t, --type <type>', 'Network type (local, ic)', 'local')
|
|
25
|
+
.option('--nodes <count>', 'Number of nodes', '4')
|
|
26
|
+
.option('--replica-count <count>', 'Replica count')
|
|
27
|
+
.option('--cycles-initial <amount>', 'Initial cycles allocation', '100T')
|
|
28
|
+
.option('--cycles-min <amount>', 'Minimum cycles threshold')
|
|
29
|
+
.option('--auto-topup', 'Enable automatic cycles top-up', false)
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
if (!options.name) {
|
|
32
|
+
console.error(chalk.red('Error: --name is required'));
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const spinner = ora('Creating network configuration...').start();
|
|
36
|
+
try {
|
|
37
|
+
const config = await createNetworkConfig({
|
|
38
|
+
name: options.name,
|
|
39
|
+
type: options.type,
|
|
40
|
+
nodes: parseInt(options.nodes, 10),
|
|
41
|
+
replicaCount: options.replicaCount ? parseInt(options.replicaCount, 10) : undefined,
|
|
42
|
+
cycles: {
|
|
43
|
+
initial: options.cyclesInitial,
|
|
44
|
+
min: options.cyclesMin,
|
|
45
|
+
autoTopup: options.autoTopup,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
spinner.succeed(chalk.green(`Network '${config.name}' created successfully`));
|
|
49
|
+
console.log(chalk.gray(`Type: ${config.type}`));
|
|
50
|
+
console.log(chalk.gray(`Replica count: ${config.replicaCount || config.nodes}`));
|
|
51
|
+
console.log(chalk.gray(`Initial cycles: ${config.cycles?.initial}`));
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
spinner.fail(chalk.red('Failed to create network'));
|
|
55
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
56
|
+
console.error(chalk.red(message));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const startCmd = new Command('start');
|
|
61
|
+
startCmd
|
|
62
|
+
.description('Start a local network')
|
|
63
|
+
.argument('<name>', 'Network name')
|
|
64
|
+
.option('-e, --environment <env>', 'Environment name')
|
|
65
|
+
.option('--project-root <path>', 'Project root directory')
|
|
66
|
+
.option('--identity <name>', 'Identity to use')
|
|
67
|
+
.action(async (name, options) => {
|
|
68
|
+
const spinner = ora(`Starting network '${name}'...`).start();
|
|
69
|
+
try {
|
|
70
|
+
const config = await getNetworkConfig(name);
|
|
71
|
+
if (!config) {
|
|
72
|
+
spinner.fail(chalk.red(`Network '${name}' not found`));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
const result = await networkStart({
|
|
76
|
+
network: name,
|
|
77
|
+
environment: options.environment,
|
|
78
|
+
projectRoot: options.projectRoot,
|
|
79
|
+
identity: options.identity,
|
|
80
|
+
});
|
|
81
|
+
if (!result.success) {
|
|
82
|
+
spinner.fail(chalk.red('Failed to start network'));
|
|
83
|
+
console.error(chalk.red(result.stderr));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
await setNetworkStatus(name, 'running');
|
|
87
|
+
spinner.succeed(chalk.green(`Network '${name}' started successfully`));
|
|
88
|
+
console.log(result.stdout);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
spinner.fail(chalk.red('Failed to start network'));
|
|
92
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
93
|
+
console.error(chalk.red(message));
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const stopCmd = new Command('stop');
|
|
98
|
+
stopCmd
|
|
99
|
+
.description('Stop a running network')
|
|
100
|
+
.argument('<name>', 'Network name')
|
|
101
|
+
.option('-e, --environment <env>', 'Environment name')
|
|
102
|
+
.option('--project-root <path>', 'Project root directory')
|
|
103
|
+
.option('--identity <name>', 'Identity to use')
|
|
104
|
+
.action(async (name, options) => {
|
|
105
|
+
const spinner = ora(`Stopping network '${name}'...`).start();
|
|
106
|
+
try {
|
|
107
|
+
const config = await getNetworkConfig(name);
|
|
108
|
+
if (!config) {
|
|
109
|
+
spinner.fail(chalk.red(`Network '${name}' not found`));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
const result = await networkStop({
|
|
113
|
+
network: name,
|
|
114
|
+
environment: options.environment,
|
|
115
|
+
projectRoot: options.projectRoot,
|
|
116
|
+
identity: options.identity,
|
|
117
|
+
});
|
|
118
|
+
if (!result.success) {
|
|
119
|
+
spinner.fail(chalk.red('Failed to stop network'));
|
|
120
|
+
console.error(chalk.red(result.stderr));
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
await setNetworkStatus(name, 'stopped');
|
|
124
|
+
spinner.succeed(chalk.green(`Network '${name}' stopped successfully`));
|
|
125
|
+
console.log(result.stdout);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
spinner.fail(chalk.red('Failed to stop network'));
|
|
129
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
130
|
+
console.error(chalk.red(message));
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const statusCmd = new Command('status');
|
|
135
|
+
statusCmd
|
|
136
|
+
.description('Get network status')
|
|
137
|
+
.argument('<name>', 'Network name')
|
|
138
|
+
.option('-e, --environment <env>', 'Environment name')
|
|
139
|
+
.option('--project-root <path>', 'Project root directory')
|
|
140
|
+
.option('--identity <name>', 'Identity to use')
|
|
141
|
+
.action(async (name, options) => {
|
|
142
|
+
const spinner = ora(`Checking network '${name}' status...`).start();
|
|
143
|
+
try {
|
|
144
|
+
const config = await getNetworkConfig(name);
|
|
145
|
+
if (!config) {
|
|
146
|
+
spinner.fail(chalk.red(`Network '${name}' not found`));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
const result = await networkStatus({
|
|
150
|
+
environment: options.environment,
|
|
151
|
+
projectRoot: options.projectRoot,
|
|
152
|
+
identity: options.identity,
|
|
153
|
+
});
|
|
154
|
+
if (!result.success) {
|
|
155
|
+
spinner.warn(chalk.yellow('Could not get network status'));
|
|
156
|
+
console.error(chalk.red(result.stderr));
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
spinner.stop();
|
|
160
|
+
console.log(chalk.bold(`Network: ${name}`));
|
|
161
|
+
console.log(chalk.gray(`Type: ${config.type}`));
|
|
162
|
+
console.log(chalk.gray(`Status: ${config.status || 'unknown'}`));
|
|
163
|
+
console.log(chalk.gray(`Created: ${config.created?.toISOString() || 'unknown'}`));
|
|
164
|
+
console.log();
|
|
165
|
+
console.log(result.stdout);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
spinner.fail(chalk.red('Failed to get network status'));
|
|
169
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
170
|
+
console.error(chalk.red(message));
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const listCmd = new Command('list');
|
|
175
|
+
listCmd
|
|
176
|
+
.description('List all networks')
|
|
177
|
+
.option('-e, --environment <env>', 'Environment name')
|
|
178
|
+
.option('--project-root <path>', 'Project root directory')
|
|
179
|
+
.option('--identity <name>', 'Identity to use')
|
|
180
|
+
.action(async (options) => {
|
|
181
|
+
const spinner = ora('Listing networks...').start();
|
|
182
|
+
try {
|
|
183
|
+
const configs = await listNetworkConfigs();
|
|
184
|
+
if (configs.length === 0) {
|
|
185
|
+
spinner.info(chalk.yellow('No networks found'));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
spinner.stop();
|
|
189
|
+
for (const config of configs) {
|
|
190
|
+
const statusColor = config.status === 'running' ? chalk.green : config.status === 'error' ? chalk.red : chalk.gray;
|
|
191
|
+
console.log(chalk.bold(config.name));
|
|
192
|
+
console.log(chalk.gray(` Type: ${config.type}`));
|
|
193
|
+
console.log(chalk.gray(` Status: ${statusColor(config.status || 'unknown')}`));
|
|
194
|
+
console.log(chalk.gray(` Replicas: ${config.replicaCount || config.nodes}`));
|
|
195
|
+
if (config.cycles) {
|
|
196
|
+
console.log(chalk.gray(` Initial cycles: ${config.cycles.initial}`));
|
|
197
|
+
}
|
|
198
|
+
console.log();
|
|
199
|
+
}
|
|
200
|
+
const result = await networkList({
|
|
201
|
+
environment: options.environment,
|
|
202
|
+
projectRoot: options.projectRoot,
|
|
203
|
+
identity: options.identity,
|
|
204
|
+
});
|
|
205
|
+
if (result.success) {
|
|
206
|
+
console.log(chalk.bold('ICP CLI networks:'));
|
|
207
|
+
console.log(result.stdout);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
spinner.fail(chalk.red('Failed to list networks'));
|
|
212
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
213
|
+
console.error(chalk.red(message));
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
const pingCmd = new Command('ping');
|
|
218
|
+
pingCmd
|
|
219
|
+
.description('Check network connectivity')
|
|
220
|
+
.argument('<name>', 'Network name')
|
|
221
|
+
.option('-e, --environment <env>', 'Environment name')
|
|
222
|
+
.option('--project-root <path>', 'Project root directory')
|
|
223
|
+
.option('--identity <name>', 'Identity to use')
|
|
224
|
+
.action(async (name, options) => {
|
|
225
|
+
const spinner = ora(`Pinging network '${name}'...`).start();
|
|
226
|
+
try {
|
|
227
|
+
const config = await getNetworkConfig(name);
|
|
228
|
+
if (!config) {
|
|
229
|
+
spinner.fail(chalk.red(`Network '${name}' not found`));
|
|
230
|
+
process.exit(1);
|
|
231
|
+
}
|
|
232
|
+
const result = await networkPing({
|
|
233
|
+
environment: options.environment,
|
|
234
|
+
projectRoot: options.projectRoot,
|
|
235
|
+
identity: options.identity,
|
|
236
|
+
});
|
|
237
|
+
if (!result.success) {
|
|
238
|
+
spinner.fail(chalk.red('Network ping failed'));
|
|
239
|
+
console.error(chalk.red(result.stderr));
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
242
|
+
spinner.succeed(chalk.green(`Network '${name}' is reachable`));
|
|
243
|
+
console.log(result.stdout);
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
spinner.fail(chalk.red('Failed to ping network'));
|
|
247
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
248
|
+
console.error(chalk.red(message));
|
|
249
|
+
process.exit(1);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
networkCmd.addCommand(createCmd);
|
|
253
|
+
networkCmd.addCommand(startCmd);
|
|
254
|
+
networkCmd.addCommand(stopCmd);
|
|
255
|
+
networkCmd.addCommand(statusCmd);
|
|
256
|
+
networkCmd.addCommand(listCmd);
|
|
257
|
+
networkCmd.addCommand(pingCmd);
|
|
258
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package command - Compile agent to WASM for deployment
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import type { PackageResult } from '../../src/packaging/index.js';
|
|
6
|
+
export interface PackageCommandOptions {
|
|
7
|
+
output?: string;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
skipValidation?: boolean;
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
target?: 'wasmedge' | 'motoko' | 'pure-wasm';
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
optimize?: number;
|
|
14
|
+
icWasmOptimize?: boolean;
|
|
15
|
+
icWasmShrink?: boolean;
|
|
16
|
+
validate?: string;
|
|
17
|
+
memoryLimit?: string;
|
|
18
|
+
computeQuota?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Display package preview (dry-run)
|
|
22
|
+
*/
|
|
23
|
+
export declare function displayPreview(sourcePath: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Display package result
|
|
26
|
+
*/
|
|
27
|
+
export declare function displayResult(result: PackageResult): void;
|
|
28
|
+
/**
|
|
29
|
+
* Execute the package command
|
|
30
|
+
*/
|
|
31
|
+
export declare function executePackage(sourcePath: string, options: PackageCommandOptions): Promise<PackageResult | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Create the package command
|
|
34
|
+
*/
|
|
35
|
+
export declare function packageCommand(): Command;
|
|
36
|
+
//# sourceMappingURL=package.d.ts.map
|