Files
mesh-media-catalog/modules/kometa/tools/index.ts
T
jschoubben db3adfa4c6 The media chain as mesh modules, in one catalogue
sonarr, radarr, lidarr, bazarr, nzbget, qbittorrent, jackett, bookshelf,
plex, tautulli, kometa and ombi, taken from the novox/mesh-catalog branches
that prepared them for ace (PRs 145-168), consolidated in stack order.
kometa gains a minimal runtime sidecar (kometa_status, kometa_config) and
declares its tmdb key as an own secret instead of a "secret" requirement.
2026-09-30 21:32:59 +02:00

40 lines
1.4 KiB
TypeScript

// kometa's tools — its own code (novox/hq ADR 0039), importing kometa's client. Kometa runs on a
// schedule and has no API, so the tools read what it leaves behind. Two tools, the example to
// extend: what it ran with, and how its last runs went.
import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools";
import { KometaClient } from "../client.js";
export function getKometaTools(kometa: KometaClient): ToolDefinition[] {
return [
{
name: "kometa_status",
description: "Kometa's last runs: the newest logs it wrote and their last lines.",
input: {
runs: { type: "number", description: "how many runs, newest first (default 3)" },
tail: { type: "number", description: "lines per run (default 20)" },
},
run: async (args) => {
const runs = kometa.runs(args.runs ? Number(args.runs) : 3, args.tail ? Number(args.tail) : 20);
return { count: runs.length, runs };
},
},
{
name: "kometa_config",
description: "The config.yml kometa runs with, credentials redacted.",
input: {},
run: async () => ({ config: kometa.config() }),
},
];
}
// Only exposed when the config dir is there; otherwise kometa contributes no tools rather than
// failing the whole runtime.
registerModuleTools("kometa", (env) => {
try {
return getKometaTools(KometaClient.fromEnv(env));
} catch {
return [];
}
});