@steerable/agent-shell-tauri 0.6.56 → 0.6.57

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/host.rs +92 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerable/agent-shell-tauri",
3
- "version": "0.6.56",
3
+ "version": "0.6.57",
4
4
  "description": "Reusable Tauri Rust host source for @steerable/agent-shell",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://steerableframework.com/",
package/src/host.rs CHANGED
@@ -53,6 +53,7 @@ fn format_host_exit(reason: &str, recent: &Mutex<Vec<String>>) -> String {
53
53
  .find(|line| {
54
54
  line.contains("failed to start")
55
55
  || line.contains("StoreAlreadyOwnedError")
56
+ || line.contains("storage upgrade blocked")
56
57
  || line.contains("web build not found")
57
58
  })
58
59
  .cloned()
@@ -145,7 +146,12 @@ impl HostProcess {
145
146
  .stdin(Stdio::null())
146
147
  .stdout(Stdio::piped())
147
148
  .stderr(Stdio::piped());
148
- paths.apply_runtime_env(&mut command, python_runner.ok().flatten());
149
+ let python_path = python_runner
150
+ .as_ref()
151
+ .ok()
152
+ .and_then(|runner| runner.as_deref())
153
+ .map(Path::to_path_buf);
154
+ paths.apply_runtime_env(&mut command, python_path.clone());
149
155
 
150
156
  let mut child = spawn_group(&mut command).map_err(|error| {
151
157
  format!(
@@ -239,6 +245,16 @@ impl HostProcess {
239
245
  "host-ready.json",
240
246
  &serde_json::to_string(&ready).map_err(|error| error.to_string())?,
241
247
  );
248
+ write_diag(
249
+ &user_data,
250
+ "host-runtime.json",
251
+ &host_runtime_document(
252
+ &paths.web_dist,
253
+ paths.sidecar_python.as_deref(),
254
+ python_path.as_deref(),
255
+ paths.engine_dir.as_deref(),
256
+ ),
257
+ );
242
258
  let url = Url::parse(&format!("http://{}:{}/", ready.host, ready.port))
243
259
  .map_err(|error| error.to_string())?;
244
260
  Ok((
@@ -475,6 +491,49 @@ impl HostPaths {
475
491
  }
476
492
  }
477
493
 
494
+ fn host_runtime_document(
495
+ web_dist: &Path,
496
+ sidecar_python: Option<&Path>,
497
+ python: Option<&Path>,
498
+ engine_dir: Option<&Path>,
499
+ ) -> String {
500
+ let mut doc = serde_json::Map::new();
501
+ doc.insert(
502
+ "webDist".to_string(),
503
+ serde_json::Value::String(web_dist.display().to_string()),
504
+ );
505
+ if let Some(path) = sidecar_python.filter(|path| path.is_file()) {
506
+ doc.insert(
507
+ "sidecarPython".to_string(),
508
+ serde_json::Value::String(path.display().to_string()),
509
+ );
510
+ }
511
+ if let Some(path) = python.filter(|path| path.is_file()) {
512
+ doc.insert(
513
+ "python".to_string(),
514
+ serde_json::Value::String(path.display().to_string()),
515
+ );
516
+ }
517
+ if let Some(engine_dir) = engine_dir {
518
+ let egress = engine_dir.join(platform_binary("steerable-egress-proxy"));
519
+ if egress.is_file() {
520
+ doc.insert(
521
+ "egressProxyBin".to_string(),
522
+ serde_json::Value::String(egress.display().to_string()),
523
+ );
524
+ }
525
+ let helper = engine_dir.join("win-spawn-helper/win-spawn-helper.exe");
526
+ if helper.is_file() {
527
+ doc.insert(
528
+ "winSpawnHelper".to_string(),
529
+ serde_json::Value::String(helper.display().to_string()),
530
+ );
531
+ }
532
+ }
533
+ serde_json::to_string_pretty(&serde_json::Value::Object(doc))
534
+ .unwrap_or_else(|_| "{}".to_string())
535
+ }
536
+
478
537
  fn platform_binary(name: &str) -> String {
479
538
  if cfg!(windows) {
480
539
  format!("{name}.exe")
@@ -536,3 +595,35 @@ fn spawn_group(command: &mut Command) -> std::io::Result<GroupChild> {
536
595
  command.group_spawn()
537
596
  }
538
597
  }
598
+
599
+ #[cfg(test)]
600
+ mod tests {
601
+ use super::host_runtime_document;
602
+
603
+ #[test]
604
+ fn host_runtime_document_records_files_that_exist() {
605
+ let dir = std::env::temp_dir().join(format!(
606
+ "host-runtime-doc-{}-{}",
607
+ std::process::id(),
608
+ std::time::SystemTime::now()
609
+ .duration_since(std::time::UNIX_EPOCH)
610
+ .expect("clock")
611
+ .as_nanos()
612
+ ));
613
+ std::fs::create_dir_all(&dir).unwrap();
614
+ let python = dir.join("python");
615
+ std::fs::write(&python, "").unwrap();
616
+ let missing = dir.join("missing-python");
617
+ let json = host_runtime_document(
618
+ &dir.join("web"),
619
+ Some(python.as_path()),
620
+ Some(missing.as_path()),
621
+ None,
622
+ );
623
+ let value: serde_json::Value = serde_json::from_str(&json).unwrap();
624
+ assert_eq!(value["webDist"], dir.join("web").display().to_string());
625
+ assert_eq!(value["sidecarPython"], python.display().to_string());
626
+ assert!(value.get("python").is_none());
627
+ let _ = std::fs::remove_dir_all(&dir);
628
+ }
629
+ }