Compare commits

..

3 Commits

Author SHA1 Message Date
Timur Gordon
d3c2966f10 Remove non-existent feature from hero-supervisor-openrpc-client dependency 2025-11-06 13:47:25 +01:00
Timur Gordon
4c62894c08 update deps 2025-11-06 13:43:55 +01:00
Timur Gordon
2e88bf33ba 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
2025-11-04 17:09:11 +01:00
2 changed files with 16 additions and 17 deletions

View File

@@ -10,7 +10,7 @@ reqwest = { version = "0.12", default-features = false, features = ["json"] }
anyhow = "1.0" anyhow = "1.0"
thiserror = "1.0" thiserror = "1.0"
chrono = "0.4" chrono = "0.4"
hero-supervisor-openrpc-client = { path = "../../supervisor/clients/openrpc" } hero-supervisor-openrpc-client = { git = "https://git.ourworld.tf/herocode/supervisor.git" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
uuid = { version = "1.0", features = ["v4"] } uuid = { version = "1.0", features = ["v4"] }

View File

@@ -211,20 +211,26 @@ impl OsirisClient {
let secret = self.supervisor_secret.as_ref() let secret = self.supervisor_secret.as_ref()
.ok_or_else(|| OsirisClientError::ConfigError("supervisor_secret not configured for commands".to_string()))?; .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"))] #[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) let supervisor_client = SupervisorClient::new(supervisor_url)
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?; .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) let result = supervisor_client.run_job(secret, job)
.await .await
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?; .map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?;
@@ -243,19 +249,12 @@ impl OsirisClient {
} }
} }
// Use WASM client for browser builds
#[cfg(target_arch = "wasm32")] #[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 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) let result_str = supervisor_client.run_job(secret.clone(), job)
.await .await
.map_err(|e| OsirisClientError::CommandFailed(format!("{:?}", e)))?; .map_err(|e| OsirisClientError::CommandFailed(format!("{:?}", e)))?;