mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 01:23:29 +00:00
refactor(sandbox): auto-recreate browser container on config changes (#16254)
This commit is contained in:
committed by
GitHub
parent
31791233d6
commit
1f1fc095a0
@@ -1,5 +1,5 @@
|
||||
import crypto from "node:crypto";
|
||||
import type { SandboxDockerConfig, SandboxWorkspaceAccess } from "./types.js";
|
||||
import type { SandboxBrowserConfig, SandboxDockerConfig, SandboxWorkspaceAccess } from "./types.js";
|
||||
|
||||
type SandboxHashInput = {
|
||||
docker: SandboxDockerConfig;
|
||||
@@ -8,6 +8,17 @@ type SandboxHashInput = {
|
||||
agentWorkspaceDir: string;
|
||||
};
|
||||
|
||||
type SandboxBrowserHashInput = {
|
||||
docker: SandboxDockerConfig;
|
||||
browser: Pick<
|
||||
SandboxBrowserConfig,
|
||||
"cdpPort" | "vncPort" | "noVncPort" | "headless" | "enableNoVnc"
|
||||
>;
|
||||
workspaceAccess: SandboxWorkspaceAccess;
|
||||
workspaceDir: string;
|
||||
agentWorkspaceDir: string;
|
||||
};
|
||||
|
||||
function isPrimitive(value: unknown): value is string | number | boolean | bigint | symbol | null {
|
||||
return value === null || (typeof value !== "object" && typeof value !== "function");
|
||||
}
|
||||
@@ -58,6 +69,14 @@ function primitiveToString(value: unknown): string {
|
||||
}
|
||||
|
||||
export function computeSandboxConfigHash(input: SandboxHashInput): string {
|
||||
return computeHash(input);
|
||||
}
|
||||
|
||||
export function computeSandboxBrowserConfigHash(input: SandboxBrowserHashInput): string {
|
||||
return computeHash(input);
|
||||
}
|
||||
|
||||
function computeHash(input: unknown): string {
|
||||
const payload = normalizeForHash(input);
|
||||
const raw = JSON.stringify(payload);
|
||||
return crypto.createHash("sha1").update(raw).digest("hex");
|
||||
|
||||
Reference in New Issue
Block a user