// lavinmq's tools — lavinmq's own code (novox/hq ADR 0039), importing lavinmq's own management // client. They return structured data; the mesh serves them through the sdk's tool harness. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { LavinmqClient } from "../client.js"; export function getLavinmqTools(lavinmq: LavinmqClient): ToolDefinition[] { return [ { name: "amqp_list_vhosts", description: "List the lavinmq virtual hosts — one per consumer that was granted a broker.", input: {}, run: async () => ({ vhosts: await lavinmq.listVhosts() }), }, { name: "amqp_list_queues", description: "List the queues on a vhost with message and consumer counts. Omit vhost for the root '/'.", input: { vhost: { type: "string", description: "the vhost to list, e.g. a consumer's login; defaults to '/'" } }, run: async (args) => ({ queues: await lavinmq.listQueues(args.vhost ? String(args.vhost) : undefined) }), }, ]; } // The tools exist only when the server can be reached from the environment; without it, lavinmq // contributes none rather than failing the whole tool runtime. registerModuleTools("lavinmq", (env) => { try { return getLavinmqTools(LavinmqClient.fromEnv(env)); } catch { return []; } });