Skip to content

Commit 903c119

Browse files
committed
fix: build fixes for WASM language runtime + LanguageBackend trait
- Fix schema.gql symlink (core/lib/src -> tests/js) - Fix AgentContext/did_for_context/sign_for_context -> agent::did()/sign() - Fix create_signed_expression to use 1-arg API - Remove conflicting From<WasmLanguageError> impl (blanket covers it) - Fix perspective_instance to use Box<dyn LanguageBackend> in Arc<Mutex<>> - Add set_app_data_path to perspectives/mod.rs (merge gap) - Forward wasm-languages feature through cli/Cargo.toml
1 parent 24a819c commit 903c119

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ path = "src/ad4m_executor.rs"
2525
# Pass metal and cuda features through to ad4m-executor
2626
metal = ["ad4m-executor/metal"]
2727
cuda = ["ad4m-executor/cuda"]
28+
wasm-languages = ["ad4m-executor/wasm-languages"]
2829

2930
[dependencies]
3031
ad4m-client = { path = "../rust-client", version="0.11.1" }

rust-client/schema.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../core/lib/src/schema.gql
1+
../tests/js/schema.gql

rust-executor/src/perspectives/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,16 @@ mod tests {
486486

487487
// Additional tests for other functions can be added here
488488
}
489+
490+
lazy_static! {
491+
static ref APP_DATA_PATH: std::sync::RwLock<Option<String>> = std::sync::RwLock::new(None);
492+
}
493+
494+
pub fn set_app_data_path(path: String) {
495+
let mut data_path = APP_DATA_PATH.write().unwrap();
496+
*data_path = Some(path);
497+
}
498+
499+
fn get_app_data_path() -> Option<String> {
500+
APP_DATA_PATH.read().unwrap().clone()
501+
}

rust-executor/src/perspectives/perspective_instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub struct PerspectiveInstance {
177177
is_teardown: Arc<Mutex<bool>>,
178178
sdna_change_mutex: Arc<Mutex<()>>,
179179
prolog_update_mutex: Arc<RwLock<()>>,
180-
link_language: Arc<RwLock<Option<Arc<Mutex<dyn LanguageBackend>>>>>,
180+
link_language: Arc<RwLock<Option<Arc<Mutex<Box<dyn LanguageBackend>>>>>>,
181181
trigger_notification_check: Arc<Mutex<bool>>,
182182
trigger_prolog_subscription_check: Arc<Mutex<bool>>,
183183
trigger_surreal_subscription_check: Arc<Mutex<bool>>,

rust-executor/src/wasm_core/error.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,4 @@ impl From<std::string::FromUtf8Error> for WasmLanguageError {
128128
}
129129
}
130130

131-
impl From<WasmLanguageError> for deno_core::error::AnyError {
132-
fn from(err: WasmLanguageError) -> Self {
133-
deno_core::anyhow::anyhow!("{}", err)
134-
}
135-
}
131+
// From<WasmLanguageError> for AnyError covered by blanket impl

rust-executor/src/wasm_core/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn alloc_and_write(
105105
/// Returns the agent's DID as a JSON string.
106106
fn host_agent_did(mut env: FunctionEnvMut<HostEnv>) -> u64 {
107107
let (host_env, mut store) = env.data_and_store_mut();
108-
match crate::agent::did_for_context(&crate::agent::AgentContext::main_agent()) {
108+
match Ok::<_, deno_core::error::AnyError>(crate::agent::did()) {
109109
Ok(did) => {
110110
let json = match serde_json::to_vec(&did) {
111111
Ok(j) => j,
@@ -148,7 +148,7 @@ fn host_agent_sign(mut env: FunctionEnvMut<HostEnv>, data_ptr: u32, data_len: u3
148148
return 0;
149149
}
150150
};
151-
match crate::agent::sign_for_context(&data, &crate::agent::AgentContext::main_agent()) {
151+
match crate::agent::sign(&data) {
152152
Ok(signature) => {
153153
let json = match serde_json::to_vec(&signature) {
154154
Ok(j) => j,
@@ -248,7 +248,7 @@ fn host_agent_create_signed_expression(
248248
}
249249
};
250250
let sorted = crate::js_core::utils::sort_json_value(&content);
251-
match crate::agent::create_signed_expression(sorted, &crate::agent::AgentContext::main_agent()) {
251+
match crate::agent::create_signed_expression(sorted) {
252252
Ok(expr) => {
253253
let json = match serde_json::to_vec(&expr) {
254254
Ok(j) => j,

0 commit comments

Comments
 (0)