// The hosts file's tools: the node-hosts-file seat's three verbs (novox/hq ADR 0199) — the file's lines // with whose each is, add an operator's line, remove one. They change the machine's file and nothing // else; the controller holds none of it. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { HostsFile } from "../client.js"; export function getSeatVerbs(hosts: HostsFile): ToolDefinition[] { return [ { name: "entries", description: "Every line of this machine's /etc/hosts, each marked whose it is: the operator's, or the block of the module or tool that writes it.", input: {}, run: async () => hosts.entries(), }, { name: "add", description: "Add one address and its names to the operator's lines of this machine's /etc/hosts — a name for this machine's own programs, not the mesh's. Nothing changes when they are already there.", input: { address: { type: "string", description: "the IPv4 or IPv6 address" }, names: { type: "string", description: "the names for it, separated by spaces" }, }, run: async (args) => hosts.add(String(args.address ?? ""), String(args.names ?? "").split(/[\s,]+/).filter(Boolean)), }, { name: "remove", description: "Remove one name, or every line of one address, from the operator's lines of this machine's /etc/hosts. A line a module writes is refused, naming the module.", input: { name: { type: "string", description: "a host name, or an address to remove every line of" } }, run: async (args) => hosts.remove(String(args.name ?? "")), }, ]; } const hosts = HostsFile.onThisMachine(); // The seat's verbs under the seat's name: the runtime serves them as /node-hosts-file.. registerModuleTools("node-hosts-file", () => getSeatVerbs(hosts));