fix(gateway): start browser control server

This commit is contained in:
Peter Steinberger
2025-12-20 19:16:49 +00:00
parent c050a82c3a
commit 21ac34bc6a
2 changed files with 6 additions and 10 deletions

View File

@@ -78,8 +78,6 @@ enum GatewayLaunchAgentManager {
<dict>
<key>PATH</key>
<string>\(preferredPath)</string>
<key>CLAWDIS_SKIP_BROWSER_CONTROL_SERVER</key>
<string>1</string>
<key>CLAWDIS_IMAGE_BACKEND</key>
<string>sips</string>
</dict>

View File

@@ -144,14 +144,12 @@ let stopBrowserControlServerIfStarted: (() => Promise<void>) | null = null;
async function startBrowserControlServerIfEnabled(): Promise<void> {
if (process.env.CLAWDIS_SKIP_BROWSER_CONTROL_SERVER === "1") return;
// Lazy import to keep optional heavyweight deps (playwright/electron) out of
// embedded/daemon builds.
const spec =
process.env.CLAWDIS_BROWSER_CONTROL_MODULE ??
// Intentionally not a static string literal so bun bundling can omit it.
// (The embedded gateway sets CLAWDIS_SKIP_BROWSER_CONTROL_SERVER=1.)
["..", "browser", "server.js"].join("/");
const mod = await import(spec);
// Lazy import: keeps startup fast, but still bundles for the embedded
// gateway (bun --compile) via the static specifier path.
const override = process.env.CLAWDIS_BROWSER_CONTROL_MODULE?.trim();
const mod = override
? await import(override)
: await import("../browser/server.js");
stopBrowserControlServerIfStarted = mod.stopBrowserControlServer;
await mod.startBrowserControlServerFromConfig(defaultRuntime);
}