// tautulli's tools — importing tautulli's own client (novox/hq ADR 0039). They return structured // data; the mesh serves them through the sdk's tool harness. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { TautulliClient } from "../client.js"; export function getTautulliTools(tautulli: TautulliClient): ToolDefinition[] { return [ { name: "tautulli_activity", description: "Current Plex activity as Tautulli sees it — who is streaming what, and progress.", input: {}, run: async () => tautulli.getActivity(), }, { name: "tautulli_history", description: "Recent Plex watch history — who watched what, and whether they finished.", input: { length: { type: "number", description: "how many rows (default 25)" } }, run: async (args) => { const history = await tautulli.getHistory(args.length ? Number(args.length) : 25); return { count: history.length, history }; }, }, { name: "tautulli_stats", description: "Tautulli home statistics — most-watched media, most-active users, and platforms.", input: {}, run: async () => { const stats = await tautulli.getHomeStats(); return { count: stats.length, stats }; }, }, ]; } // The tools exist only when an API key can be resolved; without one, tautulli contributes none // rather than failing the whole tool runtime. registerModuleTools("tautulli", (env) => { try { return getTautulliTools(TautulliClient.fromEnv(env)); } catch { return []; } });