Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

fix(openclaw): use lightweight headroom launcher checks

JerrettDavis4d8b76f7da81
diff --git a/plugins/openclaw/src/proxy-manager.ts b/plugins/openclaw/src/proxy-manager.ts
index b85e0373a..76bddc160 100644
--- a/plugins/openclaw/src/proxy-manager.ts
+++ b/plugins/openclaw/src/proxy-manager.ts
@@ -51,6 +51,9 @@ interface LaunchSpec {
checkUseShell?: boolean;
}
+const HEADROOM_MODULE_DISCOVERY_SNIPPET =
+ "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec('headroom') else 1)";
+
export class ProxyManager {
private config: ProxyManagerConfig;
private logger: ProxyManagerLogger;
@@ -214,9 +217,12 @@ export class ProxyManager {
label: "PATH: headroom",
command: "headroom",
args: commonArgs,
- checkCommand: "headroom",
- checkArgs: ["--version"],
+ checkCommand: process.platform === "win32" ? "where.exe" : "sh",
+ checkArgs: process.platform === "win32"
+ ? ["headroom"]
+ : ["-lc", "command -v headroom >/dev/null 2>&1"],
useShell: process.platform === "win32",
+ checkUseShell: false,
});
// 2) Local npm install (inside plugin install path)
@@ -266,7 +272,7 @@ export class ProxyManager {
command: pyCmd,
args: ["-m", "headroom.cli", ...commonArgs],
checkCommand: pyCmd,
- checkArgs: ["-c", "import headroom"],
+ checkArgs: ["-c", HEADROOM_MODULE_DISCOVERY_SNIPPET],
});
}
diff --git a/plugins/openclaw/test/proxy-manager.test.ts b/plugins/openclaw/test/proxy-manager.test.ts
index 80ef27b16..16ff95b35 100644
--- a/plugins/openclaw/test/proxy-manager.test.ts
+++ b/plugins/openclaw/test/proxy-manager.test.ts
@@ -204,6 +204,35 @@ describe("ProxyManager launch internals", () => {
expect(commands).toContain("py");
});
+ it("uses lightweight PATH checks instead of booting the headroom CLI", () => {
+ const manager = new ProxyManager({});
+ const specs = (manager as any).buildLaunchSpecs("127.0.0.1", "8787") as Array<Record<string, unknown>>;
+ const pathSpec = specs[0];
+
+ expect(pathSpec.command).toBe("headroom");
+ expect(pathSpec.args).toEqual(["proxy", "--host", "127.0.0.1", "--port", "8787"]);
+ if (process.platform === "win32") {
+ expect(pathSpec.checkCommand).toBe("where.exe");
+ expect(pathSpec.checkArgs).toEqual(["headroom"]);
+ expect(pathSpec.checkUseShell).toBe(false);
+ } else {
+ expect(pathSpec.checkCommand).toBe("sh");
+ expect(pathSpec.checkArgs).toEqual(["-lc", "command -v headroom >/dev/null 2>&1"]);
+ }
+ });
+
+ it("uses lightweight module discovery for python fallback checks", () => {
+ const manager = new ProxyManager({ pythonPath: "C:\\Python311\\python.exe" });
+ const specs = (manager as any).buildLaunchSpecs("127.0.0.1", "8787") as Array<Record<string, unknown>>;
+ const pythonSpec = specs.find((spec) => spec.command === "C:\\Python311\\python.exe");
+
+ expect(pythonSpec).toBeDefined();
+ expect(pythonSpec?.checkArgs).toEqual([
+ "-c",
+ "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec('headroom') else 1)",
+ ]);
+ });
+
it("uses first available launcher from provided specs", async () => {
const manager = new ProxyManager({});
(manager as any).buildLaunchSpecs = () => [