/** * @file Create the hello-world vat on a running toybox and mount it. * * Usage: node --import ./test/lockdown.js scripts/hello.js [name] * then visit http://127.0.0.1:8787/?vat= (default name: hello). */ import { readFile } from "node:fs/promises"; import { E } from "@endo/far"; import { connectClient } from "../client.js"; const name = process.argv[2] ?? "hello"; const client = await connectClient("admin.sock", `hello-script-${process.pid}`); try { const ingress = await E(client.vatAdmin).makeIngress({ vat: name }); const { id, root } = await E(client.vatAdmin).createVat(await readFile("vats/hello.js", "utf8"), { ingress }); await root; // its handoff, settled before the client goes console.log(`vat ${id}\nhttp://127.0.0.1:8787/?vat=${name}`); } finally { client.close(); }