@steerable/agent-shell-tauri 0.6.43 → 0.6.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/host.rs +35 -2
- package/src/host_tests.rs +27 -0
package/package.json
CHANGED
package/src/host.rs
CHANGED
|
@@ -5,7 +5,7 @@ use command_group::{Signal, UnixChildExt};
|
|
|
5
5
|
use serde::Deserialize;
|
|
6
6
|
use std::env;
|
|
7
7
|
use std::io::{BufRead, BufReader};
|
|
8
|
-
use std::path::PathBuf;
|
|
8
|
+
use std::path::{Path, PathBuf};
|
|
9
9
|
use std::process::{Command, Stdio};
|
|
10
10
|
use std::sync::mpsc;
|
|
11
11
|
use std::sync::Mutex;
|
|
@@ -224,12 +224,20 @@ impl HostPaths {
|
|
|
224
224
|
.path()
|
|
225
225
|
.resource_dir()
|
|
226
226
|
.map_err(|error| error.to_string())?;
|
|
227
|
+
let resource_dir = node_compatible_path(&resource_dir);
|
|
227
228
|
let host_root = resource_dir.join("node-host");
|
|
228
229
|
let app_root = host_root.join("app-dist");
|
|
230
|
+
let engine_node = resource_dir.join("engine").join(platform_binary("node"));
|
|
229
231
|
Ok(Self {
|
|
230
232
|
node: env::var_os("DEEPPATH_TAURI_NODE")
|
|
231
233
|
.map(PathBuf::from)
|
|
232
|
-
.unwrap_or_else(||
|
|
234
|
+
.unwrap_or_else(|| {
|
|
235
|
+
if engine_node.exists() {
|
|
236
|
+
engine_node
|
|
237
|
+
} else {
|
|
238
|
+
resource_dir.join(node_resource_name())
|
|
239
|
+
}
|
|
240
|
+
}),
|
|
233
241
|
server_entry: app_root
|
|
234
242
|
.join("products")
|
|
235
243
|
.join(&config.product_id)
|
|
@@ -271,6 +279,27 @@ fn node_resource_name() -> &'static str {
|
|
|
271
279
|
}
|
|
272
280
|
}
|
|
273
281
|
|
|
282
|
+
fn node_compatible_path(path: &Path) -> PathBuf {
|
|
283
|
+
#[cfg(windows)]
|
|
284
|
+
{
|
|
285
|
+
use std::ffi::OsString;
|
|
286
|
+
use std::os::windows::ffi::{OsStrExt, OsStringExt};
|
|
287
|
+
|
|
288
|
+
let wide = path.as_os_str().encode_wide().collect::<Vec<_>>();
|
|
289
|
+
let verbatim_unc = r"\\?\UNC\".encode_utf16().collect::<Vec<_>>();
|
|
290
|
+
if let Some(rest) = wide.strip_prefix(verbatim_unc.as_slice()) {
|
|
291
|
+
let mut normalized = r"\\".encode_utf16().collect::<Vec<_>>();
|
|
292
|
+
normalized.extend_from_slice(rest);
|
|
293
|
+
return PathBuf::from(OsString::from_wide(&normalized));
|
|
294
|
+
}
|
|
295
|
+
let verbatim = r"\\?\".encode_utf16().collect::<Vec<_>>();
|
|
296
|
+
if let Some(rest) = wide.strip_prefix(verbatim.as_slice()) {
|
|
297
|
+
return PathBuf::from(OsString::from_wide(rest));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
path.to_path_buf()
|
|
301
|
+
}
|
|
302
|
+
|
|
274
303
|
fn spawn_group(command: &mut Command) -> std::io::Result<GroupChild> {
|
|
275
304
|
#[cfg(windows)]
|
|
276
305
|
{
|
|
@@ -281,3 +310,7 @@ fn spawn_group(command: &mut Command) -> std::io::Result<GroupChild> {
|
|
|
281
310
|
command.group_spawn()
|
|
282
311
|
}
|
|
283
312
|
}
|
|
313
|
+
|
|
314
|
+
#[cfg(test)]
|
|
315
|
+
#[path = "host_tests.rs"]
|
|
316
|
+
mod tests;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
use super::node_compatible_path;
|
|
2
|
+
use std::path::Path;
|
|
3
|
+
|
|
4
|
+
#[cfg(not(windows))]
|
|
5
|
+
#[test]
|
|
6
|
+
fn packaged_path_is_unchanged_off_windows() {
|
|
7
|
+
let path = Path::new("/opt/Aroli/node-host");
|
|
8
|
+
assert_eq!(node_compatible_path(path), path);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#[cfg(windows)]
|
|
12
|
+
#[test]
|
|
13
|
+
fn strips_windows_verbatim_disk_prefix() {
|
|
14
|
+
assert_eq!(
|
|
15
|
+
node_compatible_path(Path::new(r"\\?\C:\Aroli\node-host")),
|
|
16
|
+
Path::new(r"C:\Aroli\node-host")
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[cfg(windows)]
|
|
21
|
+
#[test]
|
|
22
|
+
fn converts_windows_verbatim_unc_prefix() {
|
|
23
|
+
assert_eq!(
|
|
24
|
+
node_compatible_path(Path::new(r"\\?\UNC\server\share\node-host")),
|
|
25
|
+
Path::new(r"\\server\share\node-host")
|
|
26
|
+
);
|
|
27
|
+
}
|