// jackett's tools — its own code (novox/hq ADR 0039), importing jackett's client. Jackett has // nothing worth watching (an indexer proxy answers queries; it has no timeline of its own), so it // is a tools-only module: no events entrypoint, no broker. What is useful is asking it things. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { JackettClient } from "../client.js"; export function getJackettTools(jackett: JackettClient): ToolDefinition[] { return [ { name: "jackett_indexers", description: "List the indexers Jackett proxies, with their type and any last error.", input: { all: { type: "boolean", description: "include indexers not yet configured (default false)" } }, run: async (args) => { const indexers = await jackett.getIndexers(!args.all); return { count: indexers.length, indexers }; }, }, { name: "jackett_search", description: "Torznab search across Jackett's indexers, returning normalised torrent results.", input: { query: { type: "string", description: "the search query" }, indexer: { type: "string", description: 'an indexer id, or "all" to aggregate (default "all")' }, limit: { type: "number", description: "max results (default 25)" }, }, run: async (args) => { const query = String(args.query); const results = await jackett.search( query, args.indexer ? String(args.indexer) : "all", args.limit ? Number(args.limit) : 25, ); return { query, count: results.length, results }; }, }, ]; } // Only exposed when Jackett is configured; otherwise jackett contributes no tools rather than // failing the whole runtime. registerModuleTools("jackett", (env) => { try { return getJackettTools(JackettClient.fromEnv(env)); } catch { return []; } });