xonecas.ioDon't click! Sean Caetano Martin Sign in

cast / commits / 0c1f1f6

Give agents an XFCE desktop in the VM

The bake installs Xorg, XFCE, lightdm with autologin, kitty, wmctrl,
xdotool, maim and xclip, and turns off screen blanking, DPMS, the
screensaver, the power manager, suspend and the panel's first-run
prompt. The VM gets a virtio GPU at 1280x800 and 8 GB of memory, and
is ready only once the desktop answers on DISPLAY=:0. agent-browser
opens headed windows there, and the prompts tell planners and agents
to check visual work on the shared desktop.

Co-Authored-By: Claude Opus 5.5

sacenox8 days ago0c1f1f6365a482de8323f96ee4875cb09c4d44f4parent 15e77698 files changed

assets/provision.sh+39-2
@@ -10,7 +10,9 @@ say stage 1 0
1010 apt-get update -q || fail "apt-get update failed"
1111 apt-get install -y -q --no-install-recommends \
1212 build-essential pkg-config libssl-dev cmake git curl wget ca-certificates unzip xz-utils jq ripgrep sqlite3 \
13- python3 python3-pip python3-venv python-is-python3 chromium fonts-liberation 2>&1 \
13+ python3 python3-pip python3-venv python-is-python3 chromium fonts-liberation fonts-dejavu \
14+ xserver-xorg-core xserver-xorg-input-libinput x11-xserver-utils x11-utils xauth dbus-x11 libgl1-mesa-dri mesa-utils \
15+ lightdm lightdm-gtk-greeter xfce4 kitty wmctrl xdotool maim xclip 2>&1 \
1416 | tee /dev/ttyS1 \
1517 | awk '/newly installed/ { n = $3 } /^(Get:|Unpacking |Setting up )/ { c++; if (n) { printf "CAST stage 1 %d\n", c * 100 / (3 * n); fflush() } }'
1618 [ "${PIPESTATUS[0]}" -eq 0 ] || fail "apt-get install failed"
@@ -30,7 +32,7 @@ NODE=$(curl -fsSL https://nodejs.org/dist/index.json | jq -r '[.[] | select(.lts
3032 curl -fsSL "https://nodejs.org/dist/$NODE/node-$NODE-linux-x64.tar.xz" | tar -C /usr/local -xJ --strip-components 1 || fail "node install failed"
3133 npm install -g -q corepack && corepack enable || fail "corepack install failed"
3234 say stage 2 90
33-npm install -g -q agent-browser && sudo -u cast -H agent-browser install || fail "agent-browser install failed"
35+npm install -g -q --allow-scripts=agent-browser agent-browser && sudo -u cast -H agent-browser install || fail "agent-browser install failed"
3436 say stage 2 100
3537
3638 say stage 3 0
@@ -49,4 +51,39 @@ mkdir -p /cast && chown cast:cast /cast
4951 for m in work cast; do echo "$m /$m 9p trans=virtio,version=9p2000.L,msize=524288,nofail 0 0" >> /etc/fstab; done
5052 touch /etc/cloud/cloud-init.disabled
5153 say stage 4 100
54+
55+say stage 5 0
56+X=$H/.config/xfce4/xfconf/xfce-perchannel-xml
57+mkdir -p /etc/lightdm/lightdm.conf.d /etc/X11/xorg.conf.d $X $H/.config/autostart $H/.config/kitty
58+groupadd -f autologin && gpasswd -a cast autologin >/dev/null || fail "autologin group failed"
59+printf '%s\n' '[Seat:*]' autologin-user=cast autologin-user-timeout=0 autologin-session=xfce > /etc/lightdm/lightdm.conf.d/50-cast.conf
60+printf '%s\n' 'Section "ServerFlags"' ' Option "BlankTime" "0"' ' Option "StandbyTime" "0"' \
61+ ' Option "SuspendTime" "0"' ' Option "OffTime" "0"' EndSection > /etc/X11/xorg.conf.d/10-noblank.conf
62+systemctl mask -q sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
63+systemctl set-default -q graphical.target && systemctl enable -q lightdm || fail "enabling lightdm failed"
64+for a in xfce4-screensaver light-locker xscreensaver xfce4-power-manager; do
65+ printf '%s\n' '[Desktop Entry]' Hidden=true > $H/.config/autostart/$a.desktop
66+done
67+cp /etc/xdg/xfce4/panel/default.xml $X/xfce4-panel.xml || fail "seeding the panel failed"
68+cat > $X/xfce4-power-manager.xml <<'XML'
69+<?xml version="1.0" encoding="UTF-8"?>
70+<channel name="xfce4-power-manager" version="1.0">
71+ <property name="xfce4-power-manager" type="empty">
72+ <property name="dpms-enabled" type="bool" value="false"/>
73+ <property name="blank-on-ac" type="int" value="0"/>
74+ <property name="lock-screen-suspend-hibernate" type="bool" value="false"/>
75+ </property>
76+</channel>
77+XML
78+cat > $X/xfwm4.xml <<'XML'
79+<?xml version="1.0" encoding="UTF-8"?>
80+<channel name="xfwm4" version="1.0">
81+ <property name="general" type="empty">
82+ <property name="use_compositing" type="bool" value="false"/>
83+ </property>
84+</channel>
85+XML
86+printf '%s\n' 'initial_window_width 120c' 'initial_window_height 40c' 'hide_window_decorations yes' > $H/.config/kitty/kitty.conf
87+chown -R cast:cast $H
88+say stage 5 100
5289 say done
src/agent/prompts.rs+4-1
@@ -6,6 +6,7 @@ const RULES: &str = "\
66 How cast runs a workflow:
77 - Steps run in ascending order. Tasks with the same step number run at the same time, each with its own agent, in the same /work checkout.
88 - Each agent sees only the original prompt and its own task, so every task must carry the decisions and context it needs.
9+- The VM has an XFCE desktop on DISPLAY=:0 that all agents share. Visual work is checked there, in real windows, with real screenshots.
910 - Each task lists the decisions it made, its acceptance criteria and the evidence to attach.
1011 - Evidence is the bare file names the task will write as proof, such as test output, logs or screenshots. Cast picks the folder, so give no directory.
1112
@@ -84,7 +85,8 @@ pub fn task(wf: &Workflow, task: &Task, evidence_dir: &str, prompt: &str) -> Str
8485 } else {
8586 format!(
8687 "\nThese tasks run at the same time as yours, each with its own agent, in the same /work:\n{}\
87- Change only the files your task needs. Do not commit, stash, reset, rebase, check out or clean, do not revert changes you did not make, and do not run project-wide formatters or generators. If your task says to use a git worktree, work only inside it.\n",
88+ Change only the files your task needs. Do not commit, stash, reset, rebase, check out or clean, do not revert changes you did not make, and do not run project-wide formatters or generators. If your task says to use a git worktree, work only inside it.\n\
89+ The other agents share the desktop with you: find your windows by the PID you started, never close or type into windows you did not open, and give agent-browser a --session of your own.\n",
8890 list(&others)
8991 )
9092 };
@@ -92,6 +94,7 @@ pub fn task(wf: &Workflow, task: &Task, evidence_dir: &str, prompt: &str) -> Str
9294 "You are running task {id} of a workflow in /work, the user's project.\n\
9395 Original prompt:\n<prompt>\n{prompt}\n</prompt>\n\n\
9496 Task {id}: {title}\nDecisions already made:\n{d}\nAcceptance criteria:\n{a}\nEvidence to attach:\n{e}{parallel}\n\
97+ The VM runs an XFCE desktop on DISPLAY=:0 at 1280x800, and agent-browser opens real windows on it. Look at and use visual work there as a person would, and follow the xfce-computer-use skill to drive and capture it.\n\
9598 Do the work. Save every piece of evidence into {evidence_dir}/ (create it).\n\
9699 Finish with a short summary of what changed and how each acceptance criterion was met.\n\
97100 Workflow {name} v{v}, step {step} of {steps}.\n",
src/settings/view.rs+1-1
@@ -157,7 +157,7 @@ pub fn view(s: &App, k: &Kit) -> El {
157157 let vm = col()
158158 .child(line(
159159 "Image",
160- "debian 13 + dev packages, chromium, rust, go, node, agent-browser, claude, opencode",
160+ "debian 13 + xfce desktop, dev packages, chromium, rust, go, node, agent-browser, claude, opencode",
161161 rebake,
162162 ))
163163 .child(line(
src/setup/mod.rs+5-5
@@ -6,7 +6,7 @@ use crate::vm::{Vm, env, files};
66
77 pub struct Setup {
88 pub show: bool,
9- pub pct: [u8; 5],
9+ pub pct: [u8; bake::STAGES.len()],
1010 pub running: bool,
1111 pub done: bool,
1212 pub detail: String,
@@ -26,7 +26,7 @@ impl Setup {
2626 let done = files::is_baked();
2727 Setup {
2828 show: !done,
29- pct: [if done { 100 } else { 0 }; 5],
29+ pct: [if done { 100 } else { 0 }; bake::STAGES.len()],
3030 running: false,
3131 done,
3232 detail: String::new(),
@@ -45,7 +45,7 @@ impl Setup {
4545 Progress::Done => {
4646 self.running = false;
4747 self.done = true;
48- self.pct = [100; 5];
48+ self.pct = [100; bake::STAGES.len()];
4949 }
5050 Progress::Failed(e) => {
5151 self.running = false;
@@ -80,7 +80,7 @@ impl App {
8080 self.machine_off();
8181 self.setup = Setup {
8282 show: true,
83- pct: [0; 5],
83+ pct: [0; bake::STAGES.len()],
8484 running: true,
8585 done: false,
8686 detail: String::new(),
@@ -109,7 +109,7 @@ mod tests {
109109 fn a_failed_bake_marks_the_stage_it_stopped_in() {
110110 let mut s = Setup {
111111 show: true,
112- pct: [0; 5],
112+ pct: [0; bake::STAGES.len()],
113113 running: true,
114114 done: false,
115115 detail: String::new(),
src/vm/bake.rs+2-1
@@ -10,12 +10,13 @@ const URL: &str =
1010 "https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2";
1111 const PROVISION: &str = include_str!("../../assets/provision.sh");
1212
13-pub const STAGES: [&str; 5] = [
13+pub const STAGES: [&str; 6] = [
1414 "Download debian-13 cloud image",
1515 "Install dev packages",
1616 "Install claude, opencode, rust, go, node and agent-browser",
1717 "Copy ~/.claude/CLAUDE.md + skills",
1818 "Mount working folder and cast data (9p)",
19+ "Set up the xfce desktop with autologin and no screen blanking",
1920 ];
2021
2122 #[derive(Clone)]
src/vm/env.rs+1-1
@@ -3,7 +3,7 @@ use crate::vm::ssh;
33
44 pub fn render(cfg: &Config) -> String {
55 let mut out = String::from(
6- "export PATH=\"$HOME/.local/bin:$HOME/.opencode/bin:$HOME/.cargo/bin:/usr/local/go/bin:$HOME/go/bin:$PATH\"\n",
6+ "export PATH=\"$HOME/.local/bin:$HOME/.opencode/bin:$HOME/.cargo/bin:/usr/local/go/bin:$HOME/go/bin:$PATH\"\nexport DISPLAY=:0\nexport AGENT_BROWSER_HEADED=1\n",
77 );
88 for (name, secret) in [
99 (CLAUDE_ENV, cfg.claude_token()),
src/vm/mod.rs+5-2
@@ -62,14 +62,17 @@ pub fn boot(bus: &Bus, dir: &Path, state: &Path) -> std::io::Result<Machine> {
6262 std::thread::spawn(move || {
6363 let start = Instant::now();
6464 while start.elapsed() < Duration::from_secs(180) {
65- if ssh::run(port, "mountpoint -q /work && mountpoint -q /cast") {
65+ if ssh::run(
66+ port,
67+ "mountpoint -q /work && mountpoint -q /cast && DISPLAY=:0 xset q",
68+ ) {
6669 ssh::run(port, &identity);
6770 return bus.send(Event::Vm(Ok(port)));
6871 }
6972 std::thread::sleep(Duration::from_secs(2));
7073 }
7174 bus.send(Event::Vm(Err(
72- "the VM did not answer over ssh within 3 minutes".into(),
75+ "the VM did not come up with its mounts and desktop within 3 minutes".into(),
7376 )));
7477 });
7578 Ok(Machine(child))
src/vm/qemu.rs+2-2
@@ -16,11 +16,11 @@ pub fn command(disk: &Path, shares: &[(&str, &Path, bool)]) -> Command {
1616 "-cpu",
1717 "host",
1818 "-m",
19- "4096",
19+ "8192",
2020 "-smp",
2121 &cpus.to_string(),
2222 ])
23- .args(["-display", "none", "-no-reboot"])
23+ .args(["-display", "none", "-vga", "virtio", "-no-reboot"])
2424 .arg("-drive")
2525 .arg(format!("file={},if=virtio,format=qcow2", disk.display()));
2626 for (tag, path, readonly) in shares {