From 2e88bf33ba1159c6e6cfafca47365752d25a9845 Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Tue, 4 Nov 2025 17:09:11 +0100 Subject: [PATCH] Update OsirisClient to use unified JobBuilder for both native and WASM - Use hero_supervisor_openrpc_client::JobBuilder for both native and WASM builds - Simplified execute_script method by removing duplicate job building code - JobBuilder now works consistently across platforms - Removed separate WasmJobBuilder usage --- client/src/lib.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index a8209a5..2f1da48 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -211,20 +211,26 @@ impl OsirisClient { let secret = self.supervisor_secret.as_ref() .ok_or_else(|| OsirisClientError::ConfigError("supervisor_secret not configured for commands".to_string()))?; - // Use supervisor client for native builds + // Use unified JobBuilder for both native and WASM + use hero_supervisor_openrpc_client::JobBuilder; + + let job = JobBuilder::new() + .caller_id("osiris-client") + .context_id("command-execution") + .payload(script) + .runner(&self.runner_name) + .executor("rhai") + .timeout(self.timeout) + .build() + .map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?; + #[cfg(not(target_arch = "wasm32"))] { - use hero_supervisor_openrpc_client::{SupervisorClient, JobBuilder}; + use hero_supervisor_openrpc_client::SupervisorClient; let supervisor_client = SupervisorClient::new(supervisor_url) .map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?; - let job = JobBuilder::new() - .runner_name(&self.runner_name) - .script(script) - .timeout(self.timeout) - .build(); - let result = supervisor_client.run_job(secret, job) .await .map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?; @@ -243,19 +249,12 @@ impl OsirisClient { } } - // Use WASM client for browser builds #[cfg(target_arch = "wasm32")] { - use hero_supervisor_openrpc_client::wasm::{WasmSupervisorClient, WasmJobBuilder}; + use hero_supervisor_openrpc_client::wasm::WasmSupervisorClient; let supervisor_client = WasmSupervisorClient::new(supervisor_url.clone()); - let job = WasmJobBuilder::new() - .runner_name(&self.runner_name) - .script(script) - .timeout(self.timeout as i32) - .build(); - let result_str = supervisor_client.run_job(secret.clone(), job) .await .map_err(|e| OsirisClientError::CommandFailed(format!("{:?}", e)))?;