Files
mesh-catalog/modules/verdaccio/tools/index.ts
T

36 lines
1.3 KiB
TypeScript

// verdaccio's tools — its own code (novox/hq ADR 0039), importing verdaccio's own 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 { VerdaccioClient } from "../client.js";
export function getVerdaccioTools(verdaccio: VerdaccioClient): ToolDefinition[] {
return [
{
name: "verdaccio_list_packages",
description: "List every package hosted on the private npm registry, with each one's latest version.",
input: {},
run: async () => {
const packages = await verdaccio.listPackages();
return { count: packages.length, packages };
},
},
{
name: "verdaccio_package_info",
description: "Details of one package on the registry: its latest tag, all published versions, and description.",
input: { name: { type: "string", description: "the package name, e.g. '@novox/mesh-sdk'" } },
run: async (args) => verdaccio.getPackageInfo(String(args.name)),
},
];
}
// The tools exist only when a registry URL is configured; otherwise verdaccio contributes none
// rather than failing the whole runtime.
registerModuleTools("verdaccio", (env) => {
try {
return getVerdaccioTools(VerdaccioClient.fromEnv(env));
} catch {
return [];
}
});