// dnsmasq's tools — a resolver's two useful questions: what does it answer, and does it answer a // given name. Moved into the module (novox/hq ADR 0039); the mesh serves them through the sdk. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { DnsmasqClient } from "../client.js"; export function getDnsmasqTools(dnsmasq: DnsmasqClient): ToolDefinition[] { return [ { name: "dnsmasq_names", description: "The mesh names this node's resolver answers — each a machine and everything under it.", input: {}, run: async () => ({ names: await dnsmasq.answeredNames() }), }, { name: "dnsmasq_resolve", description: "Resolve a mesh name through this node's own resolver — the check that wildcard-resolution answers.", input: { name: { type: "string", description: "a name to resolve, e.g. plex.anchor.internal" } }, run: async (args) => { const name = String(args.name); try { return { name, addresses: await dnsmasq.resolve(name) }; } catch (err) { return { name, addresses: [], error: err instanceof Error ? err.message : String(err) }; } }, }, ]; } registerModuleTools("dnsmasq", (env) => getDnsmasqTools(DnsmasqClient.fromEnv(env)));