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,232 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { createApprovalRequest, signApprovalRequest, rejectApprovalRequest, listApprovalRequests, listPendingApprovals, deleteApprovalRequest, isApproved, getApprovalSummary, cleanupExpiredRequests, } from '../../src/security/index.js';
|
|
5
|
+
const approveCmd = new Command('approve');
|
|
6
|
+
approveCmd
|
|
7
|
+
.description('[Experimental] Manage multi-signature approval workflows')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
console.log(chalk.yellow('[Experimental] This feature is under active development and may change.'));
|
|
10
|
+
console.log(chalk.yellow('Please specify a subcommand: create, list, sign, reject, delete, or cleanup'));
|
|
11
|
+
console.log(chalk.gray(`\nExamples:
|
|
12
|
+
${chalk.cyan('soulrecall approve create deploy <agent-name> "Description"')}${chalk.gray(' Create approval request')}
|
|
13
|
+
${chalk.cyan('soulrecall approve list')}${chalk.gray(' List all requests')}
|
|
14
|
+
${chalk.cyan('soulrecall approve sign <request-id>')}${chalk.gray(' Sign a request')}
|
|
15
|
+
${chalk.cyan('soulrecall approve reject <request-id>')}${chalk.gray(' Reject a request')}
|
|
16
|
+
${chalk.cyan('soulrecall approve pending <signer>')}${chalk.gray(' Show pending requests')}`));
|
|
17
|
+
});
|
|
18
|
+
approveCmd
|
|
19
|
+
.command('create')
|
|
20
|
+
.description('Create a new approval request')
|
|
21
|
+
.argument('<type>', 'Request type: deploy, upgrade, transfer, config_change, rollback')
|
|
22
|
+
.argument('<agent-name>', 'Agent name')
|
|
23
|
+
.argument('<description>', 'Description of the change')
|
|
24
|
+
.option('--proposed-by <name>', 'Proposer name', 'admin')
|
|
25
|
+
.option('--policy <policy>', 'Approval policy: all, majority, quorum', 'majority')
|
|
26
|
+
.option('--required <number>', 'Number of required approvals')
|
|
27
|
+
.option('--timeout <ms>', 'Approval timeout in milliseconds', '86400000')
|
|
28
|
+
.option('--signers <count>', 'Number of allowed signers', '3')
|
|
29
|
+
.action(async (type, agentName, description, options) => {
|
|
30
|
+
const spinner = ora(`Creating approval request...`).start();
|
|
31
|
+
try {
|
|
32
|
+
const config = {
|
|
33
|
+
policy: options.policy,
|
|
34
|
+
requiredApprovals: options.required ? parseInt(options.required, 10) : undefined,
|
|
35
|
+
approvalTimeoutMs: parseInt(options.timeout, 10),
|
|
36
|
+
allowedSigners: Array.from({ length: parseInt(options.signers, 10) }, (_, i) => `signer${i + 1}`),
|
|
37
|
+
};
|
|
38
|
+
const request = createApprovalRequest(type, agentName, description, options.proposedBy, config);
|
|
39
|
+
spinner.succeed(chalk.green(`Approval request created: ${request.id}`));
|
|
40
|
+
console.log(chalk.gray(`Type: ${request.type}`));
|
|
41
|
+
console.log(chalk.gray(`Policy: ${request.policy}`));
|
|
42
|
+
console.log(chalk.gray(`Required approvals: ${request.requiredApprovals}`));
|
|
43
|
+
console.log(chalk.gray(`Expires: ${request.expiresAt?.toLocaleString()}`));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
spinner.fail(chalk.red('Failed to create approval request'));
|
|
47
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
48
|
+
console.error(chalk.red(message));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
approveCmd
|
|
53
|
+
.command('list')
|
|
54
|
+
.description('List approval requests')
|
|
55
|
+
.option('--agent <name>', 'Filter by agent name')
|
|
56
|
+
.option('--status <status>', 'Filter by status: pending, approved, rejected, expired')
|
|
57
|
+
.action(async (options) => {
|
|
58
|
+
const spinner = ora('Loading approval requests...').start();
|
|
59
|
+
try {
|
|
60
|
+
const requests = listApprovalRequests(options.agent, options.status);
|
|
61
|
+
spinner.succeed(chalk.green(`Found ${requests.length} request(s)`));
|
|
62
|
+
if (requests.length === 0) {
|
|
63
|
+
console.log(chalk.gray('No approval requests found'));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
for (const req of requests) {
|
|
67
|
+
const statusColor = {
|
|
68
|
+
pending: chalk.yellow,
|
|
69
|
+
approved: chalk.green,
|
|
70
|
+
rejected: chalk.red,
|
|
71
|
+
expired: chalk.gray,
|
|
72
|
+
}[req.status] || chalk.gray;
|
|
73
|
+
const progress = `${req.approvals.length}/${req.requiredApprovals}`;
|
|
74
|
+
console.log(`\n${chalk.bold(req.id)}`);
|
|
75
|
+
console.log(` Type: ${req.type}`);
|
|
76
|
+
console.log(` Agent: ${req.agentName}`);
|
|
77
|
+
console.log(` Status: ${statusColor(req.status)} ${progress}`);
|
|
78
|
+
console.log(` Proposed by: ${req.proposedBy}`);
|
|
79
|
+
console.log(` Description: ${req.description}`);
|
|
80
|
+
if (req.approvals.length > 0) {
|
|
81
|
+
console.log(' Signatures:');
|
|
82
|
+
for (const sig of req.approvals) {
|
|
83
|
+
console.log(` - ${sig.signer} (${sig.timestamp.toLocaleString()})`);
|
|
84
|
+
if (sig.comment) {
|
|
85
|
+
console.log(` ${chalk.gray(sig.comment)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
spinner.fail(chalk.red('Failed to list approval requests'));
|
|
93
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
94
|
+
console.error(chalk.red(message));
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
approveCmd
|
|
99
|
+
.command('sign')
|
|
100
|
+
.description('Sign an approval request')
|
|
101
|
+
.argument('<request-id>', 'Request ID to sign')
|
|
102
|
+
.argument('<signer>', 'Signer name')
|
|
103
|
+
.option('--comment <text>', 'Comment on signature')
|
|
104
|
+
.action(async (requestId, signer, options) => {
|
|
105
|
+
const spinner = ora(`Signing request ${requestId}...`).start();
|
|
106
|
+
try {
|
|
107
|
+
const success = signApprovalRequest(requestId, signer, options.comment);
|
|
108
|
+
if (success) {
|
|
109
|
+
const approved = isApproved(requestId);
|
|
110
|
+
spinner.succeed(chalk.green(`Request signed by ${signer}`));
|
|
111
|
+
if (approved) {
|
|
112
|
+
console.log(chalk.green('\n✓ Request is now approved!'));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const summary = getApprovalSummary(requestId);
|
|
116
|
+
if (summary) {
|
|
117
|
+
console.log(chalk.gray(`Approvals: ${summary.approved}/${summary.required}`));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
spinner.fail(chalk.red('Failed to sign request'));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
spinner.fail(chalk.red('Failed to sign request'));
|
|
128
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
129
|
+
console.error(chalk.red(message));
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
approveCmd
|
|
134
|
+
.command('reject')
|
|
135
|
+
.description('Reject an approval request')
|
|
136
|
+
.argument('<request-id>', 'Request ID to reject')
|
|
137
|
+
.argument('<signer>', 'Signer name')
|
|
138
|
+
.option('--reason <text>', 'Rejection reason')
|
|
139
|
+
.action(async (requestId, signer, options) => {
|
|
140
|
+
const spinner = ora(`Rejecting request ${requestId}...`).start();
|
|
141
|
+
try {
|
|
142
|
+
const success = rejectApprovalRequest(requestId, signer, options.reason);
|
|
143
|
+
if (success) {
|
|
144
|
+
spinner.succeed(chalk.green(`Request rejected by ${signer}`));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
spinner.fail(chalk.red('Failed to reject request'));
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
spinner.fail(chalk.red('Failed to reject request'));
|
|
153
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
154
|
+
console.error(chalk.red(message));
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
approveCmd
|
|
159
|
+
.command('pending')
|
|
160
|
+
.description('List pending approvals for a signer')
|
|
161
|
+
.argument('<signer>', 'Signer name')
|
|
162
|
+
.action(async (signer) => {
|
|
163
|
+
const spinner = ora(`Loading pending approvals for ${signer}...`).start();
|
|
164
|
+
try {
|
|
165
|
+
const requests = listPendingApprovals(signer);
|
|
166
|
+
spinner.succeed(chalk.green(`Found ${requests.length} pending request(s)`));
|
|
167
|
+
if (requests.length === 0) {
|
|
168
|
+
console.log(chalk.gray('No pending requests'));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
for (const req of requests) {
|
|
172
|
+
console.log(`\n${chalk.bold(req.id)}`);
|
|
173
|
+
console.log(` Type: ${req.type}`);
|
|
174
|
+
console.log(` Agent: ${req.agentName}`);
|
|
175
|
+
console.log(` Description: ${req.description}`);
|
|
176
|
+
console.log(` Required: ${req.requiredApprovals}`);
|
|
177
|
+
console.log(` Current: ${req.approvals.length}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
spinner.fail(chalk.red('Failed to list pending approvals'));
|
|
182
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
183
|
+
console.error(chalk.red(message));
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
approveCmd
|
|
188
|
+
.command('delete')
|
|
189
|
+
.description('Delete an approval request')
|
|
190
|
+
.argument('<request-id>', 'Request ID to delete')
|
|
191
|
+
.action(async (requestId) => {
|
|
192
|
+
const spinner = ora(`Deleting request ${requestId}...`).start();
|
|
193
|
+
try {
|
|
194
|
+
const success = deleteApprovalRequest(requestId);
|
|
195
|
+
if (success) {
|
|
196
|
+
spinner.succeed(chalk.green(`Request deleted: ${requestId}`));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
spinner.fail(chalk.red('Failed to delete request'));
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
spinner.fail(chalk.red('Failed to delete request'));
|
|
205
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
206
|
+
console.error(chalk.red(message));
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
approveCmd
|
|
211
|
+
.command('cleanup')
|
|
212
|
+
.description('Clean up expired requests')
|
|
213
|
+
.action(async () => {
|
|
214
|
+
const spinner = ora('Cleaning up expired requests...').start();
|
|
215
|
+
try {
|
|
216
|
+
const cleaned = cleanupExpiredRequests();
|
|
217
|
+
if (cleaned > 0) {
|
|
218
|
+
spinner.succeed(chalk.green(`Marked ${cleaned} expired request(s)`));
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
spinner.info(chalk.gray('No expired requests to clean'));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
spinner.fail(chalk.red('Failed to cleanup'));
|
|
226
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
227
|
+
console.error(chalk.red(message));
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
export { approveCmd };
|
|
232
|
+
//# sourceMappingURL=approve.js.map
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { prepareArchive, listArchives, getArchive, deleteArchive, verifyArchive, getArchiveStats, } from '../../src/archival/index.js';
|
|
5
|
+
const archiveCmd = new Command('archive');
|
|
6
|
+
archiveCmd
|
|
7
|
+
.description('[Experimental] Archive agent data to permanent storage (Arweave)')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
console.log(chalk.yellow('[Experimental] This feature is under active development and may change.'));
|
|
10
|
+
console.log(chalk.yellow('Please specify a subcommand: prepare, list, delete, verify, or stats'));
|
|
11
|
+
console.log(chalk.gray(`\nExamples:
|
|
12
|
+
${chalk.cyan('soulrecall archive prepare <agent-name> <version>')}${chalk.gray(' Prepare agent data for archival')}
|
|
13
|
+
${chalk.cyan('soulrecall archive list')}${chalk.gray(' List all archives')}
|
|
14
|
+
${chalk.cyan('soulrecall archive stats <agent-name>')}${chalk.gray(' Get archive statistics')}
|
|
15
|
+
${chalk.cyan('soulrecall archive delete <archive-id>')}${chalk.gray(' Delete an archive')}
|
|
16
|
+
${chalk.cyan('soulrecall archive verify <archive-id>')}${chalk.gray(' Verify archive integrity')}`));
|
|
17
|
+
});
|
|
18
|
+
archiveCmd
|
|
19
|
+
.command('prepare')
|
|
20
|
+
.description('Prepare agent data for archival (local storage)')
|
|
21
|
+
.argument('<agent-name>', 'Agent name to archive')
|
|
22
|
+
.argument('<version>', 'Agent version')
|
|
23
|
+
.option('--include-config', 'Include agent configuration', true)
|
|
24
|
+
.option('--include-logs', 'Include logs', false)
|
|
25
|
+
.option('--include-metrics', 'Include metrics', false)
|
|
26
|
+
.option('--tag <key=value>', 'Add metadata tag (can be used multiple times)', [])
|
|
27
|
+
.action(async (agentName, version, options) => {
|
|
28
|
+
const spinner = ora(`Preparing archive for ${agentName} v${version}...`).start();
|
|
29
|
+
try {
|
|
30
|
+
const data = {
|
|
31
|
+
agentName,
|
|
32
|
+
version,
|
|
33
|
+
timestamp: new Date().toISOString(),
|
|
34
|
+
};
|
|
35
|
+
if (options.includeConfig) {
|
|
36
|
+
data.config = { included: true };
|
|
37
|
+
}
|
|
38
|
+
if (options.includeLogs) {
|
|
39
|
+
data.logs = { included: true, sample: ['Sample log entry'] };
|
|
40
|
+
}
|
|
41
|
+
if (options.includeMetrics) {
|
|
42
|
+
data.metrics = { included: true };
|
|
43
|
+
}
|
|
44
|
+
const tags = {};
|
|
45
|
+
if (options.tag) {
|
|
46
|
+
for (const tag of options.tag) {
|
|
47
|
+
const parts = tag.split('=');
|
|
48
|
+
if (parts.length === 2) {
|
|
49
|
+
tags[parts[0]] = parts[1];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const result = prepareArchive(agentName, version, data, {
|
|
54
|
+
includeConfig: options.includeConfig,
|
|
55
|
+
includeLogs: options.includeLogs,
|
|
56
|
+
includeMetrics: options.includeMetrics,
|
|
57
|
+
tags,
|
|
58
|
+
});
|
|
59
|
+
if (result.success && result.archiveId) {
|
|
60
|
+
spinner.succeed(chalk.green(`Archive prepared: ${result.archiveId}`));
|
|
61
|
+
console.log(chalk.gray(`Agent: ${agentName}`));
|
|
62
|
+
console.log(chalk.gray(`Version: ${version}`));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
spinner.fail(chalk.red('Failed to prepare archive'));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
spinner.fail(chalk.red('Failed to prepare archive'));
|
|
71
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
72
|
+
console.error(chalk.red(message));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
archiveCmd
|
|
77
|
+
.command('list')
|
|
78
|
+
.description('List all archives')
|
|
79
|
+
.option('--agent <name>', 'Filter by agent name')
|
|
80
|
+
.option('--status <status>', 'Filter by status (pending, uploading, confirmed, failed)')
|
|
81
|
+
.action(async (options) => {
|
|
82
|
+
const spinner = ora('Loading archives...').start();
|
|
83
|
+
try {
|
|
84
|
+
const archives = listArchives(options.agent);
|
|
85
|
+
spinner.succeed(chalk.green(`Found ${archives.length} archive(s)`));
|
|
86
|
+
if (archives.length === 0) {
|
|
87
|
+
console.log(chalk.gray('No archives found'));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
let filtered = archives;
|
|
91
|
+
if (options.status) {
|
|
92
|
+
filtered = archives.filter((a) => a.status === options.status);
|
|
93
|
+
}
|
|
94
|
+
for (const archive of filtered) {
|
|
95
|
+
const statusColor = {
|
|
96
|
+
pending: chalk.yellow,
|
|
97
|
+
uploading: chalk.blue,
|
|
98
|
+
confirmed: chalk.green,
|
|
99
|
+
failed: chalk.red,
|
|
100
|
+
}[archive.status] || chalk.gray;
|
|
101
|
+
console.log(`\n${chalk.bold(archive.id)}`);
|
|
102
|
+
console.log(` Agent: ${archive.agentName}`);
|
|
103
|
+
console.log(` Status: ${statusColor(archive.status)}`);
|
|
104
|
+
console.log(` Size: ${archive.sizeBytes} bytes`);
|
|
105
|
+
console.log(` Timestamp: ${archive.timestamp.toLocaleString()}`);
|
|
106
|
+
if (archive.transactionId) {
|
|
107
|
+
console.log(` Transaction: ${archive.transactionId}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
spinner.fail(chalk.red('Failed to list archives'));
|
|
113
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
114
|
+
console.error(chalk.red(message));
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
archiveCmd
|
|
119
|
+
.command('stats')
|
|
120
|
+
.description('Get archive statistics')
|
|
121
|
+
.option('--agent <name>', 'Filter by agent name')
|
|
122
|
+
.action(async (options) => {
|
|
123
|
+
try {
|
|
124
|
+
const stats = getArchiveStats(options.agent);
|
|
125
|
+
console.log(chalk.bold('\nArchive Statistics:'));
|
|
126
|
+
console.log(` Total archives: ${stats.total}`);
|
|
127
|
+
console.log(` Confirmed: ${chalk.green(stats.confirmed)}`);
|
|
128
|
+
console.log(` Pending: ${chalk.yellow(stats.pending)}`);
|
|
129
|
+
console.log(` Failed: ${chalk.red(stats.failed)}`);
|
|
130
|
+
console.log(` Total size: ${(stats.totalBytes / 1024 / 1024).toFixed(2)} MB`);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.error(chalk.red('Failed to get stats'));
|
|
134
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
135
|
+
console.error(chalk.red(message));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
archiveCmd
|
|
140
|
+
.command('delete')
|
|
141
|
+
.description('Delete an archive (local storage only)')
|
|
142
|
+
.argument('<archive-id>', 'Archive ID to delete')
|
|
143
|
+
.action(async (archiveId) => {
|
|
144
|
+
const spinner = ora(`Deleting archive ${archiveId}...`).start();
|
|
145
|
+
try {
|
|
146
|
+
const success = deleteArchive(archiveId);
|
|
147
|
+
if (success) {
|
|
148
|
+
spinner.succeed(chalk.green(`Archive deleted: ${archiveId}`));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
spinner.fail(chalk.red('Failed to delete archive'));
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
spinner.fail(chalk.red('Failed to delete archive'));
|
|
157
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
158
|
+
console.error(chalk.red(message));
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
archiveCmd
|
|
163
|
+
.command('verify')
|
|
164
|
+
.description('Verify archive integrity')
|
|
165
|
+
.argument('<archive-id>', 'Archive ID to verify')
|
|
166
|
+
.action(async (archiveId) => {
|
|
167
|
+
const spinner = ora(`Verifying archive ${archiveId}...`).start();
|
|
168
|
+
try {
|
|
169
|
+
const archive = getArchive(archiveId);
|
|
170
|
+
if (!archive) {
|
|
171
|
+
spinner.fail(chalk.red('Archive not found'));
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
const isValid = verifyArchive(archiveId);
|
|
175
|
+
if (isValid) {
|
|
176
|
+
spinner.succeed(chalk.green(`Archive verified: ${archiveId}`));
|
|
177
|
+
console.log(chalk.gray(`Checksum: ${archive.checksum}`));
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
spinner.fail(chalk.red('Archive verification failed'));
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
spinner.fail(chalk.red('Failed to verify archive'));
|
|
186
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
187
|
+
console.error(chalk.red(message));
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
export { archiveCmd };
|
|
192
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { exportBackup, previewBackup, importBackup, listBackups, deleteBackup, formatBackupSize, } from '../../src/backup/index.js';
|
|
5
|
+
const backupCmd = new Command('backup');
|
|
6
|
+
backupCmd
|
|
7
|
+
.description('Export and import agent backups')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
console.log(chalk.yellow('Please specify a subcommand: export, import, list, delete, or preview'));
|
|
10
|
+
console.log(chalk.gray(`\nExamples:
|
|
11
|
+
${chalk.cyan('soulrecall backup export <agent-name> --output backup.json')}${chalk.gray(' Export agent config to file')}
|
|
12
|
+
${chalk.cyan('soulrecall backup import <file>')}${chalk.gray(' Import agent from backup file')}
|
|
13
|
+
${chalk.cyan('soulrecall backup list')}${chalk.gray(' List all backups')}
|
|
14
|
+
${chalk.cyan('soulrecall backup delete <backup-path>')}${chalk.gray(' Delete a backup')}
|
|
15
|
+
${chalk.cyan('soulrecall backup preview <backup-path>')}${chalk.gray(' Preview backup contents')}`));
|
|
16
|
+
});
|
|
17
|
+
backupCmd
|
|
18
|
+
.command('export')
|
|
19
|
+
.description('Export agent configuration and data to a backup file')
|
|
20
|
+
.argument('<agent-name>', 'Agent name to backup')
|
|
21
|
+
.option('-o, --output <path>', 'Output file path', './backup.json')
|
|
22
|
+
.option('-c, --canister-id <id>', 'Canister ID to include live canister state')
|
|
23
|
+
.option('--no-canister-state', 'Skip fetching canister state even if canister ID provided')
|
|
24
|
+
.action(async (agentName, options) => {
|
|
25
|
+
const outputPath = options.output.endsWith('.json') ? options.output : `${options.output}.json`;
|
|
26
|
+
const includeCanisterState = options.canisterId ? options.canisterState !== false : false;
|
|
27
|
+
const spinner = ora(`Exporting backup for ${agentName}...`).start();
|
|
28
|
+
try {
|
|
29
|
+
const result = await exportBackup({
|
|
30
|
+
agentName,
|
|
31
|
+
outputPath,
|
|
32
|
+
includeConfig: true,
|
|
33
|
+
canisterId: options.canisterId,
|
|
34
|
+
includeCanisterState,
|
|
35
|
+
});
|
|
36
|
+
if (result.success && result.path && result.manifest) {
|
|
37
|
+
spinner.succeed(chalk.green(`Backup exported to ${result.path}`));
|
|
38
|
+
const sizeBytes = result.sizeBytes || result.manifest.size;
|
|
39
|
+
console.log(chalk.gray(`Size: ${formatBackupSize(sizeBytes)}`));
|
|
40
|
+
console.log(chalk.gray(`Components: ${result.manifest.components.join(', ')}`));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
spinner.fail(chalk.red('Backup export failed'));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
spinner.fail(chalk.red('Backup export failed'));
|
|
49
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
50
|
+
console.error(chalk.red(message));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
backupCmd
|
|
55
|
+
.command('import')
|
|
56
|
+
.description('Import agent configuration from a backup file')
|
|
57
|
+
.argument('<file>', 'Backup file path to import')
|
|
58
|
+
.option('--name <name>', 'New agent name (defaults to original)')
|
|
59
|
+
.option('--overwrite', 'Overwrite existing agent configuration')
|
|
60
|
+
.action(async (filePath, options) => {
|
|
61
|
+
const spinner = ora(`Importing backup from ${filePath}...`).start();
|
|
62
|
+
try {
|
|
63
|
+
const result = await importBackup({
|
|
64
|
+
inputPath: filePath,
|
|
65
|
+
targetAgentName: options.name,
|
|
66
|
+
overwrite: options.overwrite,
|
|
67
|
+
});
|
|
68
|
+
if (result.success) {
|
|
69
|
+
spinner.succeed(chalk.green(`Backup imported for ${result.agentName}`));
|
|
70
|
+
if (result.components.length > 0) {
|
|
71
|
+
console.log(chalk.gray(`Components imported: ${result.components.join(', ')}`));
|
|
72
|
+
}
|
|
73
|
+
if (result.warnings.length > 0) {
|
|
74
|
+
console.log(chalk.yellow('Warnings:'));
|
|
75
|
+
for (const warning of result.warnings) {
|
|
76
|
+
console.log(chalk.yellow(` - ${warning}`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
spinner.fail(chalk.red('Backup import failed'));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
spinner.fail(chalk.red('Backup import failed'));
|
|
87
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
88
|
+
console.error(chalk.red(message));
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
backupCmd
|
|
93
|
+
.command('list')
|
|
94
|
+
.description('List all agent backups')
|
|
95
|
+
.option('--agent <name>', 'Filter by agent name')
|
|
96
|
+
.action(async (options) => {
|
|
97
|
+
const spinner = ora('Listing backups...').start();
|
|
98
|
+
try {
|
|
99
|
+
const backups = await listBackups(options.agent);
|
|
100
|
+
spinner.succeed(chalk.green(`Found ${backups.length} backup(s)`));
|
|
101
|
+
if (backups.length === 0) {
|
|
102
|
+
console.log(chalk.gray('No backups found'));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const backup of backups) {
|
|
106
|
+
console.log(chalk.cyan(JSON.stringify(backup, null, 2)));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
spinner.fail(chalk.red('Failed to list backups'));
|
|
111
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
112
|
+
console.error(chalk.red(message));
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
backupCmd
|
|
117
|
+
.command('delete')
|
|
118
|
+
.description('Delete a backup file')
|
|
119
|
+
.argument('<backup-path>', 'Backup file path to delete')
|
|
120
|
+
.action(async (filePath) => {
|
|
121
|
+
const spinner = ora(`Deleting backup ${filePath}...`).start();
|
|
122
|
+
try {
|
|
123
|
+
const success = await deleteBackup(filePath);
|
|
124
|
+
if (success) {
|
|
125
|
+
spinner.succeed(chalk.green(`Backup deleted: ${filePath}`));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
spinner.fail(chalk.red('Failed to delete backup'));
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
spinner.fail(chalk.red('Failed to delete backup'));
|
|
134
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
135
|
+
console.error(chalk.red(message));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
backupCmd
|
|
140
|
+
.command('preview')
|
|
141
|
+
.description('Preview backup contents without importing')
|
|
142
|
+
.argument('<backup-path>', 'Backup file path to preview')
|
|
143
|
+
.action(async (filePath) => {
|
|
144
|
+
const spinner = ora('Previewing backup...').start();
|
|
145
|
+
try {
|
|
146
|
+
const manifest = await previewBackup(filePath);
|
|
147
|
+
if (!manifest) {
|
|
148
|
+
spinner.fail(chalk.red('Invalid backup file'));
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
spinner.succeed(chalk.green('Backup manifest preview:'));
|
|
152
|
+
console.log(chalk.bold(`Agent: ${manifest.agentName}`));
|
|
153
|
+
console.log(chalk.gray(`Created: ${new Date(manifest.created).toLocaleString()}`));
|
|
154
|
+
console.log(chalk.gray(`Components: ${manifest.components.join(', ')}`));
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
spinner.fail(chalk.red('Failed to preview backup'));
|
|
158
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
159
|
+
console.error(chalk.red(message));
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
export { backupCmd };
|
|
164
|
+
//# sourceMappingURL=backup.js.map
|