Spaces:
Build error
Build error
Download plugins/openclaw/src/plugin/index.ts from minhtudragon/headroom_3: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/spaces/minhtudragon/headroom_3/resolve/0a80b52d1a8087607c9376d38cb254924221171c/plugins/openclaw/src/plugin/index.ts
- Command line
-
hf download hf://spaces/minhtudragon/headroom_3@0a80b52d1a8087607c9376d38cb254924221171c/plugins/openclaw/src/plugin/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/minhtudragon/headroom_3/resolve/0a80b52d1a8087607c9376d38cb254924221171c/plugins/openclaw/src/plugin/index.ts
1.65 kB
| /** | |
| * Headroom OpenClaw Plugin — register ContextEngine + CCR retrieval tool. | |
| * | |
| * Usage: | |
| * openclaw plugins install headroom-ai/openclaw | |
| * | |
| * Configuration (in ~/.openclaw/config.json or ~/.clawdbot/clawdbot.json): | |
| * { | |
| * "plugins": { | |
| * "slots": { "contextEngine": "headroom" }, | |
| * "entries": { "headroom": { "enabled": true } } | |
| * } | |
| * } | |
| */ | |
| /* eslint-disable @typescript-eslint/no-explicit-any */ | |
| import { HeadroomContextEngine } from "../engine.js"; | |
| import { normalizeAndValidateProxyUrl } from "../proxy-manager.js"; | |
| import { createHeadroomRetrieveTool } from "../tools/headroom-retrieve.js"; | |
| export default function headroomPlugin(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), | |
| }); | |
| // Register as context engine | |
| api.registerContextEngine("headroom", () => engine); | |
| // Register CCR retrieval tool (active once proxy is running) | |
| api.registerTool((ctx: any) => { | |
| const activeProxyUrl = engine.getProxyUrl() ?? proxyUrl; | |
| if (!activeProxyUrl) return null; | |
| return createHeadroomRetrieveTool({ proxyUrl: activeProxyUrl }); | |
| }); | |
| logger.info("[headroom] Plugin registered"); | |
| } | |