Skip to content

Commit 8cbe329

Browse files
committed
feat(gpui): run remote workspace sessions through the Kubernetes provider
The new buzz-sandbox-host crate is a SandboxBackend that starts, ends and recovers an agent's thread session with buzz-remote-sessions, as the desktop does. Each request reads the agent's key before the per-agent lock; the payload is rebuilt under the lock from the key cache only, so a deleted agent never launches and no wait happens under the lock. The host fills in the agent's community, nsec, attestation and owner from custody. A provider config that names them or the identity policy is refused, and the reserved environment keys are stripped from every environment the GUI sends. Provider refusals come back as Failed with their code. Providers are found beside the executable, then on PATH and in ~/.local/bin, and run in <state_dir>/sandbox. The embedded host and buzzd use it only with the voltage-sandbox feature, which is off by default, so upstream builds are unchanged. The flake's source is now the repository root, keeping only this workspace and crates/buzz-remote-sessions, and the builds run from apps/buzz-gpui: Cargo reads every member's manifest, including optional path dependencies, so the Nix packages failed without the crate. Signed-off-by: Tee8z <[email protected]>
1 parent 3ffc220 commit 8cbe329

9 files changed

Lines changed: 826 additions & 5 deletions

File tree

‎apps/buzz-gpui/Cargo.lock‎

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/buzz-gpui/crates/app/Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ buzz-host-rpc = { path = "../host-rpc" }
2424
buzz-identity = { path = "../identity" }
2525
buzz-pair-mobile = { path = "../pair-mobile" }
2626
buzz-relay-client = { path = "../relay" }
27+
buzz-sandbox-host = { path = "../sandbox-host", optional = true }
2728
serde_json = "1"
2829
buzz-ui = { path = "../ui" }
2930
buzzodz-plugins.workspace = true
@@ -73,6 +74,10 @@ tracing = "0.1"
7374
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
7475
url = "2"
7576

77+
[features]
78+
# Remote workspaces on Voltage's Kubernetes provider; off for upstream builds.
79+
voltage-sandbox = ["dep:buzz-sandbox-host"]
80+
7681
[dev-dependencies]
7782
# Paused time for timing tests.
7883
tokio = { version = "1", features = ["test-util"] }

‎apps/buzz-gpui/crates/app/src/hosts.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn start_embedded(
208208
state_dir: data.join("host"),
209209
credentials,
210210
legacy_dir: dirs::data_dir(),
211-
sandbox: None,
211+
sandbox: sandbox(&data.join("host")),
212212
})?;
213213
let (connector, listener) = transport::memory();
214214
let server = runtime.spawn(buzz_host_rpc::serve(
@@ -220,6 +220,17 @@ fn start_embedded(
220220
Ok((connector, (server, host)))
221221
}
222222

223+
/// Remote workspaces, in builds with them.
224+
fn sandbox(state_dir: &std::path::Path) -> Option<Arc<dyn buzz_host::sandbox::SandboxBackend>> {
225+
#[cfg(feature = "voltage-sandbox")]
226+
return Some(Arc::new(buzz_sandbox_host::Sandboxes::new(state_dir)));
227+
#[cfg(not(feature = "voltage-sandbox"))]
228+
{
229+
let _ = state_dir;
230+
None
231+
}
232+
}
233+
223234
fn remote_connector(host: &RemoteHost) -> Result<Arc<dyn Connector>, String> {
224235
if let Some(address) = host.address.strip_prefix("tcp://")
225236
&& !address.is_empty()

‎apps/buzz-gpui/crates/buzzd/Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ anyhow.workspace = true
1111
buzz-host = { path = "../host" }
1212
buzz-host-rpc = { path = "../host-rpc" }
1313
buzz-keychain = { path = "../keychain" }
14+
buzz-sandbox-host = { path = "../sandbox-host", optional = true }
1415
clap = { version = "4", features = ["derive"] }
1516
dirs = "6"
1617
getrandom = "0.3"
@@ -21,6 +22,10 @@ tracing = "0.1"
2122
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
2223
uuid = { version = "1", features = ["v4"] }
2324

25+
[features]
26+
# Remote workspaces on Voltage's Kubernetes provider; off for upstream builds.
27+
voltage-sandbox = ["dep:buzz-sandbox-host"]
28+
2429
[target.'cfg(not(target_os = "linux"))'.dependencies]
2530
# The host name where there is no /etc/hostname.
2631
gethostname = "1"

‎apps/buzz-gpui/crates/buzzd/src/main.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async fn run(config: Config, state_dir: PathBuf, token: String) -> Result<()> {
100100
state_dir: state_dir.clone(),
101101
credentials,
102102
legacy_dir: dirs::data_dir(),
103-
sandbox: None,
103+
sandbox: sandbox(&state_dir),
104104
})
105105
.map_err(anyhow::Error::msg)?;
106106
let handler = Arc::new(RpcHandler(host));
@@ -153,6 +153,17 @@ async fn run(config: Config, state_dir: PathBuf, token: String) -> Result<()> {
153153
Ok(())
154154
}
155155

156+
/// Remote workspaces, in builds with them.
157+
fn sandbox(state_dir: &Path) -> Option<Arc<dyn buzz_host::sandbox::SandboxBackend>> {
158+
#[cfg(feature = "voltage-sandbox")]
159+
return Some(Arc::new(buzz_sandbox_host::Sandboxes::new(state_dir)));
160+
#[cfg(not(feature = "voltage-sandbox"))]
161+
{
162+
let _ = state_dir;
163+
None
164+
}
165+
}
166+
156167
fn load_config(path: &Path) -> Result<Config> {
157168
match std::fs::read_to_string(path) {
158169
Ok(text) => toml::from_str(&text).with_context(|| format!("invalid {}", path.display())),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "buzz-sandbox-host"
3+
description = "Remote workspaces for a Buzz agent host, run through buzz-backend-* providers"
4+
version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
publish.workspace = true
8+
9+
[dependencies]
10+
buzz-host = { path = "../host" }
11+
# Shared with buzz-app's desktop, which drives the same providers.
12+
buzz-remote-sessions = { path = "../../../../crates/buzz-remote-sessions" }
13+
futures = "0.3"
14+
serde_json = "1"
15+
tokio = { version = "1", features = ["rt"] }
16+
uuid = "1"
17+
18+
[dev-dependencies]
19+
buzz-host-rpc = { path = "../host-rpc" }
20+
buzz-identity = { path = "../identity" }
21+
tempfile = "3"
22+
tokio = { version = "1", features = ["full"] }

0 commit comments

Comments
 (0)