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,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WasmEdge Compiler
|
|
3
|
+
*
|
|
4
|
+
* Integrates WasmEdge SDK for compiling JavaScript to WebAssembly.
|
|
5
|
+
* Provides WASI-compliant module generation for agent execution.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
import type { AgentConfig } from '../packaging/types.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Compilation target types
|
|
13
|
+
*/
|
|
14
|
+
export type CompilationTarget = 'wasmedge' | 'motoko' | 'pure-wasm';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WasmEdge compilation options
|
|
18
|
+
*/
|
|
19
|
+
export interface WasmEdgeOptions {
|
|
20
|
+
/** Enable debugging support */
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
/** Generate source maps */
|
|
23
|
+
sourcemap?: boolean;
|
|
24
|
+
/** Optimization level (0-3) */
|
|
25
|
+
optimize?: number;
|
|
26
|
+
/** Enable WASI support */
|
|
27
|
+
wasi?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Default WasmEdge options
|
|
32
|
+
*/
|
|
33
|
+
export const DEFAULT_WASMEDGE_OPTIONS: WasmEdgeOptions = {
|
|
34
|
+
debug: true,
|
|
35
|
+
sourcemap: true,
|
|
36
|
+
optimize: 2,
|
|
37
|
+
wasi: true,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generate WasmEdge-compatible JavaScript wrapper
|
|
42
|
+
*
|
|
43
|
+
* Creates a JavaScript module that implements the standard agent interface
|
|
44
|
+
* and can be compiled with WasmEdge.
|
|
45
|
+
*/
|
|
46
|
+
export function generateWasmEdgeWrapper(
|
|
47
|
+
agentCode: string,
|
|
48
|
+
config: AgentConfig
|
|
49
|
+
): string {
|
|
50
|
+
const wrapper = `
|
|
51
|
+
// AgentVault WasmEdge Module
|
|
52
|
+
// Agent: ${config.name}
|
|
53
|
+
// Type: ${config.type}
|
|
54
|
+
// Generated: ${new Date().toISOString()}
|
|
55
|
+
|
|
56
|
+
// Agent state management
|
|
57
|
+
let _state = {};
|
|
58
|
+
let _initialized = false;
|
|
59
|
+
|
|
60
|
+
// Agent initialization
|
|
61
|
+
export function init(configStr) {
|
|
62
|
+
try {
|
|
63
|
+
const config = JSON.parse(configStr);
|
|
64
|
+
_state = {
|
|
65
|
+
name: config.name,
|
|
66
|
+
type: config.type,
|
|
67
|
+
version: config.version,
|
|
68
|
+
memories: [],
|
|
69
|
+
tasks: [],
|
|
70
|
+
createdAt: Date.now(),
|
|
71
|
+
};
|
|
72
|
+
_initialized = true;
|
|
73
|
+
return 0; // Success
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('Init failed:', error);
|
|
76
|
+
return 1; // Error
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Agent step function
|
|
81
|
+
export function step(input) {
|
|
82
|
+
if (!_initialized) {
|
|
83
|
+
console.error('Agent not initialized');
|
|
84
|
+
return JSON.stringify({ error: 'Agent not initialized' });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
// Execute agent code with state
|
|
89
|
+
const result = (function() {
|
|
90
|
+
${agentCode}
|
|
91
|
+
}).call(_state);
|
|
92
|
+
|
|
93
|
+
// Update state with execution result
|
|
94
|
+
_state.lastExecuted = Date.now();
|
|
95
|
+
_state.lastResult = result;
|
|
96
|
+
|
|
97
|
+
return JSON.stringify({
|
|
98
|
+
success: true,
|
|
99
|
+
result: result,
|
|
100
|
+
state: _state,
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error('Step failed:', error);
|
|
104
|
+
return JSON.stringify({
|
|
105
|
+
success: false,
|
|
106
|
+
error: error.message,
|
|
107
|
+
state: _state,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Get agent state as bytes
|
|
113
|
+
export function get_state() {
|
|
114
|
+
const stateJson = JSON.stringify(_state);
|
|
115
|
+
const bytes = new TextEncoder().encode(stateJson);
|
|
116
|
+
return bytes;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Get agent state size
|
|
120
|
+
export function get_state_size() {
|
|
121
|
+
const stateJson = JSON.stringify(_state);
|
|
122
|
+
return new TextEncoder().encode(stateJson).length;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Add memory entry
|
|
126
|
+
export function add_memory(type, content) {
|
|
127
|
+
const memory = {
|
|
128
|
+
type: type,
|
|
129
|
+
content: content,
|
|
130
|
+
timestamp: Date.now(),
|
|
131
|
+
importance: 1,
|
|
132
|
+
};
|
|
133
|
+
if (_state.memories) {
|
|
134
|
+
_state.memories.push(memory);
|
|
135
|
+
}
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Get all memories
|
|
140
|
+
export function get_memories() {
|
|
141
|
+
return JSON.stringify(_state.memories || []);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Get memories by type
|
|
145
|
+
export function get_memories_by_type(memoryType) {
|
|
146
|
+
const memories = (_state.memories || []).filter(m => m.type === memoryType);
|
|
147
|
+
return JSON.stringify(memories);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Clear memories
|
|
151
|
+
export function clear_memories() {
|
|
152
|
+
_state.memories = [];
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Add task to queue
|
|
157
|
+
export function add_task(taskId, description) {
|
|
158
|
+
const task = {
|
|
159
|
+
id: taskId,
|
|
160
|
+
description: description,
|
|
161
|
+
status: 'pending',
|
|
162
|
+
result: null,
|
|
163
|
+
timestamp: Date.now(),
|
|
164
|
+
};
|
|
165
|
+
if (_state.tasks) {
|
|
166
|
+
_state.tasks.push(task);
|
|
167
|
+
}
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Get all tasks
|
|
172
|
+
export function get_tasks() {
|
|
173
|
+
return JSON.stringify(_state.tasks || []);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Get pending tasks
|
|
177
|
+
export function get_pending_tasks() {
|
|
178
|
+
const pending = (_state.tasks || []).filter(t => t.status === 'pending');
|
|
179
|
+
return JSON.stringify(pending);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Update task status
|
|
183
|
+
export function update_task_status(taskId, status, result) {
|
|
184
|
+
const task = (_state.tasks || []).find(t => t.id === taskId);
|
|
185
|
+
if (task) {
|
|
186
|
+
task.status = status;
|
|
187
|
+
task.result = result;
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
return 1; // Task not found
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Clear all tasks
|
|
194
|
+
export function clear_tasks() {
|
|
195
|
+
_state.tasks = [];
|
|
196
|
+
return 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Export module info
|
|
200
|
+
export function get_info() {
|
|
201
|
+
return JSON.stringify({
|
|
202
|
+
name: '${config.name}',
|
|
203
|
+
type: '${config.type}',
|
|
204
|
+
version: '${config.version || '1.0.0'}',
|
|
205
|
+
initialized: _initialized,
|
|
206
|
+
stateSize: get_state_size(),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
|
|
211
|
+
return wrapper;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Generate WasmEdge build configuration
|
|
216
|
+
*
|
|
217
|
+
* Creates configuration for WasmEdge compiler.
|
|
218
|
+
*/
|
|
219
|
+
export function generateWasmEdgeConfig(
|
|
220
|
+
config: AgentConfig,
|
|
221
|
+
options: WasmEdgeOptions = DEFAULT_WASMEDGE_OPTIONS
|
|
222
|
+
): string {
|
|
223
|
+
const buildConfig = {
|
|
224
|
+
module_name: config.name,
|
|
225
|
+
module_type: 'wasi',
|
|
226
|
+
output_type: 'wasm',
|
|
227
|
+
optimization_level: options.optimize ?? 2,
|
|
228
|
+
debug: options.debug ?? true,
|
|
229
|
+
generate_source_map: options.sourcemap ?? true,
|
|
230
|
+
enable_wasi: options.wasi ?? true,
|
|
231
|
+
target: 'wasm32',
|
|
232
|
+
features: ['bulk-memory', 'mutable-globals', 'sign-ext'],
|
|
233
|
+
exports: [
|
|
234
|
+
'init',
|
|
235
|
+
'step',
|
|
236
|
+
'get_state',
|
|
237
|
+
'get_state_size',
|
|
238
|
+
'add_memory',
|
|
239
|
+
'get_memories',
|
|
240
|
+
'get_memories_by_type',
|
|
241
|
+
'clear_memories',
|
|
242
|
+
'add_task',
|
|
243
|
+
'get_tasks',
|
|
244
|
+
'get_pending_tasks',
|
|
245
|
+
'update_task_status',
|
|
246
|
+
'clear_tasks',
|
|
247
|
+
'get_info',
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return JSON.stringify(buildConfig, null, 2);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Validate WasmEdge module
|
|
256
|
+
*
|
|
257
|
+
* Checks that a compiled module is valid WasmEdge WASM.
|
|
258
|
+
*/
|
|
259
|
+
export function validateWasmEdgeModule(wasmBuffer: Buffer): {
|
|
260
|
+
valid: boolean;
|
|
261
|
+
errors: string[];
|
|
262
|
+
} {
|
|
263
|
+
const errors: string[] = [];
|
|
264
|
+
|
|
265
|
+
// Check minimum size
|
|
266
|
+
if (wasmBuffer.length < 8) {
|
|
267
|
+
errors.push('WASM file too small (minimum 8 bytes)');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Check WASM magic bytes
|
|
271
|
+
const magic = wasmBuffer.subarray(0, 4);
|
|
272
|
+
const expectedMagic = Buffer.from([0x00, 0x61, 0x73, 0x6d]);
|
|
273
|
+
if (!magic.equals(expectedMagic)) {
|
|
274
|
+
errors.push('Invalid WASM magic bytes');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Check version
|
|
278
|
+
const version = wasmBuffer.subarray(4, 8);
|
|
279
|
+
const expectedVersion = Buffer.from([0x01, 0x00, 0x00, 0x00]);
|
|
280
|
+
if (!version.equals(expectedVersion)) {
|
|
281
|
+
errors.push('Invalid WASM version (must be 1)');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Check for required exports
|
|
285
|
+
// In a real implementation, this would parse the WASM binary
|
|
286
|
+
// and check the export section for required functions
|
|
287
|
+
// For now, we'll just check the file is not empty
|
|
288
|
+
if (wasmBuffer.length < 100) {
|
|
289
|
+
errors.push('WASM file appears to be empty or incomplete');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
valid: errors.length === 0,
|
|
294
|
+
errors,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Generate WasmEdge build command
|
|
300
|
+
*
|
|
301
|
+
* Returns the command line to compile JavaScript to WasmEdge WASM.
|
|
302
|
+
* This is a placeholder - actual WasmEdge SDK usage would be integrated.
|
|
303
|
+
*/
|
|
304
|
+
export function getWasmEdgeBuildCommand(
|
|
305
|
+
sourcePath: string,
|
|
306
|
+
outputPath: string,
|
|
307
|
+
options: WasmEdgeOptions = DEFAULT_WASMEDGE_OPTIONS
|
|
308
|
+
): string {
|
|
309
|
+
const args = [
|
|
310
|
+
sourcePath,
|
|
311
|
+
'--output', outputPath,
|
|
312
|
+
'--target', 'wasm32',
|
|
313
|
+
'--opt', String(options.optimize ?? 2),
|
|
314
|
+
];
|
|
315
|
+
|
|
316
|
+
if (options.debug) {
|
|
317
|
+
args.push('--debug');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (options.sourcemap) {
|
|
321
|
+
args.push('--sourcemap');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (options.wasi) {
|
|
325
|
+
args.push('--wasi');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return `wasmedge-compile ${args.join(' ')}`;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Extract compilation errors from WasmEdge output
|
|
333
|
+
*
|
|
334
|
+
* Parses error messages from WasmEdge compiler output.
|
|
335
|
+
*/
|
|
336
|
+
export function parseWasmEdgeErrors(output: string): string[] {
|
|
337
|
+
const errors: string[] = [];
|
|
338
|
+
const lines = output.split('\n');
|
|
339
|
+
|
|
340
|
+
for (const line of lines) {
|
|
341
|
+
if (line.includes('error:')) {
|
|
342
|
+
errors.push(line.trim());
|
|
343
|
+
} else if (line.includes('Error:')) {
|
|
344
|
+
errors.push(line.trim());
|
|
345
|
+
} else if (line.includes('ERROR')) {
|
|
346
|
+
errors.push(line.trim());
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return errors;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Get source map path for compiled WASM
|
|
355
|
+
*
|
|
356
|
+
* Returns the expected source map file path.
|
|
357
|
+
*/
|
|
358
|
+
export function getSourceMapPath(wasmPath: string): string {
|
|
359
|
+
const dir = path.dirname(wasmPath);
|
|
360
|
+
const basename = path.basename(wasmPath, '.wasm');
|
|
361
|
+
return path.join(dir, `${basename}.wasm.map`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Generate module manifest for WasmEdge
|
|
366
|
+
*
|
|
367
|
+
* Creates a manifest file with module metadata.
|
|
368
|
+
*/
|
|
369
|
+
export function generateWasmEdgeManifest(
|
|
370
|
+
config: AgentConfig,
|
|
371
|
+
wasmPath: string,
|
|
372
|
+
_outputPath: string
|
|
373
|
+
): string {
|
|
374
|
+
const manifest = {
|
|
375
|
+
module_name: config.name,
|
|
376
|
+
module_type: 'agent',
|
|
377
|
+
version: config.version || '1.0.0',
|
|
378
|
+
agent_type: config.type,
|
|
379
|
+
wasm_path: path.basename(wasmPath),
|
|
380
|
+
created_at: new Date().toISOString(),
|
|
381
|
+
features: {
|
|
382
|
+
wasi: true,
|
|
383
|
+
bulk_memory: true,
|
|
384
|
+
mutable_globals: true,
|
|
385
|
+
multi_value: false,
|
|
386
|
+
},
|
|
387
|
+
exports: [
|
|
388
|
+
'init',
|
|
389
|
+
'step',
|
|
390
|
+
'get_state',
|
|
391
|
+
'get_state_size',
|
|
392
|
+
'add_memory',
|
|
393
|
+
'get_memories',
|
|
394
|
+
'get_memories_by_type',
|
|
395
|
+
'clear_memories',
|
|
396
|
+
'add_task',
|
|
397
|
+
'get_tasks',
|
|
398
|
+
'get_pending_tasks',
|
|
399
|
+
'update_task_status',
|
|
400
|
+
'clear_tasks',
|
|
401
|
+
'get_info',
|
|
402
|
+
],
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
return JSON.stringify(manifest, null, 2);
|
|
406
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security module for AgentVault
|
|
3
|
+
*
|
|
4
|
+
* This module provides encryption, decryption, and key management
|
|
5
|
+
* using VetKeys for threshold key derivation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
|
|
10
|
+
// VetKeysClient is exported from types.js, avoid re-exporting from vetkeys.js
|
|
11
|
+
export { VetKeysClient } from './types.js';
|
|
12
|
+
|
|
13
|
+
// Re-export decryptJSON from vetkeys.js
|
|
14
|
+
export { decryptJSON } from './vetkeys.js';
|
|
15
|
+
|
|
16
|
+
// Multi-sig approval workflows
|
|
17
|
+
export * from './multisig.js';
|