// A launched bundle that keeps state through its runtime (novox/hq ADR 0202): it watches its servers as // it is imported, before it says what it serves, and its tools write, read and list them. import { state } from "../../dist/state/index.js"; import { registerModuleTools } from "../../dist/tools/index.js"; import { serveRegisteredOverStdio } from "../../dist/stdio/index.js"; const servers = state("servers"); await servers.watch((c) => { process.stderr.write(`${c.current ? "was" : "now"} ${c.op} ${c.key} ${JSON.stringify(c.value ?? null)}\n`); if (c.value && c.value.fail) throw new Error("not this one"); }); process.stderr.write("watching\n"); registerModuleTools("keeper", () => [ { name: "remember", description: "put", input: {}, run: async (a) => servers.put(a.key, a.value) }, { name: "recall", description: "get", input: {}, run: async (a) => servers.get(a.key) }, { name: "list", description: "keys", input: {}, run: async () => state("licence-manager.bindings").keys() }, ]); await serveRegisteredOverStdio();