mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 00:02:53 +00:00
fix(sandbox): cap browser autostart timeout
This commit is contained in:
24
src/agents/sandbox/config.test.ts
Normal file
24
src/agents/sandbox/config.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { MAX_TIMER_TIMEOUT_MS } from "../../shared/number-coercion.js";
|
||||
import { resolveSandboxConfigForAgent } from "./config.js";
|
||||
|
||||
describe("sandbox config", () => {
|
||||
it("caps browser autostart timeout to a timer-safe delay", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: {
|
||||
defaults: {
|
||||
sandbox: {
|
||||
browser: {
|
||||
autoStartTimeoutMs: Number.MAX_SAFE_INTEGER,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(resolveSandboxConfigForAgent(cfg, "main").browser.autoStartTimeoutMs).toBe(
|
||||
MAX_TIMER_TIMEOUT_MS,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import type { SandboxSshSettings } from "../../config/types.sandbox.js";
|
||||
import { normalizeSecretInputString } from "../../config/types.secrets.js";
|
||||
import { resolveTimerTimeoutMs } from "../../shared/number-coercion.js";
|
||||
import { normalizeOptionalString } from "../../shared/string-coerce.js";
|
||||
import { resolveAgentConfig } from "../agent-scope.js";
|
||||
import {
|
||||
@@ -40,6 +41,10 @@ const DEFAULT_SANDBOX_SSH_WORKSPACE_ROOT = "/tmp/openclaw-sandboxes";
|
||||
type DangerousSandboxDockerBooleanKey = (typeof DANGEROUS_SANDBOX_DOCKER_BOOLEAN_KEYS)[number];
|
||||
type DangerousSandboxDockerBooleans = Pick<SandboxDockerConfig, DangerousSandboxDockerBooleanKey>;
|
||||
|
||||
function resolveSandboxBrowserAutoStartTimeoutMs(value: number | undefined): number {
|
||||
return resolveTimerTimeoutMs(value, DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
function resolveDangerousSandboxDockerBooleans(
|
||||
agentDocker?: Partial<SandboxDockerConfig>,
|
||||
globalDocker?: Partial<SandboxDockerConfig>,
|
||||
@@ -154,10 +159,9 @@ export function resolveSandboxBrowserConfig(params: {
|
||||
enableNoVnc: agentBrowser?.enableNoVnc ?? globalBrowser?.enableNoVnc ?? true,
|
||||
allowHostControl: agentBrowser?.allowHostControl ?? globalBrowser?.allowHostControl ?? false,
|
||||
autoStart: agentBrowser?.autoStart ?? globalBrowser?.autoStart ?? true,
|
||||
autoStartTimeoutMs:
|
||||
agentBrowser?.autoStartTimeoutMs ??
|
||||
globalBrowser?.autoStartTimeoutMs ??
|
||||
DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS,
|
||||
autoStartTimeoutMs: resolveSandboxBrowserAutoStartTimeoutMs(
|
||||
agentBrowser?.autoStartTimeoutMs ?? globalBrowser?.autoStartTimeoutMs,
|
||||
),
|
||||
binds: bindsConfigured ? binds : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user