INNER CODE UNIT · TypeScript
registerHeadroomPlugin
headroomlabs-ai/headroom · plugins/openclaw/src/plugin/index.ts:35
export function registerHeadroomPlugin(api: any) {
const config = api.config?.plugins?.entries?.headroom?.config ?? {};
const logger = api.logger ?? console;
const rawProxyUrl = config.proxyUrl;
const proxyUrl =
typeof rawProxyUrl === "string" && rawProxyUrl.trim().length > 0
? normalizeAndValidateProxyUrl(rawProxyUrl)
: undefined;
const engine = new HeadroomContextEngine({ ...config, proxyUrl }, {
info: (m: string) => logger.info(m),
warn: (m: string) => logger.warn(m),
error: (m: string) => logger.error(m),
debug: (m: string) => logger.debug?.(m),
});
const gatewayProviderIds = resolveGatewayProviderIds(config);
let validatedConfiguredProxyUrl: string | null = null;
let configuredProxyProbePromise: Promise<string | null> | null = null;