Compare commits
3 Commits
5d82959457
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3c2966f10 | ||
|
|
4c62894c08 | ||
|
|
2e88bf33ba |
@@ -10,7 +10,7 @@ reqwest = { version = "0.12", default-features = false, features = ["json"] }
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
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]
|
||||
uuid = { version = "1.0", features = ["v4"] }
|
||||
|
||||
@@ -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)))?;
|
||||
|
||||
Reference in New Issue
Block a user