|
4 | 4 | * Claude-specific scanning now lives in src/harness/adapters/claude.mjs. |
5 | 5 | */ |
6 | 6 |
|
| 7 | +import { getAdapter, getDefaultAdapterId, listAdapters } from "./harness/registry.mjs"; |
| 8 | +import { scanHarness as runHarnessScan } from "./harness/scanner-framework.mjs"; |
| 9 | + |
7 | 10 | export { |
8 | | - scan, |
9 | 11 | detectEnterpriseMcp, |
10 | 12 | getDisabledMcpServers, |
11 | 13 | setDisabledMcpServers, |
12 | 14 | scanMcpPolicy, |
13 | 15 | checkMcpPolicy, |
14 | 16 | } from "./harness/adapters/claude.mjs"; |
| 17 | + |
| 18 | +export { getAdapter, getDefaultAdapterId, listAdapters }; |
| 19 | + |
| 20 | +function normalizeHarnessArgs(harnessIdOrOptions, maybeOptions) { |
| 21 | + if (typeof harnessIdOrOptions === "string") { |
| 22 | + return { |
| 23 | + harnessId: harnessIdOrOptions || getDefaultAdapterId(), |
| 24 | + options: maybeOptions || {}, |
| 25 | + }; |
| 26 | + } |
| 27 | + |
| 28 | + return { |
| 29 | + harnessId: getDefaultAdapterId(), |
| 30 | + options: harnessIdOrOptions || {}, |
| 31 | + }; |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * Run a scan through the harness registry. |
| 36 | + * |
| 37 | + * @param {string|Record<string, *>} [harnessIdOrOptions] |
| 38 | + * @param {Record<string, *>} [maybeOptions] |
| 39 | + * @returns {Promise<import("./harness/interface.mjs").ScanResult>} |
| 40 | + */ |
| 41 | +export async function scanHarness(harnessIdOrOptions = getDefaultAdapterId(), maybeOptions = {}) { |
| 42 | + const { harnessId, options } = normalizeHarnessArgs(harnessIdOrOptions, maybeOptions); |
| 43 | + const adapter = await getAdapter(harnessId); |
| 44 | + return runHarnessScan(adapter, options); |
| 45 | +} |
| 46 | + |
| 47 | +/** |
| 48 | + * Legacy scanner API. Defaults to Claude and preserves the pre-harness |
| 49 | + * response shape expected by the UI, tests, and older imports. |
| 50 | + */ |
| 51 | +export async function scan(options = {}) { |
| 52 | + const result = await scanHarness(getDefaultAdapterId(), options); |
| 53 | + return { |
| 54 | + scopes: result.scopes, |
| 55 | + items: result.items, |
| 56 | + counts: result.counts, |
| 57 | + enterpriseMcp: result.adapterData.enterpriseMcp, |
| 58 | + }; |
| 59 | +} |
0 commit comments