All your machines, one app. For you and your AI agents: agent sessions, desktops, files, logs and GitHub across your Macs, Linux and Windows machines, with an MCP server.
Demo VMs, schedules and Add machine suggestions; Schedules and VM views
Adib Hanna18683820ebd5
diff --git a/src/api.rs b/src/api.rsindex 504c0f4..15ac5e9 100644--- a/src/api.rs+++ b/src/api.rs@@ -644,6 +644,17 @@ pub struct TailnetHost {pub machine_id: Option<String>,}+/// Made-up suggestions for the demo's Add machine dialog.+fn demo_ssh_hosts() -> SshHostsResponse {+ let tail = |name: &str, os: &str| TailnetHost { name: name.into(), host: format!("{name}.tail0000.ts.net"), dns_name: format!("{name}.tail0000.ts.net."), os: os.into(), online: true, machine_id: None };+ let net = |name: &str, ssh: bool, mac: bool| crate::fleet::discover::NetworkHost { name: name.into(), host: format!("{name}.local"), addresses: vec!["192.168.1.60".into()], ssh, mac };+ SshHostsResponse {+ hosts: vec!["build-box".into(), "gpu-rig".into(), "nas".into()],+ tailnet: vec![tail("studio", "macOS"), tail("render-01", "linux")],+ network: vec![net("living-room-mac", false, true), net("pi-garage", true, false)],+ }+}+// ---------------------------------------------------------------------------// Conversions@@ -1086,6 +1097,10 @@ pub fn settings(engine: &Arc<Engine>) -> SettingsOut {}pub async fn ssh_hosts(engine: &Arc<Engine>) -> SshHostsResponse {+ // The demo makes its own up: nothing of this computer's shows in it.+ if engine.demo_world().is_some() {+ return demo_ssh_hosts();+ }let hosts = crate::ops::ssh_hosts();// Listening on the local network takes a moment; do it meanwhile.let listening = tokio::task::spawn_blocking(|| crate::fleet::discover::browse(Duration::from_millis(2500)));@@ -2286,9 +2301,9 @@ mod tests {async fn status_reads_the_demo_machines() {let engine = demo();let s = status(&engine, StatusRequest { refresh: true }, Surface::Mcp).await.unwrap();- assert_eq!(s.counts.machines, 7);+ assert_eq!(s.counts.machines, 9);assert!(s.demo && s.github.live);- assert!(s.summary.contains("7 machines"), "{}", s.summary);+ assert!(s.summary.contains("9 machines"), "{}", s.summary);let harbor = s.machines.iter().find(|m| m.id == "harbor").unwrap();assert_eq!(harbor.status, "offline");assert!(harbor.error.is_some());diff --git a/src/demo.rs b/src/demo.rsindex e7e3ae6..d2f8d04 100644--- a/src/demo.rs+++ b/src/demo.rs@@ -16,6 +16,7 @@ const ORG: &str = "acme";/// NAS, a MacBook that's usually asleep, and a cloud machine created days ago.fn inventory_text(now: DateTime<Utc>) -> String {let created = (now - chrono::Duration::days(3) - chrono::Duration::hours(5)).to_rfc3339_opts(chrono::SecondsFormat::Secs, true);+ let vm_created = (now - chrono::Duration::days(1)).to_rfc3339_opts(chrono::SecondsFormat::Secs, true);format!(r#"[[machine]]name = "Forge"@@ -53,6 +54,24 @@ notes = "The travel MacBook, usually asleep."name = "Vault"host = "vault"notes = "Build cache and backups."++[[machine]]+name = "win-test"+host = "127.0.0.1"+user = "ci"+port = 2201+ssh_options = ["-J", "beacon", "-o", "HostKeyAlias=muxen-win-test"]+direct_address = "beacon:47830"+vm = {{ host = "beacon", os = "windows", version = "windows-11", container = "muxen-win-test", web_port = 8007, created_at = "{vm_created}" }}++[[machine]]+name = "sandbox"+host = "127.0.0.1"+user = "ci"+port = 2202+ssh_options = ["-J", "[email protected]", "-o", "HostKeyAlias=muxen-sandbox"]+direct_address = "forge.local:47831"+vm = {{ host = "forge", os = "linux", version = "ubuntu-24.04", container = "muxen-sandbox", created_at = "{vm_created}" }}"#)}@@ -84,6 +103,8 @@ const HARDWARE: &[Hardware] = &[Hardware { id: "pebble", os: "linux", arch: "x86_64", os_version: "Fedora Linux 42 (Workstation Edition)", cores: 8, mem_gb: 32, base_mem: 0.36, disk_total_gb: 1000, disk_free_gb: 512.0, up_hours: 6, reachable: true, desktop: true, docker: Some("28.5.2"), sudo: Some("passwordless") },Hardware { id: "dev-1", os: "linux", arch: "x86_64", os_version: "Ubuntu 24.04.3 LTS", cores: 2, mem_gb: 4, base_mem: 0.31, disk_total_gb: 80, disk_free_gb: 61.0, up_hours: 3 * 24 + 5, reachable: true, desktop: false, docker: Some("29.1.3"), sudo: Some("passwordless") },Hardware { id: "harbor", os: "darwin", arch: "arm64", os_version: "macOS 26.1", cores: 12, mem_gb: 36, base_mem: 0.3, disk_total_gb: 1000, disk_free_gb: 470.0, up_hours: 3, reachable: false, desktop: true, docker: None, sudo: None },+ Hardware { id: "win-test", os: "windows", arch: "AMD64", os_version: "Microsoft Windows 11 Pro", cores: 4, mem_gb: 8, base_mem: 0.38, disk_total_gb: 64, disk_free_gb: 38.0, up_hours: 22, reachable: true, desktop: true, docker: None, sudo: None },+ Hardware { id: "sandbox", os: "linux", arch: "aarch64", os_version: "Ubuntu 24.04.3 LTS", cores: 4, mem_gb: 8, base_mem: 0.12, disk_total_gb: 2000, disk_free_gb: 1240.0, up_hours: 20, reachable: true, desktop: false, docker: None, sudo: Some("passwordless") },Hardware { id: "vault", os: "linux", arch: "aarch64", os_version: "Debian GNU/Linux 12 (bookworm)", cores: 4, mem_gb: 8, base_mem: 0.22, disk_total_gb: 4000, disk_free_gb: 41.0, up_hours: 54 * 24 + 11, reachable: true, desktop: false, docker: Some("28.5.1"), sudo: Some("password") },// Not in the demo's machines; tests add it to try Windows.Hardware { id: "test-windows", os: "windows", arch: "AMD64", os_version: "Microsoft Windows 11 Pro", cores: 8, mem_gb: 32, base_mem: 0.33, disk_total_gb: 1000, disk_free_gb: 700.0, up_hours: 30, reachable: true, desktop: false, docker: None, sudo: None },@@ -171,6 +192,27 @@ const GENERIC: Hardware = Hardware {sudo: Some("password"),};+/// The containers the demo's VMs run in, on their hosts.+fn demo_containers(machine_id: &str) -> Vec<crate::probe::PublishedContainer> {+ use crate::probe::{PublishedContainer, PublishedPort};+ let port = |ip: &str, host_port: u16, target: &str| PublishedPort { host_ip: ip.into(), host_port, target: target.into() };+ match machine_id {+ "beacon" => vec![PublishedContainer {+ name: "muxen-win-test".into(),+ state: "running".into(),+ image: "dockurr/windows".into(),+ ports: vec![port("127.0.0.1", 2201, "22/tcp"), port("127.0.0.1", 8007, "8006/tcp"), port("", 47830, "47821/udp")],+ }],+ "forge" => vec![PublishedContainer {+ name: "muxen-sandbox".into(),+ state: "running".into(),+ image: "ubuntu:24.04".into(),+ ports: vec![port("127.0.0.1", 2202, "22/tcp"), port("", 47831, "47821/udp")],+ }],+ _ => Vec::new(),+ }+}+fn hardware(machine_id: &str) -> &'static Hardware {HARDWARE.iter().find(|h| h.id == machine_id).unwrap_or(&GENERIC)}@@ -340,10 +382,15 @@ impl World {lan_broadcast: Some("192.168.1.255".into()),reboot_required: hw.id == "pebble",failed_units: Vec::new(),- virt: None,- published: Vec::new(),+ // The demo's VMs: Windows in Beacon, a Linux container on Forge.+ virt: match hw.id {+ "win-test" => Some("qemu".into()),+ "sandbox" => Some("docker".into()),+ _ => None,+ },+ published: demo_containers(hw.id),route: None,- kvm: false,+ kvm: hw.id == "beacon",}}@@ -739,19 +786,19 @@ impl World {vec!["claude", "opencode"],vec![session("opencode-c40d", "opencode", "OpenCode", "OpenCode · api", "/home/ci/api", true, 5, 0)],),- "pebble" | "dev-1" => (vec!["claude", "codex"], Vec::new()),+ "pebble" | "dev-1" | "sandbox" => (vec!["claude", "codex"], Vec::new()),+ "win-test" => (vec!["claude"], Vec::new()),_ => (Vec::new(), Vec::new()),};- let windows = hardware(machine_id).os == "windows";MachineSessions {checked_at: Some(now),- agent_version: (!windows).then(|| "0.1.0".into()),+ agent_version: Some("0.1.0".into()),agents: agents.into_iter().map(String::from).collect(),agents_checked_at: Some(now),- gh: (!windows).then(|| crate::fleet::model::GhCli { installed: true, logged_in: machine_id != "beacon", account: (machine_id != "beacon").then(|| "octocat".into()), path: None }),+ gh: Some(crate::fleet::model::GhCli { installed: true, logged_in: machine_id != "beacon", account: (machine_id != "beacon").then(|| "octocat".into()), path: None }),sessions,events: Vec::new(),- error: windows.then(|| "Sessions on Windows run while Muxen is open; they can't keep running in the background yet.".into()),+ error: None,}}diff --git a/src/fleet/schedules.rs b/src/fleet/schedules.rsindex 83bbc41..3258ba8 100644--- a/src/fleet/schedules.rs+++ b/src/fleet/schedules.rs@@ -168,7 +168,8 @@ impl Engine {.current().machines.iter()- .filter(|m| !m.host.is_empty() && m.status == "online")+ // Not offline or disconnected: one not checked yet (just after start) is asked too.+ .filter(|m| !m.host.is_empty() && !m.is_down()).filter(|m| machine_id.is_none_or(|id| m.id == id)).map(|m| (m.id.clone(), m.name.clone())).collect();@@ -238,13 +239,73 @@ impl Engine {async fn schedule_ctl(self: &Arc<Self>, machine_id: &str, request: Value) -> Result<Value, String> {let (spec, probe) = self.machine(machine_id).ok_or_else(|| format!("No machine called {machine_id}."))?;if self.demo_world().is_some() {- return Ok(json!({ "ok": true, "schedules": [], "scheduler": "cron", "runs": [], "output": "" }));+ return Ok(demo_reply(&spec.id, &request));}agent_cli::ensure(&spec, probe.as_ref()).await?;agent_cli::ctl(&spec, &request).await}}+/// The demo's schedules: tests every night on Beacon, Claude going through+/// new issues every weekday morning on Forge, and Vault's backups.+fn demo_reply(machine_id: &str, request: &Value) -> Value {+ let now = chrono::Utc::now().timestamp();+ let hours = |h: i64| now - h * 3600;+ let (scheduler, list): (&str, Value) = match machine_id {+ "beacon" => (+ "cron",+ json!([+ { "id": "s-n8t4qa", "name": "Nightly tests", "enabled": true, "when": { "every": "day", "at": "02:00" },+ "what": { "kind": "command", "command": "cd ~/api && make test", "cwd": "~/api" },+ "last_run": { "started": hours(8), "ok": true, "exit_code": 0, "seconds": 252 }, "running": false },+ { "id": "s-d1sk7r", "name": "Disk report", "enabled": true, "when": { "every": "hours", "n": 6, "at": "00:00" },+ "what": { "kind": "command", "command": "df -h / /data" },+ "last_run": { "started": hours(2), "ok": true, "exit_code": 0, "seconds": 1 }, "running": false },+ ]),+ ),+ "forge" => (+ "launchd",+ json!([+ { "id": "s-tr1age", "name": "Triage new issues", "enabled": true, "when": { "every": "weekdays", "at": "09:00" },+ "what": { "kind": "agent", "agent": "claude", "prompt": "Go through new issues in acme/api: label them, and reply to duplicates", "cwd": "~/code/api" },+ "last_run": { "started": hours(1), "ok": true, "session": "claude-tr1a51" }, "running": false },+ ]),+ ),+ "vault" => (+ "cron",+ json!([+ { "id": "s-bkup3x", "name": "Backups", "enabled": true, "when": { "every": "day", "at": "03:30" },+ "what": { "kind": "command", "command": "restic backup /srv/data --tag nightly" },+ "last_run": { "started": hours(7), "ok": false, "exit_code": 1, "seconds": 41 }, "running": false },+ ]),+ ),+ _ => ("cron", json!([])),+ };+ match request["op"].as_str().unwrap_or("") {+ "schedules" => json!({ "ok": true, "schedules": list, "scheduler": scheduler }),+ "schedule_log" => {+ let id = request["schedule_id"].as_str().unwrap_or("");+ let (runs, output): (Vec<Value>, &str) = match id {+ "s-n8t4qa" => (+ (0..6).map(|d| json!({ "started": hours(8 + 24 * d), "ok": d != 3, "exit_code": if d == 3 { 2 } else { 0 }, "seconds": 240 + d * 7 })).collect(),+ "go test ./...\nok acme/api/auth 2.114s\nok acme/api/billing 8.902s\nok acme/api/checkout 41.337s\nok acme/api/orders 12.508s\nok acme/api/search 3.776s\nPASS: 412 tests in 4m12s\n",+ ),+ "s-d1sk7r" => (+ (0..6).map(|d| json!({ "started": hours(2 + 6 * d), "ok": true, "exit_code": 0, "seconds": 1 })).collect(),+ "Filesystem Size Used Avail Use% Mounted on\n/dev/nvme0n1p2 1.8T 190G 1.6T 11% /\n/dev/sda1 7.3T 4.1T 3.2T 57% /data\n",+ ),+ "s-tr1age" => ((0..5).map(|d| json!({ "started": hours(1 + 24 * d), "ok": true, "session": format!("claude-tr1a{}", 51 - d) })).collect(), ""),+ _ => (+ (0..5).map(|d| json!({ "started": hours(7 + 24 * d), "ok": d != 0, "exit_code": if d == 0 { 1 } else { 0 }, "seconds": 41 + d * 300 })).collect(),+ "repository 6f1c2b8e opened (version 2)\nusing parent snapshot 4a9d0e21\nFatal: unable to save snapshot: Save(<data/7a3f1c2e>): no space left on device\n",+ ),+ };+ json!({ "ok": true, "runs": runs.clone(), "run": runs.first(), "output": output })+ }+ _ => json!({ "ok": true }),+ }+}+#[cfg(test)]mod tests {use super::*;diff --git a/src/mcp.rs b/src/mcp.rsindex efba3c5..724bd1e 100644--- a/src/mcp.rs+++ b/src/mcp.rs@@ -1314,7 +1314,7 @@ mod tests {send(json!({"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"status","arguments":{}}})).await;let status: Value = recv().await;assert_eq!(status["result"]["isError"], false);- assert_eq!(status["result"]["structuredContent"]["counts"]["machines"], 7);+ assert_eq!(status["result"]["structuredContent"]["counts"]["machines"], 9);assert!(status["result"]["content"][0]["text"].as_str().unwrap().contains("\"summary\""));// Tool failures are results with isError, carrying a code an agent can branch on.diff --git a/src/ui/dialogs.rs b/src/ui/dialogs.rsindex bb09213..640d451 100644--- a/src/ui/dialogs.rs+++ b/src/ui/dialogs.rs@@ -129,6 +129,10 @@ impl AddMachineDialog {cx.spawn(async move |this, cx| {if let Ok(found) = job.await {let _ = this.update(cx, |this, cx| {+ // The demo's own aliases, not this computer's.+ if this.engine.demo_world().is_some() {+ this.hosts = found.hosts.clone();+ }this.tailnet = found.tailnet.into_iter().filter(|t| t.machine_id.is_none()).collect();this.network = Some(found.network);cx.notify();@@ -136,7 +140,8 @@ impl AddMachineDialog {}}).detach();- AddMachineDialog { engine, name, host, hosts: ssh_hosts(), tailnet: Vec::new(), network: None, note: None, error: None, _subscriptions: subs }+ let hosts = if engine.demo_world().is_some() { Vec::new() } else { ssh_hosts() };+ AddMachineDialog { engine, name, host, hosts, tailnet: Vec::new(), network: None, note: None, error: None, _subscriptions: subs }}pub fn first_focus(&self, cx: &App) -> FocusHandle {diff --git a/src/ui/root.rs b/src/ui/root.rsindex be1efc1..ff92a26 100644--- a/src/ui/root.rs+++ b/src/ui/root.rs@@ -700,7 +700,14 @@ impl Root {match kind {"jobs" => self.navigate(Route::Jobs, window, cx),"usage" => self.navigate(Route::Usage, window, cx),- "schedules" => self.navigate(Route::Schedules, window, cx),+ // "schedules", or "schedules:<machine>/<id>" with that one's runs open.+ "schedules" => {+ self.navigate(Route::Schedules, window, cx);+ if let Some((m, id)) = arg.split_once('/') {+ self.schedule_open = Some((m.to_string(), id.to_string()));+ self.open_schedule_log(m, id, cx);+ }+ }// "schedule" or "schedule:<machine>": the New schedule dialog."schedule" => self.show_schedule_dialog((!arg.is_empty()).then(|| arg.to_string()), window, cx),"run-big" => self.run_expanded = Some(arg.to_string()),diff --git a/src/ui/schedules.rs b/src/ui/schedules.rsindex 4b951d0..0b39460 100644--- a/src/ui/schedules.rs+++ b/src/ui/schedules.rs@@ -40,6 +40,11 @@ impl Root {cx.notify();}+ /// Shows a schedule's runs (for `--view schedules:<machine>/<id>`).+ pub(super) fn open_schedule_log(&mut self, machine: &str, id: &str, cx: &mut Context<Self>) {+ self.load_schedule_log(machine, id, None, cx);+ }+/// A schedule's runs and one's output.fn load_schedule_log(&mut self, machine: &str, id: &str, started: Option<i64>, cx: &mut Context<Self>) {let key = (machine.to_string(), id.to_string());diff --git a/src/ui/vm_dialog.rs b/src/ui/vm_dialog.rsindex 3323ab9..58d5ec6 100644--- a/src/ui/vm_dialog.rs+++ b/src/ui/vm_dialog.rs@@ -32,9 +32,14 @@ impl EventEmitter<DialogEvent> for VmDialog {}impl VmDialog {/// `host`: the machine to put it on (opened from its page), else the best one.pub fn new(engine: Arc<Engine>, host: Option<String>, window: &mut Window, cx: &mut Context<Self>) -> Self {+ // "beacon@windows-11": that machine, with that system chosen.+ let (host, system) = match host.as_deref().and_then(|h| h.split_once('@')) {+ Some((h, s)) => (Some(h.to_string()), Some(s.to_string())),+ None => (host, None),+ };let options = engine.vm_options();// Windows where some machine can run it, else Linux.- let system = if options.hosts.iter().any(|h| h.systems.iter().any(|s| s == "windows-11")) { "windows-11" } else { "ubuntu-24.04" }.to_string();+ let system = system.filter(|s| crate::ops::vm::system(s).is_some()).unwrap_or_else(|| if options.hosts.iter().any(|h| h.systems.iter().any(|s| s == "windows-11")) { "windows-11" } else { "ubuntu-24.04" }.to_string());let name = cx.new(|cx| TextInput::new(cx, "win-dev").with_text(free_name(&engine, &system)));let subs = vec![cx.subscribe_in(&name, window, |this: &mut Self, _, e: &InputEvent, _, cx| match e {InputEvent::Submit => this.submit(cx),@@ -125,6 +130,9 @@ impl Focusable for VmDialog {impl Render for VmDialog {fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {let theme = cx.theme();+ // What the machines can run arrives with their checks (just after start, say).+ self.options = self.engine.vm_options();+ self.pick_host();let cancel = Button::new("vm-cancel", "Cancel").style(ButtonStyle::Ghost).on_click(cx.listener(|_, _, _, cx| cx.emit(DialogEvent::Dismissed))).into_any_element();let chip = |id: SharedString, text: String, selected: bool, enabled: bool| {div()