async fn LaunchAndManageCocoonSideCar(
ApplicationHandle: AppHandle,
Environment: Arc<MountainEnvironment>,
) -> Result<(), CommonError>Expand description
Spawns the Cocoon process, manages its communication channels, and performs the complete initialization handshake sequence.
This function implements the complete Cocoon lifecycle:
- Validates bootstrap script availability
- Constructs environment variables for IPC and logging
- Spawns Node.js process with proper IO redirection
- Captures stdout/stderr for logging
- Waits for gRPC server to be ready
- Establishes Vine connection
- Sends initialization payload and validates response
§Arguments
ApplicationHandle- Tauri application handle for resolving resource pathsEnvironment- Mountain environment containing application state
§Returns
Ok(())- Cocoon process spawned, connected, and initialized successfullyErr(CommonError)- Any failure during the initialization sequence
§Errors
FileSystemNotFound: Bootstrap script not found in resourcesIPCError: Failed to spawn process, connect gRPC, or complete handshake
§Lifecycle
The process runs as a background task with IO redirection for logging. Process failures are logged but not automatically restarted (callers should implement restart strategies based on their requirements).