Skip to content

Commit c0dfe5d

Browse files
committed
feat: wire scanner to harness registry
1 parent e628004 commit c0dfe5d

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

src/scanner.mjs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,56 @@
44
* Claude-specific scanning now lives in src/harness/adapters/claude.mjs.
55
*/
66

7+
import { getAdapter, getDefaultAdapterId, listAdapters } from "./harness/registry.mjs";
8+
import { scanHarness as runHarnessScan } from "./harness/scanner-framework.mjs";
9+
710
export {
8-
scan,
911
detectEnterpriseMcp,
1012
getDisabledMcpServers,
1113
setDisabledMcpServers,
1214
scanMcpPolicy,
1315
checkMcpPolicy,
1416
} 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

Comments
 (0)