Skip to content

Commit 718d53d

Browse files
feat(Handler/proxy): Add initial Cocoon RPC proxy handler
- Introduces `proxy` module in Mountain's handler layer to mediate between Sky frontend and Cocoon extension host - Implements `handle_ext_host_proxy` using Vine IPC to forward API calls to Cocoon sidecar process - Provides basic argument handling and error wrapping for IPC communication - Temporary process ID placeholder establishes pattern for future multi-instance extension host support This foundational handler enables routing extension-related commands from Sky's VS Code-compatible UI through Mountain to the Cocoon shim layer, critical for Path A extension compatibility. The implementation leverages Land's Vine IPC layer while highlighting areas for future hardening (target process selection, payload validation).
1 parent 5d9c57f commit 718d53d

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

Source/Library.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ pub mod handlers {
3030
pub mod process_mgmt;
3131

3232
pub mod protocol;
33+
34+
pub mod proxy;
3335
}

Source/handlers/proxy.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
use serde_json::{json, Value};
1+
use serde_json::{Value, json};
22
use tauri::{AppHandle, Runtime, Window};
3-
use crate::vine; // Use the Vine IPC layer
43

5-
pub async fn handle_ext_host_proxy<R: Runtime>(
6-
_app: AppHandle<R>,
7-
_window: Window<R>,
8-
args: Vec<Value>,
4+
// Use the Vine IPC layer
5+
use crate::vine;
6+
7+
pub async fn handle_ext_host_proxy<R:Runtime>(
8+
_app:AppHandle<R>,
9+
_window:Window<R>,
10+
args:Vec<Value>,
911
) -> Result<Value, String> {
10-
println!("[Proxy Handler] Proxying call to Cocoon: {:?}", args);
11-
// TODO: Identify target Cocoon process instance
12-
let target_process_id = 1234; // Placeholder
12+
println!("[Proxy Handler] Proxying call to Cocoon: {:?}", args);
13+
14+
// TODO: Identify target Cocoon process instance
15+
// Placeholder
16+
let target_process_id = 1234;
1317

14-
// TODO: Robust arg handling - expect specific structure for API call
15-
let request_payload = args.get(0).cloned().unwrap_or(json!(null));
18+
// TODO: Robust arg handling - expect specific structure for API call
19+
let request_payload = args.get(0).cloned().unwrap_or(json!(null));
1620

17-
// Use Vine to send the request and await response
18-
match vine::send_to_sidecar(target_process_id, request_payload).await {
19-
Ok(response) => Ok(response),
20-
Err(e) => Err(format!("Cocoon IPC Error: {}", e)),
21-
}
21+
// Use Vine to send the request and await response
22+
match vine::send_to_sidecar(target_process_id, request_payload).await {
23+
Ok(response) => Ok(response),
24+
Err(e) => Err(format!("Cocoon IPC Error: {}", e)),
25+
}
2226
}

0 commit comments

Comments
 (0)