fix(browser): keep local chrome relay defaults in remote gateway mode
This commit is contained in:
parent
151f26070b
commit
58a8b9c456
@ -59,6 +59,19 @@ describe("browser config", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps local browser relay defaults when gateway.mode=remote", () => {
|
||||
withEnv({ OPENCLAW_GATEWAY_PORT: undefined }, () => {
|
||||
const resolved = resolveBrowserConfig(undefined, {
|
||||
gateway: { mode: "remote", port: 443 },
|
||||
});
|
||||
expect(resolved.controlPort).toBe(18791);
|
||||
const chrome = resolveProfile(resolved, "chrome");
|
||||
expect(chrome?.driver).toBe("extension");
|
||||
expect(chrome?.cdpPort).toBe(18792);
|
||||
expect(chrome?.cdpUrl).toBe("http://127.0.0.1:18792");
|
||||
});
|
||||
});
|
||||
|
||||
it("supports overriding the local CDP auto-allocation range start", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
cdpPortRangeStart: 19000,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { BrowserConfig, BrowserProfileConfig, OpenClawConfig } from "../config/config.js";
|
||||
import { resolveGatewayPort } from "../config/paths.js";
|
||||
import { DEFAULT_GATEWAY_PORT, resolveGatewayPort } from "../config/paths.js";
|
||||
import {
|
||||
deriveDefaultBrowserCdpPortRange,
|
||||
deriveDefaultBrowserControlPort,
|
||||
@ -208,7 +208,17 @@ export function resolveBrowserConfig(
|
||||
const enabled = cfg?.enabled ?? DEFAULT_OPENCLAW_BROWSER_ENABLED;
|
||||
const evaluateEnabled = cfg?.evaluateEnabled ?? DEFAULT_BROWSER_EVALUATE_ENABLED;
|
||||
const gatewayPort = resolveGatewayPort(rootConfig);
|
||||
const controlPort = deriveDefaultBrowserControlPort(gatewayPort ?? DEFAULT_BROWSER_CONTROL_PORT);
|
||||
// In gateway.mode=remote, gateway.port often points to a remote ingress port (e.g. 443).
|
||||
// Browser relay/control ports remain local on the current host, so derive defaults from
|
||||
// the local gateway default unless browser ports are explicitly configured.
|
||||
const gatewayMode =
|
||||
typeof rootConfig?.gateway?.mode === "string"
|
||||
? rootConfig.gateway.mode.trim().toLowerCase()
|
||||
: undefined;
|
||||
const browserPortBase = gatewayMode === "remote" ? DEFAULT_GATEWAY_PORT : gatewayPort;
|
||||
const controlPort = deriveDefaultBrowserControlPort(
|
||||
browserPortBase ?? DEFAULT_BROWSER_CONTROL_PORT,
|
||||
);
|
||||
const defaultColor = normalizeHexColor(cfg?.color);
|
||||
const remoteCdpTimeoutMs = normalizeTimeoutMs(cfg?.remoteCdpTimeoutMs, 1500);
|
||||
const remoteCdpHandshakeTimeoutMs = normalizeTimeoutMs(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user