/**
* loadChambers(): the one door a test suite uses to get the chambers. With CERBERUS_CHAMBERS set (the path of a
* module exporting the Chambers interface), it loads that module: this is how Kognai runs the same suite against its
* production chambers, and how the review runs it against broken ones. Unset, it loads the kit's reference chambers.
*/
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import type { Chambers } from './types.ts';
export const CHAMBER_FUNCTIONS = ['createChallenge', 'challengeMessage', 'verifyChallenge', 'scoreAgent', 'screenIntent', 'soulHandshake', 'issueSessionToken', 'verifySessionToken', 'runAirlock'] as const;
export async function loadChambers(): Promise<Chambers> {
const path = process.env.CERBERUS_CHAMBERS;
const m: Record<string, unknown> = path ? await import(pathToFileURL(resolve(path)).href) : await import('./reference.ts');
const missing = CHAMBER_FUNCTIONS.filter((n) => typeof m[n] !== 'function');
if (missing.length) throw new Error(`${path || 'the reference'} does not export ${missing.join(', ')}`);
return Object.fromEntries(CHAMBER_FUNCTIONS.map((n) => [n, m[n]])) as unknown as Chambers;
}
agentgate-source: code mirror on Cloudflare Pages. All repos