MCPcopy Create free account
hub / github.com/deepclause/agentvm / main

Function main

example/agent_bridge.js:5–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3const path = require('path');
4
5async function main() {
6 // Redirect console.log to stderr to keep stdout clean for JSON-RPC
7 const originalLog = console.log;
8 console.log = console.error;
9
10 const vm = new AgentVM({
11 // Point to the WASM file relative to this script
12 wasmPath: path.join(__dirname, '../agentvm-alpine-python.wasm')
13 });
14
15 try {
16 await vm.start();
17 // Signal readiness on stdout
18 process.stdout.write("READY\n");
19 } catch (err) {
20 console.error("Failed to start VM:", err);
21 process.exit(1);
22 }
23
24 const rl = readline.createInterface({
25 input: process.stdin,
26 output: process.stdout,
27 terminal: false
28 });
29
30 rl.on('line', async (line) => {
31 if (!line.trim()) return;
32 try {
33 const msg = JSON.parse(line);
34 if (msg.cmd === 'exec') {
35 try {
36 const res = await vm.exec(msg.command);
37 process.stdout.write(JSON.stringify({ status: 'ok', result: res }) + "\n");
38 } catch (execErr) {
39 process.stdout.write(JSON.stringify({ status: 'error', error: execErr.message }) + "\n");
40 }
41 } else if (msg.cmd === 'stop') {
42 await vm.stop();
43 process.exit(0);
44 }
45 } catch (err) {
46 console.error("Bridge Error:", err);
47 }
48 });
49}
50
51main();

Callers 1

agent_bridge.jsFile · 0.70

Calls 3

startMethod · 0.95
execMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected