Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(local-vm): keep the profile merge going when cp skips files, read a copied lock link as copied, and rebuild images so they carry the safe start-up script

milind-soni548955fa1f4f
diff --git a/server/container-computer.test.ts b/server/container-computer.test.ts
index f0c92b98e5..24633c3869 100644
--- a/server/container-computer.test.ts
+++ b/server/container-computer.test.ts
@@ -1049,7 +1049,7 @@ describe("Cua integration", () => {
expect(dockerfile).toContain("6a73f9541c2de74158c0e7cf6b0a58ef774f5a780bf191f2d7ec9cc53efe2bf2");
expect(dockerfile).toContain("/usr/local/share/licenses/noto-cjk/OFL.txt");
expect(dockerfile).toContain("fc-cache -f");
- expect(IMAGE_LAYER_VERSION).toBe("9");
+ expect(IMAGE_LAYER_VERSION).toBe("10");
});
it("starts the driver's Chrome without its own sandbox inside the hardened container", () => {
diff --git a/server/container-computer.ts b/server/container-computer.ts
index 92112188c8..bed684bdea 100644
--- a/server/container-computer.ts
+++ b/server/container-computer.ts
@@ -53,7 +53,7 @@ export const BASE_IMAGE = `${BASE_IMAGE_REPOSITORY}@${BASE_IMAGE_DIGEST}`;
// localhost/ is explicit: Podman prepends it to unqualified build tags and may then resolve the name on Docker Hub.
// Image and container labels, not this mutable tag, decide compatibility.
export const IMAGE_REPOSITORY = "localhost/openmausbot/cua-local-vm";
-export const IMAGE_LAYER_VERSION = "9";
+export const IMAGE_LAYER_VERSION = "10";
export const IMAGE_LAYER_LABEL = "com.openmausbot.image-layer";
export const IMAGE = `${IMAGE_REPOSITORY}:driver-${CUA_DRIVER_VERSION}-v${IMAGE_LAYER_VERSION}`;
export const CONTAINER = "openmausbot-computer";
diff --git a/server/container-workspace.ts b/server/container-workspace.ts
index 1d3cfb86f2..cd416c60c0 100644
--- a/server/container-workspace.ts
+++ b/server/container-workspace.ts
@@ -16,9 +16,11 @@ export function workspacePreparationDockerfile(workspace: string): string {
' target="$2"' \\
' if [ -e "$source" ] && [ ! -L "$source" ]; then' \\
' if [ -d "$source" ]; then' \\
- ' cp -an "$source/." "$target/"' \\
+ ' cp -an "$source/." "$target/" || true' \\
' missing=$(cd "$source" && find . -mindepth 1 -print | while IFS= read -r item; do' \\
- ' if [ -f "$item" ]; then' \\
+ ' if [ -L "$item" ]; then' \\
+ ' [ "$(readlink "$item")" = "$(readlink "$target/$item" || true)" ] || echo "$item"' \\
+ ' elif [ -f "$item" ]; then' \\
' cmp -s "$item" "$target/$item" || echo "$item"' \\
' elif [ ! -e "$target/$item" ]; then' \\
' echo "$item"' \\
diff --git a/server/local-vm-browser-profiles.test.ts b/server/local-vm-browser-profiles.test.ts
index f0f5b2f998..08e731bfdb 100644
--- a/server/local-vm-browser-profiles.test.ts
+++ b/server/local-vm-browser-profiles.test.ts
@@ -101,6 +101,19 @@ describe.skipIf(process.platform === "win32")("the image's start-up script keeps
expect(readdirSync(workspace).some((name) => name.startsWith("unmerged-local-"))).toBe(true);
});
+ it("reads a profile's dangling lock link as copied, so a complete profile is not moved aside", () => {
+ const dir = scratch();
+ const home = join(dir, "home");
+ const workspace = join(dir, "workspace");
+ mkdirSync(join(home, ".config", "google-chrome", "Default"), { recursive: true });
+ writeFileSync(join(home, ".config", "google-chrome", "Default", "Cookies"), "cookies");
+ symlinkSync("old-host-4242", join(home, ".config", "google-chrome", "SingletonLock"));
+ runPrepare(prepareScript(dir, workspace), home);
+ expect(readFileSync(join(workspace, ".browser-profiles", "google-chrome", "Default", "Cookies"), "utf8")).toBe("cookies");
+ expect(lstatSync(join(home, ".config", "google-chrome")).isSymbolicLink()).toBe(true);
+ expect(readdirSync(workspace).filter((name) => name.startsWith("unmerged-"))).toEqual([]);
+ });
+
it("keeps a home path that is a regular file instead of deleting it silently", () => {
const dir = scratch();
const home = join(dir, "home");