import { fileURLToPath } from "node:url";

import { npmSupplyChain, sensitiveMode } from "../packages/acuity/src/index.mjs";

const BUNDLED_NPM_FEED = fileURLToPath(new URL("../packages/acuity/data/chaindrop-2026-08-04.csv", import.meta.url));

/**
 * Calls Talons' Acuity subsystem. Pairing is constructed by the local runner,
 * never by MCP parameters or a model.
 */
export async function runAcuity({ capability, pairing, signal }) {
  if (signal?.aborted) throw signal.reason || new Error("Acuity assessment was aborted.");
  if (capability === "npm_supply_chain_assessment") return npmSupplyChain({
    workspace: pairing.workspaceRoot,
    home: pairing.homeRoot,
    feed_file: pairing.npmFeedFile || BUNDLED_NPM_FEED,
  });
  if (capability === "sensitive_file_mode_assessment") return sensitiveMode({ workspace: pairing.workspaceRoot, relative_path: pairing.relativePath });
  throw new Error(`Unknown Acuity capability: ${capability}.`);
}
