Files
agcanvas/crates/agcanvas-mcp/src/bridge.rs
David Ibia 9489c390fa feat: add boolean shape ops, visual undo tree, and Augmented Canvas branding
- Boolean operations (union, intersection, difference, xor) via i_overlay
  with Path shape rendering using earcutr triangulation
- Visual undo tree with branching history, checkout, and fork (Cmd+H)
  using Arc-based snapshots for structural sharing
- Consistent Augmented Canvas branding across app title, MCP server,
  CLI help text, and error messages
- macOS .app bundle script and Info.plist for Finder integration
- New MCP tool: boolean_op for agent-driven shape composition
- 26 tests passing (5 boolean, 6 history, 15 existing)
2026-02-10 00:01:45 +01:00

30 lines
1020 B
Rust

use anyhow::Result;
use futures_util::{SinkExt, StreamExt};
use tokio_tungstenite::tungstenite::Message;
pub async fn send_request(ws_url: &str, request_json: &str) -> Result<String> {
let (ws_stream, _) = tokio_tungstenite::connect_async(ws_url)
.await
.map_err(|e| {
anyhow::anyhow!(
"Cannot connect to Augmented Canvas at {}. Is Augmented Canvas running? Error: {}",
ws_url,
e
)
})?;
let (mut write, mut read) = ws_stream.split();
// Skip the initial Connected event
let _connected = read.next().await;
write.send(Message::Text(request_json.to_string())).await?;
match read.next().await {
Some(Ok(Message::Text(response))) => Ok(response),
Some(Ok(other)) => Err(anyhow::anyhow!("Unexpected message type: {:?}", other)),
Some(Err(e)) => Err(anyhow::anyhow!("WebSocket error: {}", e)),
None => Err(anyhow::anyhow!("Connection closed before response")),
}
}