// model-usage's tools — its own read-only query surface over the usage store (novox/hq ADR 0039: // the tools and the client they call live in the module). The store is opened from the environment; // when it cannot be (no DATABASE_URL), the module contributes no tools rather than failing the whole // tool runtime — the postgres precedent. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { UsageStore } from "../store.js"; export function getUsageTools(store: UsageStore): ToolDefinition[] { return [ { name: "model_usage_current", description: "The latest model-usage reading per (licence, consumer, period, metric), across both grains, optionally restricted to one licence.", input: { licence: { type: "string", description: "restrict to one licence (optional)" }, }, run: async (args) => { const licence = args.licence ? String(args.licence) : undefined; return { usage: await store.current(licence) }; }, }, ]; } registerModuleTools("model-usage", (env) => { try { return getUsageTools(UsageStore.fromEnv(env)); } catch { return []; } });