Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
chore: remove openclaw integration on desktop app
Vanalite841ab1bb9190
diff --git a/extensions/yarn.lock b/extensions/yarn.lockindex 46c067f58..a05a6e928 100644--- a/extensions/yarn.lock+++ b/extensions/yarn.lock@@ -342,7 +342,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Fassistant-extension%40workspace%3Aassistant-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Fassistant-extension%40workspace%3Aassistant-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Fassistant-extension%40workspace%3Aassistant-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -354,7 +354,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Fconversational-extension%40workspace%3Aconversational-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Fconversational-extension%40workspace%3Aconversational-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Fconversational-extension%40workspace%3Aconversational-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -366,19 +366,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Fdownload-extension%40workspace%3Adownload-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Fdownload-extension%40workspace%3Adownload-extension"- dependencies:- rxjs: "npm:^7.8.1"- ulidx: "npm:^2.3.0"- peerDependencies:- react: 19.0.0- checksum: 10c0/c80736877d9b0d9498d76588a1e92664f467a84265aee7cb6be497b89ed4b1e1c9379c12686c4676bb438eb268ba97caae607b01686e3dc0d485933a4ab69af7- languageName: node- linkType: hard--"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Ffoundation-models-extension%40workspace%3Afoundation-models-extension":- version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Ffoundation-models-extension%40workspace%3Afoundation-models-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Fdownload-extension%40workspace%3Adownload-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -390,7 +378,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Fllamacpp-extension%40workspace%3Allamacpp-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Fllamacpp-extension%40workspace%3Allamacpp-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Fllamacpp-extension%40workspace%3Allamacpp-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -402,7 +390,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Fmlx-extension%40workspace%3Amlx-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Fmlx-extension%40workspace%3Amlx-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Fmlx-extension%40workspace%3Amlx-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -414,7 +402,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Frag-extension%40workspace%3Arag-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Frag-extension%40workspace%3Arag-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Frag-extension%40workspace%3Arag-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -426,7 +414,7 @@ __metadata:"@janhq/core@file:../../core/package.tgz::locator=%40janhq%2Fvector-db-extension%40workspace%3Avector-db-extension":version: 0.1.10- resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=4d03b5&locator=%40janhq%2Fvector-db-extension%40workspace%3Avector-db-extension"+ resolution: "@janhq/core@file:../../core/package.tgz#../../core/package.tgz::hash=6c8a42&locator=%40janhq%2Fvector-db-extension%40workspace%3Avector-db-extension"dependencies:rxjs: "npm:^7.8.1"ulidx: "npm:^2.3.0"@@ -451,21 +439,6 @@ __metadata:languageName: unknownlinkType: soft-"@janhq/foundation-models-extension@workspace:foundation-models-extension":- version: 0.0.0-use.local- resolution: "@janhq/foundation-models-extension@workspace:foundation-models-extension"- dependencies:- "@janhq/core": ../../core/package.tgz- "@janhq/tauri-plugin-foundation-models-api": "link:../../src-tauri/plugins/tauri-plugin-foundation-models"- "@tauri-apps/api": "npm:2.8.0"- "@tauri-apps/plugin-log": "npm:^2.6.0"- cpx: "npm:1.5.0"- rimraf: "npm:3.0.2"- rolldown: "npm:1.0.0-beta.1"- typescript: "npm:5.9.2"- languageName: unknown- linkType: soft-"@janhq/llamacpp-extension@workspace:llamacpp-extension":version: 0.0.0-use.localresolution: "@janhq/llamacpp-extension@workspace:llamacpp-extension"@@ -520,12 +493,6 @@ __metadata:languageName: unknownlinkType: soft-"@janhq/tauri-plugin-foundation-models-api@link:../../src-tauri/plugins/tauri-plugin-foundation-models::locator=%40janhq%2Ffoundation-models-extension%40workspace%3Afoundation-models-extension":- version: 0.0.0-use.local- resolution: "@janhq/tauri-plugin-foundation-models-api@link:../../src-tauri/plugins/tauri-plugin-foundation-models::locator=%40janhq%2Ffoundation-models-extension%40workspace%3Afoundation-models-extension"- languageName: node- linkType: soft-"@janhq/tauri-plugin-hardware-api@link:../../src-tauri/plugins/tauri-plugin-hardware::locator=%40janhq%2Fllamacpp-extension%40workspace%3Allamacpp-extension":version: 0.0.0-use.localresolution: "@janhq/tauri-plugin-hardware-api@link:../../src-tauri/plugins/tauri-plugin-hardware::locator=%40janhq%2Fllamacpp-extension%40workspace%3Allamacpp-extension"diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 7dab7692c..82c6781af 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -8,7 +8,6 @@ version = "0.6.599"dependencies = ["async-trait","base64 0.22.1",- "bollard","chrono","clap","console",@@ -64,7 +63,6 @@ dependencies = ["tempfile","thiserror 2.0.17","tokio",- "tokio-tungstenite","tokio-util","url","uuid",@@ -549,50 +547,6 @@ dependencies = ["piper",]-[[package]]-name = "bollard"-version = "0.18.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "97ccca1260af6a459d75994ad5acc1651bcabcbdbc41467cc9786519ab854c30"-dependencies = [- "base64 0.22.1",- "bollard-stubs",- "bytes",- "futures-core",- "futures-util",- "hex",- "http 1.3.1",- "http-body-util",- "hyper 1.7.0",- "hyper-named-pipe",- "hyper-util",- "hyperlocal",- "log",- "pin-project-lite",- "serde",- "serde_derive",- "serde_json",- "serde_repr",- "serde_urlencoded",- "thiserror 2.0.17",- "tokio",- "tokio-util",- "tower-service",- "url",- "winapi",-]--[[package]]-name = "bollard-stubs"-version = "1.47.1-rc.27.3.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "3f179cfbddb6e77a5472703d4b30436bff32929c0aa8a9008ecf23d1d3cdd0da"-dependencies = [- "serde",- "serde_repr",- "serde_with",-]-[[package]]name = "borsh"version = "1.5.7"@@ -1334,12 +1288,6 @@ dependencies = ["parking_lot_core",]-[[package]]-name = "data-encoding"-version = "2.10.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea"-[[package]]name = "data-url"version = "0.3.2"@@ -2700,7 +2648,6 @@ dependencies = ["http 1.3.1","http-body 1.0.1","httparse",- "httpdate","itoa","pin-project-lite","pin-utils",@@ -2709,21 +2656,6 @@ dependencies = ["want",]-[[package]]-name = "hyper-named-pipe"-version = "0.1.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278"-dependencies = [- "hex",- "hyper 1.7.0",- "hyper-util",- "pin-project-lite",- "tokio",- "tower-service",- "winapi",-]-[[package]]name = "hyper-rustls"version = "0.24.2"@@ -2794,21 +2726,6 @@ dependencies = ["windows-registry",]-[[package]]-name = "hyperlocal"-version = "0.9.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7"-dependencies = [- "hex",- "http-body-util",- "hyper 1.7.0",- "hyper-util",- "pin-project-lite",- "tokio",- "tower-service",-]-[[package]]name = "iana-time-zone"version = "0.1.64"@@ -7196,20 +7113,6 @@ dependencies = ["tokio",]-[[package]]-name = "tokio-tungstenite"-version = "0.24.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9"-dependencies = [- "futures-util",- "log",- "native-tls",- "tokio",- "tokio-native-tls",- "tungstenite",-]-[[package]]name = "tokio-util"version = "0.7.16"@@ -7424,25 +7327,6 @@ version = "0.2.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"-[[package]]-name = "tungstenite"-version = "0.24.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a"-dependencies = [- "byteorder",- "bytes",- "data-encoding",- "http 1.3.1",- "httparse",- "log",- "native-tls",- "rand 0.8.5",- "sha1",- "thiserror 1.0.69",- "utf-8",-]-[[package]]name = "type1-encoding-parser"version = "0.1.0"diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex ab3ad573c..9bfad4126 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -35,13 +35,11 @@ hardware = ["dep:tauri-plugin-hardware"]deep-link = ["dep:tauri-plugin-deep-link"]mlx = ["dep:tauri-plugin-mlx"]foundation-models = ["dep:tauri-plugin-foundation-models"]-docker = ["dep:bollard"]desktop = ["deep-link","hardware","mlx",- "foundation-models",- "docker"+ "foundation-models"]mobile = ["tauri/protocol-asset",@@ -122,14 +120,12 @@ ed25519-dalek = { version = "2.1", features = ["rand_core"] }futures = "0.3"hostname = "0.4"base64 = "0.22"-tokio-tungstenite = { version = "0.24", features = ["native-tls"] }glob = "0.3"clap = { version = "4", features = ["derive"] }dialoguer = { version = "0.11", optional = true }env_logger = { version = "0.11", optional = true }indicatif = { version = "0.17", optional = true }console = { version = "0.15", optional = true }-bollard = { version = "0.18", optional = true }[dependencies.tauri]version = "2.8.5"diff --git a/src-tauri/src/core/mod.rs b/src-tauri/src/core/mod.rsindex 86844f8c9..673bf0fab 100644--- a/src-tauri/src/core/mod.rs+++ b/src-tauri/src/core/mod.rs@@ -5,7 +5,6 @@ pub mod downloads;pub mod extensions;pub mod filesystem;pub mod mcp;-pub mod openclaw;pub mod server;pub mod setup;pub mod state;diff --git a/src-tauri/src/core/openclaw/cli.rs b/src-tauri/src/core/openclaw/cli.rsdeleted file mode 100644index d74315acf..000000000--- a/src-tauri/src/core/openclaw/cli.rs+++ /dev/null@@ -1,254 +0,0 @@-use std::process::Stdio;-use tokio::process::Command;--use super::models::OpenClawStatus;-use super::{get_openclaw_config_dir, get_openclaw_config_path, OPENCLAW_PORT};--#[cfg(target_os = "windows")]-fn hide_window(cmd: &mut Command) {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);-}--#[cfg(not(target_os = "windows"))]-fn hide_window(_cmd: &mut Command) {}--/// Returns the BUN_INSTALL directory (`~/.jan/.bunx`), creating it if needed.-fn get_bunx_dir() -> Option<std::path::PathBuf> {- let dir = dirs::home_dir()?.join(".jan").join(".bunx");- if let Err(e) = std::fs::create_dir_all(&dir) {- log::warn!("Failed to create BUN_INSTALL dir {:?}: {}", dir, e);- }- Some(dir)-}--/// Build a command for openclaw. On Unix, uses bun as explicit interpreter-/// to bypass shebang resolution. On Windows, runs openclaw.exe directly.-fn build_openclaw_command(args: &[&str]) -> tokio::process::Command {- let bunx_dir = get_bunx_dir();-- let installed_bin = bunx_dir.as_ref().map(|d| {- if cfg!(target_os = "windows") {- d.join("bin").join("openclaw.exe")- } else {- d.join("bin").join("openclaw")- }- });-- let mut cmd = if installed_bin.as_ref().map(|p| p.exists()).unwrap_or(false) {- log::info!("Running openclaw from installed path: {:?}", installed_bin);- tokio::process::Command::new(installed_bin.unwrap())- } else if let Some(bun) = super::resolve_bundled_bun() {- log::info!("openclaw not installed yet, falling back to bun x");- let mut c = tokio::process::Command::new(bun);- c.arg("x");- c.arg("openclaw");- c- } else {- tokio::process::Command::new("openclaw")- };-- cmd.args(args)- // .current_dir(config_dir)- .stdout(Stdio::piped())- .stderr(Stdio::piped());-- if let Some(dir) = bunx_dir {- cmd.env("BUN_INSTALL", dir);- }-- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);- }-- cmd-}--async fn check_openclaw_installed() -> Result<Option<String>, String> {- if let Ok(openclaw_path) = super::get_openclaw_bin_path() {- if openclaw_path.exists() {- let bun_path = super::resolve_bundled_bun();- let mut cmd = if !cfg!(target_os = "windows") && bun_path.is_some() {- let mut c = Command::new(bun_path.unwrap());- c.arg(&openclaw_path);- c- } else {- Command::new(&openclaw_path)- };- cmd.arg("--version");- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }- hide_window(&mut cmd);- let output = cmd.output().await;-- if let Ok(output) = output {- if output.status.success() {- let version = String::from_utf8_lossy(&output.stdout).trim().to_string();- return Ok(Some(version));- }- }- }- }-- let mut cmd = Command::new("openclaw");- cmd.arg("--version");- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- let version = String::from_utf8_lossy(&output.stdout).trim().to_string();- Ok(Some(version))- } else {- Ok(None)- }- }- Err(_) => Ok(None),- }-}--async fn check_runtime_version() -> Option<String> {- if let Some(bun_path) = super::resolve_bundled_bun() {- let mut cmd = Command::new(&bun_path);- cmd.arg("--version");- hide_window(&mut cmd);- let output = cmd.output().await.ok()?;-- if output.status.success() {- let version = String::from_utf8_lossy(&output.stdout).trim().to_string();- return Some(format!("bun {}", version));- }- }-- let mut cmd = Command::new("node");- cmd.arg("--version");- hide_window(&mut cmd);- let output = cmd.output().await.ok()?;-- if output.status.success() {- Some(String::from_utf8_lossy(&output.stdout).trim().to_string())- } else {- None- }-}--async fn check_port_available(port: u16) -> bool {- let addr = format!("127.0.0.1:{}", port);- tokio::net::TcpListener::bind(&addr).await.is_ok()-}--async fn check_gateway_running() -> bool {- !check_port_available(OPENCLAW_PORT).await-}--pub async fn get_status() -> Result<OpenClawStatus, String> {- let openclaw_version = check_openclaw_installed().await?;- let runtime_version = check_runtime_version().await;- let port_available = check_port_available(OPENCLAW_PORT).await;- let running = check_gateway_running().await;-- Ok(OpenClawStatus {- installed: openclaw_version.is_some(),- running,- runtime_version,- openclaw_version,- port_available,- error: None,- sandbox_type: None,- isolation_tier: None,- })-}--pub async fn start_gateway() -> Result<(), String> {- if check_gateway_running().await {- return Err("OpenClaw gateway is already running".to_string());- }-- let config_path = get_openclaw_config_path()?;- if !config_path.exists() {- return Err("OpenClaw is not configured. Run 'jan openclaw configure' first.".to_string());- }-- let config_dir = get_openclaw_config_dir()?;-- let mut child = build_openclaw_command(&["gateway", "start"])- .current_dir(&config_dir)- .stdout(Stdio::null())- .stderr(Stdio::null())- .spawn()- .map_err(|e| format!("Failed to start OpenClaw: {}", e))?;-- tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;-- match child.try_wait() {- Ok(Some(status)) => {- if !status.success() {- return Err("OpenClaw gateway failed to start".to_string());- }- }- Ok(None) => {}- Err(e) => {- return Err(format!("Failed to check gateway status: {}", e));- }- }-- Ok(())-}--pub async fn stop_gateway() -> Result<(), String> {- let output = build_openclaw_command(&["gateway", "stop"])- .output()- .await;-- if let Ok(output) = output {- if output.status.success() {- return Ok(());- }- }-- #[cfg(unix)]- {- let mut cmd = Command::new("pkill");- cmd.args(["-f", "openclaw"]);- let _ = cmd.output().await;- }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- let kill = |im: &'static str| async move {- let mut cmd = Command::new("taskkill");- cmd.args(["/F", "/IM", im]);- cmd.creation_flags(0x08000000);- let _ = cmd.output().await;- };- kill("bun.exe").await;- kill("node.exe").await;- kill("openclaw.exe").await;- }-- tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;-- if check_gateway_running().await {- return Err("Failed to stop OpenClaw gateway".to_string());- }-- Ok(())-}--pub async fn restart_gateway() -> Result<(), String> {- let _ = stop_gateway().await;- tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;- start_gateway().await-}diff --git a/src-tauri/src/core/openclaw/commands.rs b/src-tauri/src/core/openclaw/commands.rsdeleted file mode 100644index 26d998b7c..000000000--- a/src-tauri/src/core/openclaw/commands.rs+++ /dev/null@@ -1,4725 +0,0 @@-use std::process::Stdio;-use std::sync::atomic::{AtomicU8, AtomicU64, Ordering};--use futures::{SinkExt, StreamExt};-use serde::{Deserialize, Serialize};-use tokio::process::Command;-use tokio::net::TcpStream;-use tokio_tungstenite::{connect_async_with_config, tungstenite::{self, Message, http::Request}, MaybeTlsStream, WebSocketStream};-use tauri::State;--use crate::core::openclaw::{- constants::*,- models::*,- sandbox::Sandbox,- get_openclaw_config_path, get_openclaw_config_dir, set_docker_mode, OpenClawState, OPENCLAW_PORT,-};--/// On Windows, prevent console window popups for background commands.-#[cfg(target_os = "windows")]-fn hide_window(cmd: &mut Command) {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW-}--#[cfg(not(target_os = "windows"))]-fn hide_window(_cmd: &mut Command) {}--/// Request ID counter for WebSocket messages-static REQUEST_ID_COUNTER: AtomicU64 = AtomicU64::new(1);--/// Container name for the Docker sandbox-const DOCKER_CONTAINER_NAME: &str = "jan-openclaw";--/// Check if the Docker container `jan-openclaw` is running.-async fn is_docker_container_running() -> bool {- let mut cmd = Command::new("docker");- cmd.args(["inspect", "--format", "{{.State.Running}}", DOCKER_CONTAINER_NAME]);- hide_window(&mut cmd);- cmd.output()- .await- .map(|o| o.status.success() && String::from_utf8_lossy(&o.stdout).trim() == "true")- .unwrap_or(false)-}--/// Returns the BUN_INSTALL directory under Jan's data folder, creating it if needed.-fn get_bunx_dir() -> Option<std::path::PathBuf> {- let dir = super::get_openclaw_base_dir().ok()?.join("bunx");- if let Err(e) = std::fs::create_dir_all(&dir) {- log::warn!("Failed to create BUN_INSTALL dir {:?}: {}", dir, e);- }- Some(dir)-}--/// Build a command for openclaw. On Unix, uses bun as explicit interpreter-/// to bypass shebang resolution. On Windows, runs openclaw.exe directly.-fn build_openclaw_command(args: &[&str]) -> tokio::process::Command {- let bunx_dir = get_bunx_dir();-- let installed_bin = bunx_dir.as_ref().map(|d| {- if cfg!(target_os = "windows") {- d.join("bin").join("openclaw.exe")- } else {- d.join("bin").join("openclaw")- }- });-- let mut cmd = if installed_bin.as_ref().map(|p| p.exists()).unwrap_or(false) {- log::info!("Running openclaw from installed path: {:?}", installed_bin);- tokio::process::Command::new(installed_bin.unwrap())- } else if let Some(bun) = super::resolve_bundled_bun() {- log::info!("openclaw not installed yet, falling back to bun x");- let mut c = tokio::process::Command::new(bun);- c.arg("x");- c.arg("openclaw");- c- } else {- tokio::process::Command::new("openclaw")- };-- cmd.args(args)- // .current_dir(config_dir)- .stdout(Stdio::piped())- .stderr(Stdio::piped());-- if let Some(dir) = bunx_dir {- cmd.env("BUN_INSTALL", dir);- }-- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);- }-- cmd-}--/// Build a `Command` for openclaw: docker exec when container is running,-/// otherwise direct process with bun interpreter (Unix) or native exe (Windows).-async fn openclaw_command(args: &[&str]) -> Command {- if is_docker_container_running().await {- let mut cmd = Command::new("docker");- let mut full_args: Vec<&str> = vec![- "exec",- "-e", "OPENCLAW_CONFIG=/home/node/.openclaw/openclaw.json",- "-e", "HOME=/home/node",- DOCKER_CONTAINER_NAME,- "openclaw",- ];- full_args.extend_from_slice(args);- cmd.args(full_args);- hide_window(&mut cmd);- cmd- } else {- let mut cmd = build_openclaw_command(args);- hide_window(&mut cmd);- cmd- }-}--/// Gateway restart attempts counter during WhatsApp auth polling (reset per session).-static WA_RESTART_COUNT: AtomicU8 = AtomicU8::new(0);-const MAX_WA_RESTART_ATTEMPTS: u8 = 3;--fn next_request_id() -> String {- REQUEST_ID_COUNTER.fetch_add(1, Ordering::SeqCst).to_string()-}--/// Returns true if `installed` is older than `required` (CalVer comparison).-/// Returns false if either version cannot be parsed.-pub(crate) fn needs_upgrade(installed: &str, required: &str) -> bool {- let parse = |v: &str| -> Option<Vec<u32>> {- v.split('.').map(|s| s.parse::<u32>().ok()).collect()- };- match (parse(installed), parse(required)) {- (Some(a), Some(b)) => a < b,- _ => false,- }-}--#[derive(Debug, Serialize)]-struct GatewayRequest {- #[serde(rename = "type")]- msg_type: String,- id: String,- method: String,- params: serde_json::Value,-}--#[derive(Debug, Deserialize)]-struct GatewayResponse {- #[serde(rename = "type")]- msg_type: String,- id: String,- ok: bool,- #[serde(default)]- payload: serde_json::Value,- #[serde(default)]- error: Option<serde_json::Value>,-}--/// Read the gateway auth token from the OpenClaw config file.-async fn get_gateway_auth_token() -> Result<String, String> {- let config_path = get_openclaw_config_path()?;-- if !config_path.exists() {- return Err("OpenClaw config not found".to_string());- }-- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read OpenClaw config: {}", e))?;-- let config: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse OpenClaw config: {}", e))?;-- config- .get("gateway")- .and_then(|g| g.get("auth"))- .and_then(|a| a.get("token"))- .and_then(|t| t.as_str())- .map(String::from)- .ok_or_else(|| "Gateway auth token not found in config".to_string())-}--/// Expose the gateway auth token to the frontend for direct HTTP API access.-#[tauri::command]-pub async fn openclaw_get_auth_token() -> Result<String, String> {- get_gateway_auth_token().await-}--/// Ensure the OpenClaw HTTP chat completions endpoint is enabled in the config.-/// This is required for Jan's agent mode to send messages via POST /v1/chat/completions.-/// Uses `or_insert` semantics — only adds the field if missing, never overwrites.-#[tauri::command]-pub async fn openclaw_ensure_http_api() -> Result<bool, String> {- let mut config = read_openclaw_config()?;-- let enabled = config- .pointer("/gateway/http/endpoints/chatCompletions/enabled")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- if enabled {- return Ok(false); // already enabled, no change- }-- // Deep-set gateway.http.endpoints.chatCompletions.enabled = true- let gw = config.get_mut("gateway")- .and_then(|v| v.as_object_mut())- .ok_or("Missing gateway config")?;- let http = gw.entry("http")- .or_insert_with(|| serde_json::json!({}));- let endpoints = http.as_object_mut()- .ok_or("Invalid gateway.http")?- .entry("endpoints")- .or_insert_with(|| serde_json::json!({}));- let cc = endpoints.as_object_mut()- .ok_or("Invalid gateway.http.endpoints")?- .entry("chatCompletions")- .or_insert_with(|| serde_json::json!({}));- cc.as_object_mut()- .ok_or("Invalid gateway.http.endpoints.chatCompletions")?- .insert("enabled".to_string(), serde_json::json!(true));-- write_openclaw_config(&config)?;- log::info!("Enabled OpenClaw HTTP chat completions endpoint");- Ok(true) // config was changed-}--/// Connect to the OpenClaw Gateway WebSocket with required Origin header.-async fn connect_to_gateway() -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>, String> {- let url = format!("ws://127.0.0.1:{}", OPENCLAW_PORT);-- // Origin header required for CVE-2026-25253 validation- let request = Request::builder()- .uri(&url)- .header("Host", format!("127.0.0.1:{}", OPENCLAW_PORT))- .header("Origin", "http://localhost")- .header("Connection", "Upgrade")- .header("Upgrade", "websocket")- .header("Sec-WebSocket-Version", "13")- .header("Sec-WebSocket-Key", tungstenite::handshake::client::generate_key())- .body(())- .map_err(|e| format!("Failed to build WebSocket request: {}", e))?;-- let (ws_stream, _) = connect_async_with_config(request, None, false)- .await- .map_err(|e| format!("Failed to connect to OpenClaw Gateway: {}", e))?;-- Ok(ws_stream)-}--/// Perform the Gateway handshake (connect request) using protocol v3.-async fn gateway_handshake(ws_stream: &mut WebSocketStream<MaybeTlsStream<TcpStream>>) -> Result<(), String> {- let timeout = tokio::time::Duration::from_secs(5);- let challenge_result = tokio::time::timeout(timeout, async {- while let Some(msg) = ws_stream.next().await {- match msg {- Ok(Message::Text(text)) => {- log::debug!("Received during handshake: {}", text);- if let Ok(event) = serde_json::from_str::<serde_json::Value>(&text) {- if event.get("type").and_then(|t| t.as_str()) == Some("event")- && event.get("event").and_then(|e| e.as_str()) == Some("connect.challenge") {- let nonce = event.get("payload")- .and_then(|p| p.get("nonce"))- .and_then(|n| n.as_str())- .map(String::from);- return Ok(nonce);- }- }- }- Ok(Message::Close(_)) => return Err("Connection closed during handshake".to_string()),- Err(e) => return Err(format!("WebSocket error during handshake: {}", e)),- _ => {}- }- }- Err("No challenge received".to_string())- }).await;-- match challenge_result {- Ok(Ok(_)) => {}- Ok(Err(e)) => return Err(e),- Err(_) => return Err("Handshake timeout".to_string()),- };-- // client.id "openclaw-control-ui" enables dangerouslyDisableDeviceAuth bypass- let connect_id = next_request_id();- let auth_token = get_gateway_auth_token().await.unwrap_or_default();-- let connect_request = serde_json::json!({- "type": "req",- "id": connect_id,- "method": "connect",- "params": {- "minProtocol": 3,- "maxProtocol": 3,- "client": {- "id": "openclaw-control-ui",- "version": env!("CARGO_PKG_VERSION"),- "platform": std::env::consts::OS,- "mode": "webchat"- },- "role": "operator",- "scopes": ["operator.read", "operator.write", "operator.channels", "operator.admin"],- "caps": ["structured-commands"],- "commands": [],- "permissions": {},- "auth": {- "token": auth_token- },- "locale": "en-US",- "userAgent": format!("jan-desktop/{}", env!("CARGO_PKG_VERSION"))- }- });-- let request_json = serde_json::to_string(&connect_request)- .map_err(|e| format!("Failed to serialize connect request: {}", e))?;-- log::debug!("Connect request: {}", request_json);-- ws_stream.send(Message::Text(request_json))- .await- .map_err(|e| format!("Failed to send connect request: {}", e))?;-- let response_result = tokio::time::timeout(timeout, async {- while let Some(msg) = ws_stream.next().await {- match msg {- Ok(Message::Text(text)) => {- log::debug!("Received connect response: {}", text);- if let Ok(response) = serde_json::from_str::<GatewayResponse>(&text) {- if response.msg_type == "res" && response.id == connect_id {- if response.ok {- return Ok(());- } else {- let error_msg = response.error- .map(|e| {- e.get("message")- .and_then(|m| m.as_str())- .map(String::from)- .unwrap_or_else(|| e.to_string())- })- .unwrap_or_else(|| "Unknown connect error".to_string());- return Err(error_msg);- }- }- }- }- Ok(Message::Close(_)) => return Err("Connection closed".to_string()),- Err(e) => return Err(format!("WebSocket error: {}", e)),- _ => {}- }- }- Err("No connect response received".to_string())- }).await;-- match response_result {- Ok(Ok(())) => Ok(()),- Ok(Err(e)) => Err(e),- Err(_) => Err("Connect response timeout".to_string()),- }-}--/// Send a request to the Gateway and wait for response with configurable timeout.-async fn gateway_request_with_timeout(- method: &str,- params: serde_json::Value,- timeout_secs: u64,-) -> Result<serde_json::Value, String> {- let _ = openclaw_ensure_jan_origin().await;-- let mut ws_stream = connect_to_gateway().await?;- gateway_handshake(&mut ws_stream).await?;-- let request_id = next_request_id();- let request = GatewayRequest {- msg_type: "req".to_string(),- id: request_id.clone(),- method: method.to_string(),- params,- };-- let request_json = serde_json::to_string(&request)- .map_err(|e| format!("Failed to serialize request: {}", e))?;-- log::debug!("Sending Gateway request: {}", request_json);-- ws_stream.send(Message::Text(request_json))- .await- .map_err(|e| format!("Failed to send request: {}", e))?;-- let timeout = tokio::time::Duration::from_secs(timeout_secs);- let result = tokio::time::timeout(timeout, async {- while let Some(msg) = ws_stream.next().await {- match msg {- Ok(Message::Text(text)) => {- log::debug!("Received Gateway message: {}", text);- if let Ok(response) = serde_json::from_str::<GatewayResponse>(&text) {- if response.msg_type == "res" && response.id == request_id {- if response.ok {- return Ok(response.payload);- } else {- let error_msg = response.error- .map(|e| {- e.get("message")- .and_then(|m| m.as_str())- .map(String::from)- .unwrap_or_else(|| e.to_string())- })- .unwrap_or_else(|| "Unknown error".to_string());- return Err(error_msg);- }- }- }- }- Ok(Message::Close(_)) => {- return Err("Connection closed".to_string());- }- Err(e) => {- return Err(format!("WebSocket error: {}", e));- }- _ => {}- }- }- Err("Connection closed unexpectedly".to_string())- }).await;-- let _ = ws_stream.close(None).await;-- match result {- Ok(inner) => inner,- Err(_) => Err("Request timed out".to_string()),- }-}--/// Send a request to the Gateway with default 30s timeout.-async fn gateway_request(- method: &str,- params: serde_json::Value,-) -> Result<serde_json::Value, String> {- gateway_request_with_timeout(method, params, 30).await-}--// ============================================-// Unified 1-Click Setup Functions-// ============================================--#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct OpenClawSetupResult {- /// Whether setup completed successfully- pub success: bool,- /// Current step in the setup process- pub step: String,- /// Whether OpenClaw is installed- pub openclaw_installed: bool,- /// Whether the Gateway is running- pub gateway_running: bool,- /// Whether the device is paired with the Gateway- pub device_paired: bool,- /// Error message if setup failed- pub error: Option<String>,- /// Helpful message for the user- pub message: Option<String>,-}--/// 1-click setup: ensure OpenClaw is installed, configured, and the Gateway is reachable.-#[tauri::command]-pub async fn openclaw_setup_for_channels(state: tauri::State<'_, OpenClawState>) -> Result<OpenClawSetupResult, String> {-- {- let sandbox_guard = state.sandbox.lock().await;- let is_docker = sandbox_guard.as_ref().map(|s| s.name() == "Docker").unwrap_or(false);- set_docker_mode(is_docker);- }-- if let Err(e) = clear_stale_openclaw_data().await {- log::warn!("Failed to clear stale data: {}", e);- }-- let openclaw_version = match check_openclaw_installed().await {- Ok(Some(version)) if !needs_upgrade(&version, OPENCLAW_VERSION) => {- log::info!("OpenClaw installed: {}", version);- Some(version)- }- Ok(maybe_version) => {- if let Some(ref v) = maybe_version {- log::info!("OpenClaw {} outdated, upgrading to {}", v, OPENCLAW_VERSION);- }- match openclaw_install().await {- Ok(result) if result.success => {- result.version- }- Ok(result) => {- return Ok(OpenClawSetupResult {- success: false,- step: "install".to_string(),- openclaw_installed: false,- gateway_running: false,- device_paired: false,- error: result.error,- message: Some("Please install Bun or Node.js 22+ and OpenClaw manually".to_string()),- });- }- Err(e) => {- return Ok(OpenClawSetupResult {- success: false,- step: "install".to_string(),- openclaw_installed: false,- gateway_running: false,- device_paired: false,- error: Some(e),- message: Some("Please install Bun or Node.js 22+ and OpenClaw manually".to_string()),- });- }- }- }- Err(e) => {- return Ok(OpenClawSetupResult {- success: false,- step: "check_install".to_string(),- openclaw_installed: false,- gateway_running: false,- device_paired: false,- error: Some(e),- message: None,- });- }- };-- let config_changed = match ensure_gateway_config_for_jan().await {- Ok(changed) => changed,- Err(e) => {- log::warn!("Failed to configure Gateway: {}", e);- false- }- };-- let gateway_running = check_gateway_responding().await;- if !gateway_running {- match openclaw_start(state.clone()).await {- Ok(()) => {- if !wait_for_gateway_ready(10).await {- log::warn!("Gateway did not become responsive within 10s, proceeding anyway");- }- }- Err(e) => {- return Ok(OpenClawSetupResult {- success: false,- step: "start_gateway".to_string(),- openclaw_installed: openclaw_version.is_some(),- gateway_running: false,- device_paired: false,- error: Some(e),- message: Some("Failed to start the OpenClaw Gateway".to_string()),- });- }- }- } else if config_changed {- log::info!("Config changed, restarting Gateway");- let _ = restart_gateway_cli().await;- if !wait_for_gateway_ready(10).await {- log::warn!("Gateway did not become responsive after restart within 10s");- }- }-- match test_gateway_connection().await {- Ok(()) => {- return Ok(OpenClawSetupResult {- success: true,- step: "complete".to_string(),- openclaw_installed: true,- gateway_running: true,- device_paired: true,- error: None,- message: Some("OpenClaw is ready for channel connections".to_string()),- });- }- Err(e) => {- log::warn!("Gateway connection failed: {}, retrying after restart", e);-- let _ = restart_gateway_cli().await;- if !wait_for_gateway_ready(10).await {- log::warn!("Gateway did not become responsive after retry restart");- }-- match test_gateway_connection().await {- Ok(()) => {- return Ok(OpenClawSetupResult {- success: true,- step: "complete".to_string(),- openclaw_installed: true,- gateway_running: true,- device_paired: true,- error: None,- message: Some("OpenClaw is ready for channel connections".to_string()),- });- }- Err(retry_err) => {- return Ok(OpenClawSetupResult {- success: false,- step: "connect".to_string(),- openclaw_installed: true,- gateway_running: true,- device_paired: false,- error: Some(retry_err),- message: Some("Connection failed. Please check if OpenClaw Gateway is running.".to_string()),- });- }- }- }- }-}--/// Test the Gateway connection by performing a handshake only.-async fn test_gateway_connection() -> Result<(), String> {- let mut ws_stream = connect_to_gateway().await?;- gateway_handshake(&mut ws_stream).await?;- let _ = ws_stream.close(None).await;- Ok(())-}--/// Validate gateway auth via WebSocket handshake + RPC health check.-async fn validate_gateway_auth() -> Result<(), String> {- let mut ws_stream = connect_to_gateway().await- .map_err(|e| format!("Gateway unreachable: {}", e))?;-- gateway_handshake(&mut ws_stream).await- .map_err(|e| format!("Gateway auth failed: {}", e))?;-- let health_id = next_request_id();- let health_request = serde_json::json!({- "type": "req",- "id": health_id,- "method": "health",- "params": {}- });-- let health_json = serde_json::to_string(&health_request)- .map_err(|e| format!("Failed to serialize health request: {}", e))?;-- ws_stream.send(Message::Text(health_json))- .await- .map_err(|e| format!("Failed to send health request: {}", e))?;-- let timeout = tokio::time::Duration::from_secs(5);- let health_result = tokio::time::timeout(timeout, async {- while let Some(msg) = ws_stream.next().await {- match msg {- Ok(Message::Text(text)) => {- if let Ok(response) = serde_json::from_str::<GatewayResponse>(&text) {- if response.msg_type == "res" && response.id == health_id {- if response.ok {- return Ok(());- } else {- let error_msg = response.error- .map(|e| {- e.get("message")- .and_then(|m| m.as_str())- .map(String::from)- .unwrap_or_else(|| e.to_string())- })- .unwrap_or_else(|| "Health check rejected".to_string());- return Err(format!("Gateway health check failed: {}", error_msg));- }- }- }- }- Ok(Message::Close(_)) => return Err("Connection closed during health check".to_string()),- Err(e) => return Err(format!("WebSocket error during health check: {}", e)),- _ => {}- }- }- Err("Connection closed before health response".to_string())- }).await;-- let _ = ws_stream.close(None).await;-- match health_result {- Ok(inner) => inner,- Err(_) => Err("Gateway health check timed out".to_string()),- }-}--/// Auto-fix gateway config issues via `openclaw doctor --fix`.-async fn run_doctor_fix() -> Result<(), String> {- let output = openclaw_command(&["doctor", "--fix"]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw doctor: {}", e))?;-- if output.status.success() {- Ok(())- } else {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("openclaw doctor --fix failed: {}", stderr);- Err(format!("Doctor fix failed: {}", stderr.trim()))- }-}--/// Restart the gateway. Docker: `docker restart`. Direct process: stop → spawn child.-async fn restart_gateway_cli() -> Result<(), String> {- if is_docker_container_running().await {- let mut cmd = Command::new("docker");- cmd.args(["restart", DOCKER_CONTAINER_NAME])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- let output = cmd.output()- .await- .map_err(|e| format!("Failed to restart Docker container: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("Docker container restart failed: {}", stderr);- }- return Ok(());- }-- let _ = openclaw_command(&["gateway", "stop"]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await;-- tokio::time::sleep(std::time::Duration::from_secs(1)).await;-- // Check if a system service is already registered (launchd plist on Mac,- // systemd unit on Linux) — if so, use `gateway start` to let the service- // manager handle it. Otherwise spawn as a direct child process.- let service_exists = is_gateway_service_registered();-- if service_exists {- let output = openclaw_command(&["gateway", "start"]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to start gateway: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("Gateway start via service failed: {}, falling back to child process", stderr);- let mut cmd = openclaw_command(&["gateway"]).await;- cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());- hide_window(&mut cmd);- if let Err(e) = cmd.spawn() {- log::warn!("Failed to spawn openclaw gateway: {}", e);- }- }- } else {- log::info!("No gateway service registered, restarting as child process");- let mut cmd = openclaw_command(&["gateway"]).await;- cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());- hide_window(&mut cmd);- if let Err(e) = cmd.spawn() {- log::warn!("Failed to spawn openclaw gateway: {}", e);- }- }- Ok(())-}--/// Check if a gateway system service is already registered (without running `gateway install`).-fn is_gateway_service_registered() -> bool {- #[cfg(target_os = "macos")]- {- if let Some(home) = dirs::home_dir() {- return home.join("Library/LaunchAgents/ai.openclaw.gateway.plist").exists();- }- }- #[cfg(target_os = "linux")]- {- if let Some(home) = dirs::home_dir() {- return home.join(".config/systemd/user/openclaw-gateway.service").exists();- }- }- // Windows uses Task Scheduler — no simple file check, default to child process.- false-}--/// Clear stale files that may cause setup failures.-async fn clear_stale_openclaw_data() -> Result<(), String> {- let config_dir = get_openclaw_config_dir()?;-- let stale_files = ["jan_device_key.json", "whatsapp.json"];- for file in &stale_files {- let file_path = config_dir.join(file);- if file_path.exists() {- match std::fs::remove_file(&file_path) {- Ok(_) => log::info!("Removed stale file: {}", file),- Err(e) => log::warn!("Failed to remove {}: {}", file, e),- }- }- }-- // Remove corrupted whatsapp_auth session files (< 10 bytes)- let whatsapp_auth_dir = config_dir.join("whatsapp_auth");- if whatsapp_auth_dir.exists() {- if let Ok(entries) = std::fs::read_dir(&whatsapp_auth_dir) {- for entry in entries.flatten() {- if let Ok(metadata) = entry.metadata() {- if metadata.len() < 10 {- let _ = std::fs::remove_file(entry.path());- }- }- }- }- }-- Ok(())-}--/// Stop the opposing sandbox instance to prevent 409 conflicts when switching modes.-async fn stop_other_sandbox_instance(stop_docker: bool) {- if stop_docker {- if is_docker_container_running().await {- let mut cmd = Command::new("docker");- cmd.args(["stop", DOCKER_CONTAINER_NAME])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- let _ = cmd.output().await;- }- } else {- // Try to use resolved openclaw path first, fallback to bare command- let openclaw_path = super::get_openclaw_bin_path().ok();- let use_installed_binary = openclaw_path- .as_ref()- .map(|p| p.exists())- .unwrap_or(false);-- let cli_stopped = if use_installed_binary {- let mut cmd = Command::new(openclaw_path.unwrap());- cmd.args(["gateway", "stop"])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }- hide_window(&mut cmd);- cmd.output()- .await- .map(|o| o.status.success())- .unwrap_or(false)- } else {- let mut cmd = Command::new("openclaw");- cmd.args(["gateway", "stop"])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }- hide_window(&mut cmd);- cmd.output()- .await- .map(|o| o.status.success())- .unwrap_or(false)- };-- if !cli_stopped {- #[cfg(any(target_os = "macos", target_os = "linux"))]- {- let _ = Command::new("pkill")- .args(["-f", "openclaw"])- .output()- .await;- }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- let kill = |im: &'static str| async move {- let mut cmd = Command::new("taskkill");- cmd.args(["/F", "/IM", im]);- cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW- let _ = cmd.output().await;- };- kill("bun.exe").await;- kill("node.exe").await;- kill("openclaw.exe").await;- }- }-- for _ in 0..10 {- if !crate::core::openclaw::lifecycle::is_port_in_use(OPENCLAW_PORT).await {- break;- }- tokio::time::sleep(std::time::Duration::from_millis(500)).await;- }-- // Port-based kill fallback- if crate::core::openclaw::lifecycle::is_port_in_use(OPENCLAW_PORT).await {- #[cfg(any(target_os = "macos", target_os = "linux"))]- {- let _ = Command::new("sh")- .args(["-c", &format!("lsof -ti :{} | xargs kill -9", OPENCLAW_PORT)])- .output()- .await;- }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- if let Ok(output) = Command::new("cmd")- .args(["/C", &format!("for /f \"tokens=5\" %a in ('netstat -aon ^| findstr :{} ^| findstr LISTENING') do taskkill /F /PID %a", OPENCLAW_PORT)])- .creation_flags(0x08000000)- .output()- .await- {- let _ = output;- }- }- }- }-}--/// Ensure the Gateway config has all required settings for Jan.-async fn ensure_gateway_config_for_jan() -> Result<bool, String> {- let config_path = get_openclaw_config_path()?;-- if !config_path.exists() {- return Ok(false);- }-- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read OpenClaw config: {}", e))?;-- let mut config: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse OpenClaw config: {}", e))?;-- let mut modified = false;-- if config.get("gateway").is_none() {- config["gateway"] = serde_json::json!({});- modified = true;- }-- if config["gateway"].get("controlUi").is_none() {- config["gateway"]["controlUi"] = serde_json::json!({});- modified = true;- }-- let allowed_origins = config["gateway"]["controlUi"]- .get("allowedOrigins")- .and_then(|v| v.as_array())- .cloned()- .unwrap_or_default();-- let existing_origins: std::collections::HashSet<String> = allowed_origins- .iter()- .filter_map(|v| v.as_str())- .map(String::from)- .collect();-- let mut new_origins: Vec<serde_json::Value> = allowed_origins;- for origin in JAN_ALLOWED_ORIGINS {- if !existing_origins.contains(*origin) {- new_origins.push(serde_json::json!(origin));- modified = true;- }- }- if modified {- config["gateway"]["controlUi"]["allowedOrigins"] = serde_json::Value::Array(new_origins);- }-- let disable_device_auth = config["gateway"]["controlUi"]- .get("dangerouslyDisableDeviceAuth")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- if !disable_device_auth {- config["gateway"]["controlUi"]["dangerouslyDisableDeviceAuth"] = serde_json::json!(true);- modified = true;- }-- // Channels require bind=lan; loopback causes setup errors- let current_bind = config["gateway"]- .get("bind")- .and_then(|v| v.as_str())- .unwrap_or("loopback");- if current_bind == "loopback" {- config["gateway"]["bind"] = serde_json::json!("lan");- modified = true;- }-- if config.get("plugins").is_none() {- config["plugins"] = serde_json::json!({"entries": {}});- }- if config["plugins"].get("entries").is_none() {- config["plugins"]["entries"] = serde_json::json!({});- }- let whatsapp_enabled = config["plugins"]["entries"]- .get("whatsapp")- .and_then(|w| w.get("enabled"))- .and_then(|e| e.as_bool())- .unwrap_or(false);-- if !whatsapp_enabled {- config["plugins"]["entries"]["whatsapp"] = serde_json::json!({"enabled": true});- modified = true;- }-- if modified {- let updated_json = serde_json::to_string_pretty(&config)- .map_err(|e| format!("Failed to serialize config: {}", e))?;-- std::fs::write(&config_path, updated_json)- .map_err(|e| format!("Failed to write config: {}", e))?;-- log::info!("Gateway config updated for Jan");- }-- Ok(modified)-}---/// Ensure gateway.bind is "lan" in config. If the gateway is running-/// and the config changed, restarts it so the service picks up bind=lan.-async fn ensure_gateway_bind_lan() {- let config_path = match get_openclaw_config_path() {- Ok(p) => p,- Err(_) => return,- };- if !config_path.exists() {- return;- }-- let content = match std::fs::read_to_string(&config_path) {- Ok(c) => c,- Err(_) => return,- };- let mut config: serde_json::Value = match serde_json::from_str(&content) {- Ok(c) => c,- Err(_) => return,- };-- let current_bind = config- .pointer("/gateway/bind")- .and_then(|v| v.as_str())- .unwrap_or("loopback");-- if current_bind == "lan" {- return;- }-- config["gateway"]["bind"] = serde_json::json!("lan");- if let Ok(json) = serde_json::to_string_pretty(&config) {- let _ = std::fs::write(&config_path, json);- }-- if check_gateway_responding().await {- let _ = restart_gateway_cli().await;- let _ = wait_for_gateway_ready(10).await;- }-}--/// Check if bundled Bun or Node.js is installed and meets version requirements.-#[tauri::command]-pub async fn openclaw_check_dependencies() -> NodeCheckResult {- // First try: bundled Bun- if let Some(bun_path) = super::resolve_bundled_bun() {- let mut cmd = tokio::process::Command::new(&bun_path);- cmd.arg("--version");- hide_window(&mut cmd);- let output = cmd.output().await;-- if let Ok(output) = output {- if output.status.success() {- let version_output = String::from_utf8_lossy(&output.stdout).trim().to_string();- // Bun returns version like "1.2.3", prepend "bun " for clarity- let version_with_runtime = format!("bun {}", version_output);- let version_str = version_output.trim_start_matches('v');-- let major_version: Option<u32> = version_str- .split('.')- .next()- .and_then(|v| v.parse().ok());-- // Bun 1.0+ meets requirements- let meets_requirements = major_version.map(|v| v >= 1).unwrap_or(false);-- return NodeCheckResult {- installed: true,- version: Some(version_with_runtime),- major_version,- meets_requirements,- error: if !meets_requirements {- Some(format!("Bun version {} is required, found {}", super::MIN_BUN_VERSION, version_str))- } else {- None- },- };- }- }- }-- // Fallback: check for Node.js- let mut node_cmd = Command::new("node");- node_cmd.arg("--version");- hide_window(&mut node_cmd);- let output = node_cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- let version_output = String::from_utf8_lossy(&output.stdout).trim().to_string();- let version_str = version_output.trim_start_matches('v');-- let major_version: Option<u32> = version_str- .split('.')- .next()- .and_then(|v| v.parse().ok());-- let meets_requirements = major_version- .map(|v| v >= 22)- .unwrap_or(false);-- let version_clone = version_output.clone();- NodeCheckResult {- installed: true,- version: Some(version_clone),- major_version,- meets_requirements,- error: if !meets_requirements {- Some(format!("Node.js version 22 is required, found {}", version_str))- } else {- None- },- }- } else {- NodeCheckResult {- installed: false,- version: None,- major_version: None,- meets_requirements: false,- error: Some("Could not find a JavaScript runtime (Bun or Node.js)".to_string()),- }- }- }- Err(e) => {- NodeCheckResult {- installed: false,- version: None,- major_version: None,- meets_requirements: false,- error: Some(format!("Could not find a JavaScript runtime: {}", e)),- }- }- }-}--/// Check if a port is available.-#[tauri::command]-pub async fn openclaw_check_port(port: u16) -> PortCheckResult {-- let addr = if cfg!(target_os = "windows") {- format!("127.0.0.1:{}", port)- } else {- format!("localhost:{}", port)- };-- match tokio::net::TcpListener::bind(&addr).await {- Ok(_) => PortCheckResult {- available: true,- port,- error: None,- },- Err(e) => PortCheckResult {- available: false,- port,- error: Some(format!("Port {} is in use: {}", port, e)),- },- }-}--/// Check if OpenClaw is installed and get its version.-async fn check_openclaw_installed() -> Result<Option<String>, String> {- let output = openclaw_command(&["--version"]).await- .output()- .await;-- match output {- Ok(output) => {- if output.status.success() {- let version = String::from_utf8_lossy(&output.stdout).trim().to_string();- Ok(Some(version))- } else {- Ok(None)- }- }- Err(_) => Ok(None),- }-}--/// Get OpenClaw version from inside the Docker container.-async fn check_openclaw_version_docker() -> Option<String> {- let mut cmd = Command::new("docker");- cmd.args(["exec", "jan-openclaw", "openclaw", "--version"]);- hide_window(&mut cmd);- let output = cmd.output().await.ok()?;-- if output.status.success() {- let version = String::from_utf8_lossy(&output.stdout).trim().to_string();- if version.is_empty() { None } else { Some(version) }- } else {- None- }-}--/// Get Node.js version from inside the Docker container.-async fn check_node_version_docker() -> Option<String> {- let mut cmd = Command::new("docker");- cmd.args(["exec", "jan-openclaw", "node", "--version"]);- hide_window(&mut cmd);- let output = cmd.output().await.ok()?;-- if output.status.success() {- let version = String::from_utf8_lossy(&output.stdout).trim().to_string();- if version.is_empty() { None } else { Some(version) }- } else {- None- }-}--/// Install OpenClaw globally via npm or bun.-#[tauri::command]-pub async fn openclaw_install() -> Result<InstallResult, String> {- let already_installed = check_openclaw_installed().await.ok().flatten();-- let should_install = match &already_installed {- None => true,- Some(version) => needs_upgrade(version, OPENCLAW_VERSION),- };-- if should_install {- if let Some(ref old_version) = already_installed {- log::info!("Upgrading OpenClaw from {} to {}", old_version, OPENCLAW_VERSION);- }- let node_check = openclaw_check_dependencies().await;- if !node_check.installed {- return Ok(InstallResult {- success: false,- version: None,- error: node_check.error.or_else(|| Some("A JavaScript runtime (Bun or Node.js) is required but not found".to_string())),- });- }-- if !node_check.meets_requirements {- return Ok(InstallResult {- success: false,- version: None,- error: node_check.error,- });- }-- let pinned_package = format!("{}@{}", OPENCLAW_PACKAGE_NAME, OPENCLAW_VERSION);-- let output = if let Some(bun_path) = super::resolve_bundled_bun() {- let runtime_dir = super::get_openclaw_runtime_dir()?;- let mut cmd = tokio::process::Command::new(&bun_path);- cmd.args(["install", "-g", &pinned_package])- .env("BUN_INSTALL", runtime_dir.to_string_lossy().as_ref())- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- cmd.output()- .await- .map_err(|e| format!("Failed to run bun install: {}", e))?- } else {- let mut cmd = Command::new("npm");- cmd.args(["install", "-g", &pinned_package])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- cmd.output()- .await- .map_err(|e| format!("Failed to run npm install: {}", e))?- };-- if !output.status.success() {- // Parse error output for better error messages- let stderr = String::from_utf8_lossy(&output.stderr);- let stdout = String::from_utf8_lossy(&output.stdout);-- let error_message = if stderr.contains("404") || stderr.contains("Not Found") || stdout.contains("404") {- format!(- "OpenClaw package '{}' is not yet available on npm. \- Please check the OpenClaw project for installation instructions.",- OPENCLAW_PACKAGE_NAME- )- } else if stderr.contains("EACCES") || stderr.contains("permission denied") {- "Permission denied. Try running with administrator privileges.".to_string()- } else if stderr.contains("ENOTFOUND") || stderr.contains("network") {- "Network error. Please check your internet connection and try again.".to_string()- } else {- format!(- "Installation failed: {}",- if !stderr.is_empty() {- stderr.trim().to_string()- } else if !stdout.is_empty() {- stdout.trim().to_string()- } else {- "Unknown error".to_string()- }- )- };-- log::error!("OpenClaw installation failed: {}", error_message);-- return Ok(InstallResult {- success: false,- version: None,- error: Some(error_message),- });- }- }-- // Verify installation- let version = match check_openclaw_installed().await {- Ok(v) => v,- Err(e) => {- return Ok(InstallResult {- success: false,- version: None,- error: Some(e),- });- }- };-- // Auto-configure for Jan integration-- // 1. Ensure Jan's origins are allowed for WebSocket connections- if let Err(e) = openclaw_ensure_jan_origin().await {- log::warn!("Failed to ensure Jan origin: {}", e);- // Don't fail the install, just log the warning- }-- // 2. Configure WhatsApp with pairing mode by default (safer for users)- if let Ok(mut child) = openclaw_command(&["config", "set", "channels.whatsapp.dmPolicy", "pairing"]).await- .stdout(Stdio::null())- .stderr(Stdio::null())- .spawn()- {- let _ = child.wait().await;- }-- // 3. Configure Telegram with pairing mode by default- if let Ok(mut child) = openclaw_command(&["config", "set", "channels.telegram.dmPolicy", "pairing"]).await- .stdout(Stdio::null())- .stderr(Stdio::null())- .spawn()- {- let _ = child.wait().await;- }-- // 4. Enable dangerouslyDisableDeviceAuth for Jan's Control UI client- // This allows Jan to connect without device pairing (Jan is trusted)- if let Ok(mut child) = openclaw_command(&["config", "set", "gateway.controlUi.dangerouslyDisableDeviceAuth", "true"]).await- .stdout(Stdio::null())- .stderr(Stdio::null())- .spawn()- {- let _ = child.wait().await;- }-- // 5. Set gateway.mode to "local" - required for gateway to start- if let Ok(mut child) = openclaw_command(&["config", "set", "gateway.mode", "local"]).await- .stdout(Stdio::null())- .stderr(Stdio::null())- .spawn()- {- let _ = child.wait().await;- }-- // NOTE: Gateway is NOT auto-started here. It is started by openclaw_start()- // via the sandbox abstraction (Docker, platform-native, or direct process).- // Auto-starting here would conflict with Docker sandbox mode.-- Ok(InstallResult {- success: true,- version,- error: None,- })-}--/// Generate the default OpenClaw configuration-fn generate_default_config(input: Option<OpenClawConfigInput>) -> OpenClawConfig {- let mut config = OpenClawConfig::default();-- if let Some(input) = input {- if let Some(port) = input.port {- config.gateway.port = port;- }- if let Some(bind) = input.bind {- config.gateway.bind = bind;- }- if let Some(base_url) = input.jan_base_url {- config.models.providers.jan.base_url = base_url;- }- if let Some(api_key) = input.jan_api_key {- if !api_key.is_empty() {- config.models.providers.jan.api_key = api_key;- }- }- }-- config-}--/// Jan's allowed origins for OpenClaw Gateway WebSocket connections-/// These origins allow Jan (Tauri app) to connect to the Gateway-const JAN_ALLOWED_ORIGINS: &[&str] = &[- "tauri://localhost",- "http://tauri.localhost",- "http://localhost",- "http://localhost:1420", // Tauri dev server- "http://127.0.0.1",-];--fn required_origins(gateway_port: u64) -> Vec<String> {- let mut origins: Vec<String> = JAN_ALLOWED_ORIGINS.iter().map(|s| s.to_string()).collect();- origins.push(format!("http://127.0.0.1:{}", gateway_port));- origins.push(format!("http://localhost:{}", gateway_port));- origins-}--/// Ensure Jan's origins are in the OpenClaw config's gateway.controlUi.allowedOrigins-/// This patches an existing config without overwriting other settings-/// Returns true if the config was modified, false if already correct-#[tauri::command]-pub async fn openclaw_ensure_jan_origin() -> Result<bool, String> {- log::debug!("Ensuring Jan's origin is in OpenClaw allowedOrigins");-- let config_path = get_openclaw_config_path()?;-- if !config_path.exists() {- // No config exists, it will be created with correct defaults when openclaw_configure is called- log::info!("No OpenClaw config exists yet, will be created with Jan origins");- return Ok(false);- }-- // Read and parse existing config as JSON Value to preserve all fields- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read OpenClaw config: {}", e))?;-- let mut config: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse OpenClaw config: {}", e))?;-- // Ensure gateway object exists- if config.get("gateway").is_none() {- config["gateway"] = serde_json::json!({});- }-- // Ensure gateway.controlUi object exists- if config["gateway"].get("controlUi").is_none() {- config["gateway"]["controlUi"] = serde_json::json!({});- }-- // Get or create allowedOrigins array- let allowed_origins = config["gateway"]["controlUi"]- .get("allowedOrigins")- .and_then(|v| v.as_array())- .cloned()- .unwrap_or_default();-- // Convert to a set of existing origins- let existing_origins: std::collections::HashSet<String> = allowed_origins- .iter()- .filter_map(|v| v.as_str())- .map(String::from)- .collect();-- // Check which Jan origins are missing- let mut modified = false;- let mut new_origins: Vec<serde_json::Value> = allowed_origins;-- let gateway_port = config- .pointer("/gateway/port")- .and_then(|v| v.as_u64())- .unwrap_or(super::OPENCLAW_PORT as u64);- for origin in required_origins(gateway_port) {- if !existing_origins.contains(&origin) {- new_origins.push(serde_json::json!(origin));- modified = true;- }- }-- // Also enable dangerouslyDisableDeviceAuth for local connections- // This simplifies the connection flow for non-tech users- // Security note: This is safe for loopback-only gateways (local use)- let disable_device_auth = config["gateway"]["controlUi"]- .get("dangerouslyDisableDeviceAuth")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- if !disable_device_auth {- config["gateway"]["controlUi"]["dangerouslyDisableDeviceAuth"] = serde_json::json!(true);- modified = true;- log::info!("Enabled dangerouslyDisableDeviceAuth for local connections");- }-- if modified {- // Update the config with new origins- config["gateway"]["controlUi"]["allowedOrigins"] = serde_json::Value::Array(new_origins);-- // Write back the config- let updated_json = serde_json::to_string_pretty(&config)- .map_err(|e| format!("Failed to serialize config: {}", e))?;-- std::fs::write(&config_path, updated_json)- .map_err(|e| format!("Failed to write config: {}", e))?;-- log::info!("OpenClaw config updated with Jan's allowed origins and device auth disabled");- } else {- log::debug!("Jan's config already correct");- }-- Ok(modified)-}--/// Back up `openclaw.json` before modifying it.-/// Keeps up to 3 timestamped backups, prunes older ones.-fn backup_openclaw_config(config_path: &std::path::Path) -> Result<(), String> {- if !config_path.exists() {- return Ok(());- }-- let timestamp = chrono::Local::now().format("%Y%m%dT%H%M%S");- let backup_name = format!(- "{}.bak.{}",- config_path.file_name().unwrap_or_default().to_string_lossy(),- timestamp- );- let backup_path = config_path.with_file_name(&backup_name);- std::fs::copy(config_path, &backup_path)- .map_err(|e| format!("Failed to backup config: {}", e))?;-- const MAX_BACKUPS: usize = 3;- if let Some(parent) = config_path.parent() {- let prefix = format!(- "{}.bak.",- config_path.file_name().unwrap_or_default().to_string_lossy()- );- if let Ok(entries) = std::fs::read_dir(parent) {- let mut backups: Vec<std::path::PathBuf> = entries- .filter_map(|e| e.ok())- .map(|e| e.path())- .filter(|p| {- p.file_name()- .map(|n| n.to_string_lossy().starts_with(&prefix))- .unwrap_or(false)- })- .collect();- backups.sort_by(|a, b| b.cmp(a));- for old in backups.into_iter().skip(MAX_BACKUPS) {- let _ = std::fs::remove_file(&old);- }- }- }-- Ok(())-}--/// Configure OpenClaw with the specified settings.-/// Selectively merges only Jan-managed gateway fields (mode, port, auth)-/// without destroying user-configured settings.-/// Strips known-invalid keys that would cause OpenClaw to reject the config.-#[tauri::command]-pub async fn openclaw_configure(config_input: Option<OpenClawConfigInput>) -> Result<OpenClawConfig, String> {- log::info!("Configuring OpenClaw");-- let config = generate_default_config(config_input);- let config_path = get_openclaw_config_path()?;-- let defaults: serde_json::Value = serde_json::to_value(&config)- .map_err(|e| format!("Failed to serialize config: {}", e))?;-- let mut merged = if config_path.exists() {- let existing_str = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read existing config: {}", e))?;- let mut existing: serde_json::Value = serde_json::from_str(&existing_str)- .unwrap_or_else(|_| serde_json::json!({}));-- backup_openclaw_config(&config_path)?;-- // Selectively merge only Jan-managed gateway fields, preserving user config- if let Some(gw_defaults) = defaults.get("gateway").and_then(|v| v.as_object()) {- if existing.get("gateway").is_none() {- existing["gateway"] = serde_json::Value::Object(gw_defaults.clone());- } else if let Some(gw_obj) = existing["gateway"].as_object_mut() {- gw_obj.entry("mode")- .or_insert_with(|| gw_defaults.get("mode").cloned()- .unwrap_or(serde_json::json!("local")));- gw_obj.entry("port")- .or_insert_with(|| gw_defaults.get("port").cloned()- .unwrap_or(serde_json::json!(super::OPENCLAW_PORT)));- gw_obj.entry("auth")- .or_insert_with(|| gw_defaults.get("auth").cloned()- .unwrap_or(serde_json::json!({"mode": "token"})));- // Enable the OpenAI-compatible HTTP API so Jan can send messages- // to the OpenClaw agent runtime via POST /v1/chat/completions- let http = gw_obj.entry("http")- .or_insert_with(|| serde_json::json!({}));- if let Some(http_obj) = http.as_object_mut() {- let endpoints = http_obj.entry("endpoints")- .or_insert_with(|| serde_json::json!({}));- if let Some(ep_obj) = endpoints.as_object_mut() {- let cc = ep_obj.entry("chatCompletions")- .or_insert_with(|| serde_json::json!({}));- if let Some(cc_obj) = cc.as_object_mut() {- cc_obj.entry("enabled")- .or_insert_with(|| serde_json::json!(true));- }- }- }- }- }- if let Some(models) = defaults.get("models") {- if existing.get("models").is_none() {- existing["models"] = models.clone();- } else if existing.pointer("/models/providers/jan").is_none() {- existing["models"]["providers"]["jan"] = models["providers"]["jan"].clone();- }- }- // Always update the jan provider apiKey when an explicit key was provided- // (i.e., the generated config has a non-default key from config_input.jan_api_key)- if config.models.providers.jan.api_key != DEFAULT_JAN_API_KEY {- existing["models"]["providers"]["jan"]["apiKey"] =- serde_json::json!(config.models.providers.jan.api_key);- }- // Always update the jan provider baseUrl so a stale port is never kept- existing["models"]["providers"]["jan"]["baseUrl"] =- serde_json::json!(config.models.providers.jan.base_url);- existing- } else {- defaults- };-- strip_invalid_config_keys(&mut merged);-- // Ensure gateway.auth.token exists when mode is "token".- // On Mac, `gateway install` auto-generates the token, but on Windows/Linux- // the child-process path (`openclaw gateway`) skips `gateway install`- // entirely, leaving the config without a token.- let auth_mode = merged- .pointer("/gateway/auth/mode")- .and_then(|v| v.as_str())- .unwrap_or("token");- let has_token = merged- .pointer("/gateway/auth/token")- .and_then(|v| v.as_str())- .map(|s| !s.is_empty())- .unwrap_or(false);- if auth_mode == "token" && !has_token {- let token = security::generate_access_token();- merged["gateway"]["auth"]["token"] = serde_json::json!(token);- }-- // Ensure controlUi settings so Jan can connect without device pairing.- // The openclaw_install step sets these via CLI, but on fresh installs- // the CLI commands may fail silently.- if merged.pointer("/gateway/controlUi").is_none() {- merged["gateway"]["controlUi"] = serde_json::json!({});- }- let has_disable_device_auth = merged- .pointer("/gateway/controlUi/dangerouslyDisableDeviceAuth")- .and_then(|v| v.as_bool())- .unwrap_or(false);- if !has_disable_device_auth {- merged["gateway"]["controlUi"]["dangerouslyDisableDeviceAuth"] = serde_json::json!(true);- }- // Ensure Jan's allowed origins for WebSocket connections- let existing_origins: std::collections::HashSet<String> = merged- .pointer("/gateway/controlUi/allowedOrigins")- .and_then(|v| v.as_array())- .map(|arr| arr.iter().filter_map(|v| v.as_str()).map(String::from).collect())- .unwrap_or_default();- let mut origins: Vec<serde_json::Value> = merged- .pointer("/gateway/controlUi/allowedOrigins")- .and_then(|v| v.as_array())- .cloned()- .unwrap_or_default();- let gateway_port = merged- .pointer("/gateway/port")- .and_then(|v| v.as_u64())- .unwrap_or(super::OPENCLAW_PORT as u64);- for origin in required_origins(gateway_port) {- if !existing_origins.contains(&origin) {- origins.push(serde_json::json!(origin));- }- }- merged["gateway"]["controlUi"]["allowedOrigins"] = serde_json::Value::Array(origins);-- let config_json = serde_json::to_string_pretty(&merged)- .map_err(|e| format!("Failed to serialize config: {}", e))?;-- std::fs::write(&config_path, config_json)- .map_err(|e| format!("Failed to write config file: {}", e))?;-- log::info!("OpenClaw configuration written to {:?}", config_path);-- // Ensure the agent directory has auth-profiles.json and that models.json- // carries the jan apiKey. Without these, agents fail with- // "No API key found for provider".- ensure_agent_auth_files()?;-- Ok(config)-}--/// Ensure the agent directory has the files OpenClaw's agent system needs:-/// 1. `auth-profiles.json` — the credential store (empty is fine).-/// 2. `models.json` — must have `apiKey` on the jan provider so the agent-/// can resolve credentials via `getCustomProviderApiKey`.-///-/// OpenClaw regenerates `models.json` from `openclaw.json` on gateway start,-/// but if the gateway is already running (hot-reload) the stale file is used.-/// We patch it directly so the fix takes effect immediately.-fn ensure_agent_auth_files() -> Result<(), String> {- let config_dir = get_openclaw_config_dir()?;- let agent_dir = config_dir.join("agents").join("main").join("agent");-- std::fs::create_dir_all(&agent_dir)- .map_err(|e| format!("Failed to create agent directory: {}", e))?;-- // 1. auth-profiles.json- let auth_path = agent_dir.join("auth-profiles.json");- if !auth_path.exists() {- let empty_store = serde_json::json!({- "version": 1,- "profiles": {}- });- let json = serde_json::to_string_pretty(&empty_store)- .map_err(|e| format!("Failed to serialize auth profiles: {}", e))?;- std::fs::write(&auth_path, json)- .map_err(|e| format!("Failed to write auth-profiles.json: {}", e))?;- log::info!("Created empty auth-profiles.json at {:?}", auth_path);- }-- // 2. Patch models.json — ensure jan provider has apiKey- let models_path = agent_dir.join("models.json");- if models_path.exists() {- let content = std::fs::read_to_string(&models_path)- .map_err(|e| format!("Failed to read models.json: {}", e))?;- if let Ok(mut models) = serde_json::from_str::<serde_json::Value>(&content) {- let needs_patch = models- .pointer("/providers/jan")- .map(|jan| jan.get("apiKey").and_then(|v| v.as_str()).unwrap_or("").is_empty())- .unwrap_or(false);-- if needs_patch {- models["providers"]["jan"]["apiKey"] = serde_json::json!(DEFAULT_JAN_API_KEY);- let json = serde_json::to_string_pretty(&models)- .map_err(|e| format!("Failed to serialize models.json: {}", e))?;- std::fs::write(&models_path, json)- .map_err(|e| format!("Failed to write models.json: {}", e))?;- log::info!("Patched models.json with jan apiKey");- }- }- }-- Ok(())-}--/// Sanitise an OpenClaw config value before writing it to disk.-/// 1. Strips known-invalid keys (OpenClaw uses strict Zod validation).-/// 2. Ensures required fields are present (e.g., gateway.mode = "local").-fn strip_invalid_config_keys(config: &mut serde_json::Value) {- // agents.defaults.systemPrompt is NOT a valid key (system prompts come from workspace files)- if let Some(defaults) = config.pointer_mut("/agents/defaults") {- if let Some(obj) = defaults.as_object_mut() {- if obj.remove("systemPrompt").is_some() {- log::info!("Stripped invalid key: agents.defaults.systemPrompt");- }- }- }-- // gateway.mode is REQUIRED — without it the gateway refuses to start.- // Ensure it is always present and defaults to "local".- if let Some(gw) = config.get_mut("gateway") {- if let Some(obj) = gw.as_object_mut() {- if !obj.contains_key("mode") {- obj.insert("mode".to_string(), serde_json::json!("local"));- log::info!("Added missing required key: gateway.mode = \"local\"");- }- }- }-}--/// Get the current OpenClaw configuration-#[tauri::command]-pub async fn openclaw_get_config() -> Result<OpenClawConfig, String> {- let config_path = get_openclaw_config_path()?;-- if !config_path.exists() {- // Return default config if no config exists- return Ok(OpenClawConfig::default());- }-- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read config file: {}", e))?;-- serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse config: {}", e))-}--/// Read the OpenClaw config file as a JSON Value.-/// Preserves all fields including unknown ones.-fn read_openclaw_config() -> Result<serde_json::Value, String> {- let config_path = get_openclaw_config_path()?;- let content = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read OpenClaw config: {}", e))?;- serde_json::from_str(&content)- .map_err(|e| format!("Failed to parse OpenClaw config: {}", e))-}--/// Write a JSON Value back to the OpenClaw config file.-/// Automatically sanitises the config (strip invalid keys, ensure required keys).-fn write_openclaw_config(config: &serde_json::Value) -> Result<(), String> {- let config_path = get_openclaw_config_path()?;- let mut sanitized = config.clone();- strip_invalid_config_keys(&mut sanitized);- let json = serde_json::to_string_pretty(&sanitized)- .map_err(|e| format!("Failed to serialize config: {}", e))?;- std::fs::write(&config_path, json)- .map_err(|e| format!("Failed to write config: {}", e))-}--/// Sync the selected model from Jan to OpenClaw-///-/// This updates OpenClaw's agent default model to match Jan's currently selected model.-/// Works for both Docker and direct process modes by writing directly to the config file.-#[tauri::command]-pub async fn openclaw_sync_model(- model_id: String,- provider: Option<String>,- model_name: Option<String>,-) -> Result<(), String> {- log::info!("Syncing model to OpenClaw: {} (provider: {:?})", model_id, provider);-- let display_name = model_name.unwrap_or_else(|| model_id.clone());-- // OpenClaw models.providers.jan.models expects an array of objects with- // at minimum { id, name }. The id must be the plain model name — OpenClaw- // prepends the provider key ("jan/") when resolving references.- // Context window is declared as 131072 for all models — the actual limit- // is enforced by the inference engine, not this metadata.- let model_def = serde_json::json!({- "id": model_id,- "name": display_name,- "input": ["text"],- "reasoning": false,- "contextWindow": 131072,- "maxTokens": 16384,- "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }- });-- // Read, modify, write the config directly (works for both Docker and direct process)- let mut config = read_openclaw_config()?;-- // Ensure models.providers.jan exists- if config.pointer("/models/providers/jan").is_none() {- let current_base_url = config- .pointer("/models/providers/jan/baseUrl")- .and_then(|v| v.as_str())- .unwrap_or(DEFAULT_JAN_BASE_URL);-- config["models"]["providers"]["jan"] = serde_json::json!({- "baseUrl": current_base_url,- "api": DEFAULT_JAN_API_TYPE,- "apiKey": DEFAULT_JAN_API_KEY,- "models": [model_def]- });- } else {- // Add model to existing list if not already present- let models = config- .pointer_mut("/models/providers/jan/models")- .and_then(|v| v.as_array_mut());-- if let Some(models) = models {- let model_exists = models.iter().any(|m| {- m.get("id").and_then(|v| v.as_str()) == Some(&model_id)- });- if !model_exists {- models.push(model_def);- }- }- }-- // Default model reference must use "jan/<model_id>" so OpenClaw resolves- // it under the "jan" provider.- let qualified_id = format!("jan/{}", model_id);- config["agents"]["defaults"]["model"]["primary"] = serde_json::json!(qualified_id);-- write_openclaw_config(&config)?;-- log::info!("Successfully synced model '{}' to OpenClaw config (default: {})", model_id, qualified_id);- Ok(())-}--/// Bulk sync all models from Jan to OpenClaw-///-/// This replaces the entire model list in the 'jan' provider with the full-/// catalog from Jan's model provider store. Called when Remote Access starts-/// so that OpenClaw knows about all available models without requiring the-/// user to switch models in the dropdown.-#[tauri::command]-pub async fn openclaw_sync_all_models(- models: Vec<ModelSyncEntry>,- default_model_id: Option<String>,-) -> Result<BulkSyncResult, String> {- log::info!("Bulk syncing {} models to OpenClaw", models.len());-- if models.is_empty() {- log::warn!("No models to sync");- return Ok(BulkSyncResult {- synced_count: 0,- default_model: None,- });- }-- // Build model definition objects matching the CLI's rich format so OpenClaw- // can make optimal decisions about context, output limits, and cost.- // Use the actual context window from Jan's model settings when available,- // falling back to 131072 (128K) as a reasonable default.- let model_defs: Vec<serde_json::Value> = models- .iter()- .map(|entry| {- let ctx = entry.context_window.unwrap_or(131072);- serde_json::json!({- "id": entry.model_id,- "name": entry.display_name,- "input": ["text"],- "reasoning": false,- "contextWindow": ctx,- "maxTokens": 16384,- "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }- })- })- .collect();-- let synced_count = model_defs.len() as u32;-- // Read, modify, write the config directly (works for both Docker and direct process)- let mut config = read_openclaw_config()?;-- // Preserve the current baseUrl (may be Docker or localhost depending on sandbox)- let current_base_url = config- .pointer("/models/providers/jan/baseUrl")- .and_then(|v| v.as_str())- .unwrap_or(DEFAULT_JAN_BASE_URL)- .to_string();-- // Preserve the current apiKey (may have been customised by the user)- let current_api_key = config- .pointer("/models/providers/jan/apiKey")- .and_then(|v| v.as_str())- .unwrap_or(DEFAULT_JAN_API_KEY)- .to_string();-- // Build the full jan provider config with all models as objects- config["models"]["providers"]["jan"] = serde_json::json!({- "baseUrl": current_base_url,- "api": DEFAULT_JAN_API_TYPE,- "apiKey": current_api_key,- "models": model_defs- });-- // Default model must be "jan/<model_id>" so OpenClaw resolves under the jan provider- let set_default = if let Some(ref model_id) = default_model_id {- let qualified = format!("jan/{}", model_id);- config["agents"]["defaults"]["model"]["primary"] = serde_json::json!(qualified);- Some(qualified)- } else {- None- };-- write_openclaw_config(&config)?;-- // Also patch the agent-level models.json so the running gateway picks up- // the apiKey immediately (without needing a full restart).- ensure_agent_auth_files()?;-- log::info!("Successfully bulk synced {} models to OpenClaw", synced_count);- Ok(BulkSyncResult {- synced_count,- default_model: set_default,- })-}--/// Get the currently configured model in OpenClaw-#[tauri::command]-pub async fn openclaw_get_model() -> Result<String, String> {- log::info!("Getting OpenClaw model");-- let config = read_openclaw_config()?;- let model = config- .pointer("/agents/defaults/model/primary")- .and_then(|v| v.as_str())- .unwrap_or(DEFAULT_MODEL_ID)- .to_string();-- // Strip the "jan/" provider prefix so the frontend gets the plain model ID- // that matches Jan's internal model identifiers.- let model = model.strip_prefix("jan/").unwrap_or(&model).to_string();-- Ok(model)-}--/// Check if OpenClaw gateway is responding on the expected port-async fn check_gateway_responding() -> bool {- // Use TCP connection check - OpenClaw serves a dashboard UI, not a JSON health endpoint- match tokio::net::TcpStream::connect(format!("127.0.0.1:{}", OPENCLAW_PORT)).await {- Ok(_) => {- log::debug!("OpenClaw gateway is responding on port {}", OPENCLAW_PORT);- true- }- Err(_) => false,- }-}--/// Wait for the gateway to become responsive, polling every 500ms up to `max_wait_secs`.-/// Returns true if the gateway responded before the deadline, false otherwise.-async fn wait_for_gateway_ready(max_wait_secs: u64) -> bool {- let deadline = tokio::time::Instant::now() + tokio::time::Duration::from_secs(max_wait_secs);- // Always give the process at least 1s to bind the port- tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;- loop {- if check_gateway_responding().await {- return true;- }- if tokio::time::Instant::now() >= deadline {- return false;- }- tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;- }-}--/// 1-click enable: orchestrates dependency check, install, configure, and start-#[tauri::command]-pub async fn openclaw_enable(- app: tauri::AppHandle,- config_input: Option<OpenClawConfigInput>,- state: State<'_, OpenClawState>,-) -> Result<EnableResult, String> {- use tauri::Emitter;- log::info!("Starting 1-click OpenClaw enable flow");-- let mut steps_completed: Vec<EnableStep> = vec![];- let emit = |step: &str, progress: u32, message: &str, sandbox: Option<&str>| {- let _ = app.emit(- "openclaw-enable-progress",- EnableProgressEvent {- step: step.to_string(),- progress,- message: message.to_string(),- sandbox_info: sandbox.map(|s| s.to_string()),- },- );- };-- // Step 1: Detect sandbox type FIRST (before Node.js check)- // This is important because for Docker, Node.js runs inside container- let detected = crate::core::openclaw::sandbox::detect_sandbox().await;- let sandbox_name = detected.name().to_string();- let tier = detected.isolation_tier();- let is_docker = sandbox_name == "Docker";- let mut sandbox_info = Some(match tier {- crate::core::openclaw::sandbox::IsolationTier::None => "None (direct process)".to_string(),- _ => sandbox_name.clone(),- });- log::info!("Detected sandbox: {} (tier: {:?})", sandbox_name, tier);-- set_docker_mode(is_docker);-- // Step 1b: Check JS runtime dependencies (skip for Docker - runs inside container)- emit("checking_dependencies", 10, "Checking runtime installation...", sandbox_info.as_deref());- steps_completed.push(EnableStep::CheckingDependencies);-- let _node_check = if is_docker {- // For Docker, runtime runs inside container - no host check needed- log::info!("Docker sandbox detected - runtime runs inside container, skipping host check");- NodeCheckResult {- installed: true, // Pretend it's installed to allow flow to continue- version: None,- major_version: None,- meets_requirements: true,- error: None,- }- } else {- // For direct process, a JS runtime (bundled Bun or Node.js) must be available- let check = openclaw_check_dependencies().await;- if !check.installed {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::RuntimeNotFound,- message: "Could not find a JavaScript runtime. Bundled Bun was not found, and Node.js 22+ is not installed.".to_string(),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try detecting the runtime again.".to_string(),- }],- })- .unwrap_or_else(|_| "JavaScript runtime not found".to_string()));- }- if !check.meets_requirements {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::RuntimeVersionTooLow,- message: format!(- "A compatible JavaScript runtime is required. Found: {}",- check.version.as_deref().unwrap_or("unknown")- ),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try detecting the runtime again.".to_string(),- }],- })- .unwrap_or_else(|_| "JavaScript runtime version too low".to_string()));- }- check- };-- // Store detected sandbox in state- {- let mut sandbox_guard = state.sandbox.lock().await;- *sandbox_guard = Some(detected);- }-- // Step 2: Check if OpenClaw is already installed- emit("checking_installation", 25, "Checking OpenClaw installation...", sandbox_info.as_deref());- steps_completed.push(EnableStep::CheckingInstallation);-- let already_installed = if is_docker {- let docker_installed = crate::core::openclaw::sandbox_docker::DockerSandbox::is_installed().await;- let docker_exists = docker_installed == Some(true);- let image_ready = if docker_exists {- crate::core::openclaw::sandbox_docker::DockerSandbox::is_image_available().await- } else {- false- };- log::info!("Installation check: docker_container={}, image_ready={}", docker_exists, image_ready);-- if image_ready {- emit("already_installed", 40, "OpenClaw container exists in Docker.", sandbox_info.as_deref());- }- image_ready- } else {- let pkg_version = check_openclaw_installed().await.ok().flatten();- let up_to_date = match &pkg_version {- Some(v) => !needs_upgrade(v, OPENCLAW_VERSION),- None => false,- };- log::info!("Installation check: version={:?}, up_to_date={}", pkg_version, up_to_date);- up_to_date- };-- // Step 3: Install if needed- if !already_installed {- if is_docker {- // Docker path: pull the image (the actual container is created in openclaw_start)- emit("installing", 40, "Pulling OpenClaw Docker image...", sandbox_info.as_deref());- steps_completed.push(EnableStep::Installing);-- // Pull Docker image with progress events- match crate::core::openclaw::sandbox_docker::DockerSandbox::pull_image_if_needed_with_progress(- &app,- sandbox_info.as_deref(),- ).await {- Ok(()) => {- log::info!("Docker image pulled successfully");- }- Err(e) => {- // Docker image pull failed (e.g., image not published yet, auth error, network)- // Fall back to direct process mode with npm install- log::warn!("Docker image pull failed: {}. Falling back to direct process.", e);- emit("installing", 42, "Docker image unavailable, falling back to direct install...", sandbox_info.as_deref());-- sandbox_info = Some("None (direct process)".to_string());-- // Replace sandbox in state with DirectProcessSandbox- {- let mut sandbox_guard = state.sandbox.lock().await;- *sandbox_guard = Some(Box::new(- crate::core::openclaw::sandbox_direct::DirectProcessSandbox,- ));- }-- // Check runtime (bundled Bun or Node.js, required for direct process)- let node_check = openclaw_check_dependencies().await;- if !node_check.installed {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::RuntimeNotFound,- message: format!(- "Docker image unavailable and no JavaScript runtime found. \- Original error: {}. Bundled Bun was not found and Node.js 22+ is not installed.",- e- ),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try detecting the runtime again.".to_string(),- }],- })- .unwrap_or_else(|_| "No JavaScript runtime found".to_string()));- }- if !node_check.meets_requirements {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::RuntimeVersionTooLow,- message: format!(- "Docker image unavailable and runtime version too low. \- Original error: {}. Bun 1.0+ or Node.js 22+ required.",- e- ),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try detecting the runtime again.".to_string(),- }],- })- .unwrap_or_else(|_| "Runtime version too low".to_string()));- }-- // Now install via bun/npm- emit("installing", 45, "Installing OpenClaw...", sandbox_info.as_deref());- let install_result = openclaw_install().await?;- if !install_result.success {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::InstallFailed,- message: install_result- .error- .unwrap_or_else(|| "npm install failed".to_string()),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try installing OpenClaw again.".to_string(),- }],- })- .unwrap_or_else(|_| "Installation failed".to_string()));- }- }- }- } else {- // Non-Docker path: npm install- emit("installing", 40, "Installing OpenClaw (this may take a moment)...", sandbox_info.as_deref());- steps_completed.push(EnableStep::Installing);- let install_result = openclaw_install().await?;- if !install_result.success {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::InstallFailed,- message: install_result- .error- .unwrap_or_else(|| "npm install failed".to_string()),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try installing OpenClaw again.".to_string(),- }],- })- .unwrap_or_else(|_| "Installation failed".to_string()));- }- }- } else {- emit("already_installed", 40, "OpenClaw is already installed.", sandbox_info.as_deref());- }-- // Step 4: Configure- emit("configuring", 60, "Configuring OpenClaw...", sandbox_info.as_deref());- steps_completed.push(EnableStep::Configuring);- openclaw_configure(config_input).await.map_err(|e| {- serde_json::to_string(&EnableError {- code: EnableErrorCode::ConfigWriteFailed,- message: format!("Failed to write configuration: {}", e),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try configuring again.".to_string(),- }],- })- .unwrap_or(e)- })?;-- // Step 5: Start the gateway (with doctor --fix auto-recovery for non-Docker)- emit("starting", 75, "Starting OpenClaw gateway...", sandbox_info.as_deref());- steps_completed.push(EnableStep::Starting);-- // Phase A: attempt start + wait-for-ready- let mut doctor_already_ran = false;- let start_err = match openclaw_start(state.clone()).await {- Ok(()) => None,- Err(e) => Some(e),- };-- // Port conflicts cannot be fixed by doctor — bail immediately- if let Some(ref e) = start_err {- if e.contains("Port") || e.contains("port") {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::PortInUse,- message: e.clone(),- recovery: vec![RecoveryOption {- label: "Use different port".to_string(),- action: RecoveryAction::UseDifferentPort {- port: OPENCLAW_PORT + 1,- },- description: format!("Try port {} instead.", OPENCLAW_PORT + 1),- }],- })- .unwrap_or_else(|_| e.clone()));- }- }-- let gateway_responsive = if start_err.is_none() {- let gateway_wait = if is_docker { 60 } else { 15 };- wait_for_gateway_ready(gateway_wait).await- } else {- false- };-- if !gateway_responsive && !is_docker {- // Non-Docker: run doctor --fix and retry before giving up- let original_err = start_err.unwrap_or_else(|| "Gateway did not become responsive after starting.".to_string());- log::warn!("Gateway start/wait failed: {}. Running doctor --fix.", original_err);- emit("starting", 78, "Auto-fixing configuration and retrying...", sandbox_info.as_deref());-- let _ = run_doctor_fix().await;- doctor_already_ran = true;- let _ = restart_gateway_cli().await;-- if !wait_for_gateway_ready(15).await {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::GatewayStartFailed,- message: format!("Gateway did not recover after auto-fix: {}", original_err),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try the setup again.".to_string(),- }],- })- .unwrap_or_else(|_| original_err));- }- } else if !gateway_responsive {- // Docker: start/wait failed — no doctor, just fail- let original_err = start_err.unwrap_or_else(|| "Gateway did not become responsive after starting.".to_string());- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::GatewayStartFailed,- message: original_err.clone(),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try the setup again.".to_string(),- }],- })- .unwrap_or_else(|_| original_err));- }-- // Phase B: validate gateway auth- emit("validating", 85, "Validating configuration...", sandbox_info.as_deref());- steps_completed.push(EnableStep::ValidatingConfig);-- if is_docker {- // Docker: port binds early but app layer may still be initialising.- // Poll validate_gateway_auth with retries instead of restarting.- let deadline = tokio::time::Instant::now()- + tokio::time::Duration::from_secs(90);- let mut last_err = String::new();- loop {- match validate_gateway_auth().await {- Ok(()) => {- last_err.clear();- break;- }- Err(e) => {- last_err = e;- if tokio::time::Instant::now() >= deadline {- break;- }- tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;- }- }- }- if !last_err.is_empty() {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::ValidationFailed,- message: format!("Gateway validation timed out: {}", last_err),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try the setup again.".to_string(),- }],- })- .unwrap_or_else(|_| last_err));- }- } else {- match validate_gateway_auth().await {- Ok(()) => {}- Err(e) => {- if doctor_already_ran {- // Doctor already ran during start/wait retry — don't retry again- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::ValidationFailed,- message: format!("Validation failed after auto-fix: {}", e),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try the setup again.".to_string(),- }],- })- .unwrap_or_else(|_| e));- }-- // Doctor hasn't run yet (start+wait passed on first try) — try it now- log::warn!("Gateway validation failed: {}. Running doctor --fix.", e);- let _ = run_doctor_fix().await;- let _ = restart_gateway_cli().await;-- if !wait_for_gateway_ready(15).await {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::ValidationFailed,- message: format!("Gateway did not recover after auto-fix: {}", e),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try the setup again.".to_string(),- }],- })- .unwrap_or_else(|_| e.clone()));- }-- if let Err(retry_err) = validate_gateway_auth().await {- return Err(serde_json::to_string(&EnableError {- code: EnableErrorCode::ValidationFailed,- message: format!("Validation failed after auto-fix: {}", retry_err),- recovery: vec![RecoveryOption {- label: "Retry".to_string(),- action: RecoveryAction::Retry,- description: "Try the setup again.".to_string(),- }],- })- .unwrap_or_else(|_| retry_err));- }- }- }- }-- // Get final status- emit("complete", 100, "OpenClaw is ready!", sandbox_info.as_deref());- let final_status = openclaw_status(state).await?;-- Ok(EnableResult {- success: true,- already_installed,- steps_completed,- status: final_status,- })-}--/// Start the OpenClaw gateway via the sandbox abstraction.-#[tauri::command]-pub async fn openclaw_start(state: State<'_, OpenClawState>) -> Result<(), String> {- log::info!("Starting OpenClaw gateway");-- let is_docker = {- let mut sandbox_guard = state.sandbox.lock().await;- if sandbox_guard.is_none() {- let detected = crate::core::openclaw::sandbox::detect_sandbox().await;- let is_docker = detected.name() == "Docker";- log::info!("Detected sandbox: {} (tier: {})", detected.name(), detected.isolation_tier());- *sandbox_guard = Some(detected);- is_docker- } else {- sandbox_guard.as_ref().unwrap().name() == "Docker"- }- };-- set_docker_mode(is_docker);-- // Step 2: Port check — behavior depends on sandbox type- if is_docker {- // For Docker: if port is in use, something else is on it (host process, old container).- // We need to ensure the Docker container is running, not just that the port responds.- // Check if our Docker container is already running.- let docker_status = {- let sandbox_guard = state.sandbox.lock().await;- if let Some(sandbox) = sandbox_guard.as_ref() {- let dummy_handle = crate::core::openclaw::sandbox::SandboxHandle::Named(- "jan-openclaw".to_string(),- );- sandbox.status(&dummy_handle).await.ok()- } else {- None- }- };-- if docker_status == Some(crate::core::openclaw::sandbox::SandboxStatus::Running) {- let _ = openclaw_ensure_jan_origin().await;- return Ok(());- }-- // Stop any running direct-process gateway to avoid port/bot conflicts- stop_other_sandbox_instance(false).await;- } else {- // Stop any running Docker container to avoid port/bot conflicts- stop_other_sandbox_instance(true).await;-- if check_gateway_responding().await {- let _ = openclaw_ensure_jan_origin().await;- return Ok(());- }-- let port_check = openclaw_check_port(OPENCLAW_PORT).await;- if !port_check.available {- return Err(format!("Port {} is already in use by another application", OPENCLAW_PORT));- }- }-- // Ensure config exists- let config_path = get_openclaw_config_path()?;- if !config_path.exists() {- openclaw_configure(None).await?;- } else {- openclaw_ensure_jan_origin().await?;- }-- // Runtime check (skip for Docker — runs inside container)- if !is_docker {- let node_check = openclaw_check_dependencies().await;- if !node_check.installed || !node_check.meets_requirements {- return Err(node_check.error.unwrap_or_else(|| "JavaScript runtime requirements not met (Bun or Node.js 22+)".to_string()));- }- }-- // Build config and start via lifecycle module- let config = crate::core::openclaw::lifecycle::build_sandbox_config(- &crate::core::openclaw::constants::DEFAULT_JAN_BASE_URL,- )?;-- let sandbox_guard = state.sandbox.lock().await;- let sandbox = sandbox_guard.as_ref().ok_or("Sandbox not initialized")?;- crate::core::openclaw::lifecycle::start_openclaw(sandbox.as_ref(), &config, &state).await-}--/// Stop the OpenClaw gateway via the sandbox abstraction.-#[tauri::command]-pub async fn openclaw_stop(state: State<'_, OpenClawState>) -> Result<(), String> {- log::info!("Stopping OpenClaw gateway");-- let sandbox_guard = state.sandbox.lock().await;-- let is_docker = sandbox_guard.as_ref().map(|s| s.name() == "Docker").unwrap_or(false);- set_docker_mode(is_docker);-- match sandbox_guard.as_ref() {- Some(sandbox) => {- crate::core::openclaw::lifecycle::stop_openclaw(sandbox.as_ref(), &state).await- }- None => {- let direct = crate::core::openclaw::sandbox_direct::DirectProcessSandbox;- let mut handle = crate::core::openclaw::sandbox::SandboxHandle::Named("direct-process".to_string());- direct.stop(&mut handle).await- }- }-}--/// Lightweight gateway reachability check (TCP only, no HTTP).-/// Used by the frontend before sending agent-mode chat requests.-#[tauri::command]-pub async fn openclaw_check_gateway() -> bool {- check_gateway_responding().await-}--/// Get the current OpenClaw status, including sandbox information.-#[tauri::command]-pub async fn openclaw_status(state: State<'_, OpenClawState>) -> Result<OpenClawStatus, String> {- log::debug!("Getting OpenClaw status");-- let running = check_gateway_responding().await;-- // 1. Detect sandbox first — environment may change between checks- // (e.g. Docker Desktop started/stopped since last status call)- let is_docker_sandbox = {- let mut sandbox_guard = state.sandbox.lock().await;- let mut mode = state.sandbox_mode.lock().await;-- if let crate::core::openclaw::sandbox::SandboxMode::Active { .. } = &*mode {- if !running {- *mode = crate::core::openclaw::sandbox::SandboxMode::Inactive;- }- }-- if !running || sandbox_guard.is_none() {- *sandbox_guard = Some(crate::core::openclaw::sandbox::detect_sandbox().await);- }-- sandbox_guard.as_ref().map(|s| s.name() == "Docker").unwrap_or(false)- };-- set_docker_mode(is_docker_sandbox);-- // 2. Check installation status using the detected sandbox type- let (openclaw_version, is_installed, runtime_version) = if is_docker_sandbox {- let version = check_openclaw_version_docker().await;- let installed = crate::core::openclaw::sandbox_docker::DockerSandbox::is_image_available().await;- let runtime_ver = if running {- check_node_version_docker().await- } else {- None- };- (version, installed, runtime_ver)- } else {- let version = match check_openclaw_installed().await {- Ok(v) => v,- Err(_) => None,- };- let installed = version.is_some();- let runtime_check = openclaw_check_dependencies().await;- (version, installed, runtime_check.version)- };-- let port_check = openclaw_check_port(OPENCLAW_PORT).await;-- // 3. Read sandbox info for response- let (sandbox_type, isolation_tier) = {- let sandbox_guard = state.sandbox.lock().await;- match &*sandbox_guard {- Some(sandbox) => (- Some(sandbox.name().to_string()),- Some(sandbox.isolation_tier().to_string()),- ),- None => (None, None),- }- };-- Ok(OpenClawStatus {- installed: is_installed,- running,- runtime_version,- openclaw_version,- port_available: port_check.available,- error: None,- sandbox_type,- isolation_tier,- })-}--/// Restart the OpenClaw gateway. Blocks until the gateway is responsive.-#[tauri::command]-pub async fn openclaw_restart(state: State<'_, OpenClawState>) -> Result<(), String> {- openclaw_stop(state.clone()).await?;- tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;- openclaw_start(state).await?;-- let max_wait = if is_docker_container_running().await { 60 } else { 15 };- if !wait_for_gateway_ready(max_wait).await {- return Err("Gateway did not become responsive after restart".to_string());- }-- Ok(())-}--/// Get the OpenClaw configuration directory path-#[tauri::command]-pub fn openclaw_get_config_dir() -> Result<String, String> {- let path = get_openclaw_config_dir()?;- Ok(path.to_string_lossy().to_string())-}--/// Telegram bot token validation result-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TelegramTokenValidation {- /// Whether the token is valid- pub valid: bool,- /// Bot username if valid- pub bot_username: Option<String>,- /// Bot name if valid- pub bot_name: Option<String>,- /// Error message if invalid- pub error: Option<String>,-}--/// Telegram channel configuration-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TelegramConfig {- /// Bot token- pub bot_token: String,- /// Bot username- pub bot_username: Option<String>,- /// Whether the channel is connected- pub connected: bool,- /// Pairing code (if not yet paired)- pub pairing_code: Option<String>,- /// Number of paired users- pub paired_users: u32,-}--/// Validate a Telegram bot token by calling the Telegram Bot API.-/// Retries up to 3 times on transient connection errors.-#[tauri::command]-pub async fn telegram_validate_token(token: String) -> TelegramTokenValidation {- if token.len() < 30 || !token.contains(':') {- return TelegramTokenValidation {- valid: false,- bot_username: None,- bot_name: None,- error: Some("Invalid token format. Telegram tokens should look like: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz".to_string()),- };- }-- let url = format!("https://api.telegram.org/bot{}/getMe", token);-- let client = match reqwest::Client::builder()- .timeout(std::time::Duration::from_secs(15))- .connect_timeout(std::time::Duration::from_secs(10))- .build()- {- Ok(c) => c,- Err(e) => {- return TelegramTokenValidation {- valid: false,- bot_username: None,- bot_name: None,- error: Some(format!("Failed to create HTTP client: {}", e)),- };- }- };-- const MAX_RETRIES: u32 = 3;- let mut last_err = String::new();-- for attempt in 0..MAX_RETRIES {- if attempt > 0 {- tokio::time::sleep(std::time::Duration::from_millis(500 * u64::from(attempt))).await;- }-- match client.get(&url).send().await {- Ok(response) => {- if response.status().is_success() {- match response.json::<serde_json::Value>().await {- Ok(data) => {- if data.get("ok").and_then(|v| v.as_bool()).unwrap_or(false) {- let result = data.get("result");- let username = result.and_then(|r| r.get("username")).and_then(|v| v.as_str()).map(String::from);- let name = result.and_then(|r| r.get("first_name")).and_then(|v| v.as_str()).map(String::from);-- return TelegramTokenValidation {- valid: true,- bot_username: username,- bot_name: name,- error: None,- };- } else {- let description = data.get("description").and_then(|v| v.as_str()).unwrap_or("Unknown error");- return TelegramTokenValidation {- valid: false,- bot_username: None,- bot_name: None,- error: Some(format!("Token validation failed: {}", description)),- };- }- }- Err(e) => {- return TelegramTokenValidation {- valid: false,- bot_username: None,- bot_name: None,- error: Some(format!("Failed to parse API response: {}", e)),- };- }- }- } else {- return TelegramTokenValidation {- valid: false,- bot_username: None,- bot_name: None,- error: Some(format!("API returned error: {}", response.status())),- };- }- }- Err(e) => {- last_err = format!("{}", e);- let is_transient = e.is_connect() || e.is_timeout() || e.is_request();- if !is_transient {- break;- }- log::warn!("Telegram API connection error (attempt {}): {}", attempt + 1, e);- }- }- }-- TelegramTokenValidation {- valid: false,- bot_username: None,- bot_name: None,- error: Some(format!(- "Failed to connect to Telegram API after {} attempts: {}",- MAX_RETRIES, last_err- )),- }-}--/// Enable a channel plugin in OpenClaw.-/// In Docker mode, writes directly to the config file to avoid CLI commands-/// that restart the gateway (killing the container's PID 1).-async fn enable_channel_plugin(channel: &str) -> Result<(), String> {- log::info!("Enabling {} plugin", channel);-- if is_docker_container_running().await {- let mut config = read_openclaw_config()?;-- // Schema: plugins.entries.<channel>.enabled (not plugins.<channel>)- let plugins = config- .as_object_mut()- .ok_or("Config is not an object")?- .entry("plugins")- .or_insert_with(|| serde_json::json!({}));- let plugins_obj = plugins- .as_object_mut()- .ok_or("plugins is not an object")?;- let entries = plugins_obj- .entry("entries")- .or_insert_with(|| serde_json::json!({}));- let entries_obj = entries- .as_object_mut()- .ok_or("plugins.entries is not an object")?;- entries_obj.insert(- channel.to_string(),- serde_json::json!({ "enabled": true }),- );-- write_openclaw_config(&config)?;- return Ok(());- }-- let enable_output = openclaw_command(&["plugins", "enable", channel]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw plugins enable: {}", e))?;-- let stderr = String::from_utf8_lossy(&enable_output.stderr);- let stdout = String::from_utf8_lossy(&enable_output.stdout);- if !enable_output.status.success() {- let combined = format!("{}{}", stdout, stderr);- // Ignore "already enabled" type messages- if !combined.contains("already") && !combined.contains("Enabled") {- return Err(format!("Failed to enable {} plugin: {}", channel, combined));- }- }-- Ok(())-}--/// Configure Telegram channel with the bot token.-/// In Docker mode, writes config directly + restarts the container.-#[tauri::command]-pub async fn telegram_configure(token: String) -> Result<TelegramConfig, String> {- log::info!("Configuring Telegram channel");-- let validation = telegram_validate_token(token.clone()).await;- if !validation.valid {- return Err(validation.error.unwrap_or_else(|| "Invalid token".to_string()));- }-- ensure_gateway_bind_lan().await;-- enable_channel_plugin("telegram").await?;-- if is_docker_container_running().await {- let mut config = read_openclaw_config()?;-- // Schema: botToken, enabled, dmPolicy, groupPolicy, streaming- let channels = config- .as_object_mut()- .ok_or("Config is not an object")?- .entry("channels")- .or_insert_with(|| serde_json::json!({}));- let channels_obj = channels- .as_object_mut()- .ok_or("channels is not an object")?;- channels_obj.insert("telegram".to_string(), serde_json::json!({- "botToken": token,- "enabled": true,- "dmPolicy": "pairing",- "groupPolicy": "allowlist",- "streaming": "off"- }));-- // Ensure pairing credentials file exists- let config_dir = get_openclaw_config_dir()?;- let creds_dir = config_dir.join("credentials");- std::fs::create_dir_all(&creds_dir)- .map_err(|e| format!("Failed to create credentials dir: {}", e))?;- let pairing_path = creds_dir.join("telegram-pairing.json");- if !pairing_path.exists() {- std::fs::write(- &pairing_path,- serde_json::to_string_pretty(&serde_json::json!({- "requests": [],- "version": 1- })).unwrap(),- )- .map_err(|e| format!("Failed to write telegram-pairing.json: {}", e))?;- }-- write_openclaw_config(&config)?;- } else {- let add_output = openclaw_command(&[- "channels",- "add",- "--channel", "telegram",- "--token", &token,- "--account", "default",- ]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw channels add: {}", e))?;-- let add_stderr = String::from_utf8_lossy(&add_output.stderr);- let add_stdout = String::from_utf8_lossy(&add_output.stdout);-- if !add_output.status.success() {- let combined = format!("{}{}", add_stdout, add_stderr);- if !combined.contains("already exists") && !combined.contains("updated") && !combined.contains("Added") {- return Err(format!(- "Failed to add Telegram channel: {}",- if !add_stderr.is_empty() { add_stderr.to_string() } else { add_stdout.to_string() }- ));- }- }- }-- // Clear stale pending pairing codes from the credentials file.- // This ensures the 3-code cap is reset so the user can get a fresh code- // when they type /start in Telegram.- {- let config_dir = get_openclaw_config_dir()?;- let pairing_path = config_dir.join("credentials").join("telegram-pairing.json");- let creds_dir = config_dir.join("credentials");- std::fs::create_dir_all(&creds_dir).ok();- let empty = serde_json::json!({ "version": 1, "requests": [] });- std::fs::write(&pairing_path, serde_json::to_string_pretty(&empty).unwrap())- .map_err(|e| format!("Failed to clear pairing state: {}", e))?;- log::info!("Reset pairing state for fresh code generation");- }-- // Restart gateway so it picks up both the new channel config and the- // clean pairing state. Use readiness polling instead of a fixed sleep.- if check_gateway_responding().await {- log::info!("Restarting gateway to apply Telegram config and pairing state");- let _ = restart_gateway_cli().await;- if !wait_for_gateway_ready(10).await {- log::warn!("Gateway did not become responsive after Telegram configure restart");- }- }-- // Store in local config for Jan's reference- let telegram_settings = serde_json::json!({- "enabled": true,- "bot_token": token,- "bot_username": validation.bot_username,- "connected": true,- });-- let config_dir = get_openclaw_config_dir()?;- let telegram_config_path = config_dir.join("telegram.json");-- std::fs::write(&telegram_config_path, serde_json::to_string_pretty(&telegram_settings).unwrap())- .map_err(|e| format!("Failed to save Telegram config: {}", e))?;-- log::info!("Telegram configured successfully via OpenClaw");-- Ok(TelegramConfig {- bot_token: token,- bot_username: validation.bot_username,- connected: true, // Channel is added and connected- pairing_code: None,- paired_users: 0,- })-}--/// Get current Telegram configuration.-///-/// Reads the local `telegram.json` reference file and reconciles it with the-/// live gateway state (if running) and the main `openclaw.json` config.-/// This ensures the UI shows the correct status regardless of whether the-/// channel was originally configured in Docker mode or direct process mode.-#[tauri::command]-pub async fn telegram_get_config() -> Result<TelegramConfig, String> {- let config_dir = get_openclaw_config_dir()?;- let telegram_config_path = config_dir.join("telegram.json");-- // Start with local file data (if it exists)- let mut bot_token = String::new();- let mut bot_username: Option<String> = None;- let mut connected = false;- let mut paired_users: u32 = 0;-- if telegram_config_path.exists() {- if let Ok(config_json) = std::fs::read_to_string(&telegram_config_path) {- if let Ok(settings) = serde_json::from_str::<serde_json::Value>(&config_json) {- bot_token = settings.get("bot_token").and_then(|v| v.as_str()).unwrap_or("").to_string();- bot_username = settings.get("bot_username").and_then(|v| v.as_str()).map(String::from);- connected = settings.get("connected").and_then(|v| v.as_bool()).unwrap_or(false);- paired_users = settings.get("paired_users").and_then(|v| v.as_u64()).unwrap_or(0) as u32;- }- }- }-- // If no local file, try to recover from openclaw.json (read-only — never- // write back here; only explicit user actions should modify local files)- if bot_token.is_empty() {- if let Ok(main_config) = read_openclaw_config() {- if let Some(tg) = main_config.get("channels").and_then(|c| c.get("telegram")) {- if let Some(token) = tg.get("botToken").and_then(|v| v.as_str()) {- if !token.is_empty() {- log::info!("Recovered Telegram config from openclaw.json (in-memory only)");- bot_token = token.to_string();- }- }- }- }- }-- // If the gateway is running, check live channel status (read-only — report- // actual state but never persist it; only connect/disconnect actions write)- if !bot_token.is_empty() && check_gateway_responding().await {- let params = serde_json::json!({ "probe": true, "timeoutMs": 5000 });- if let Ok(status) = gateway_request("channels.status", params).await {- if let Some(telegram) = status.get("channels").and_then(|c| c.get("telegram")) {- let gw_configured = telegram.get("configured").and_then(|v| v.as_bool()).unwrap_or(false);- let gw_running = telegram.get("running").and_then(|v| v.as_bool()).unwrap_or(false);- let gw_probe_ok = telegram.get("probe")- .and_then(|p| p.get("ok"))- .and_then(|v| v.as_bool())- .unwrap_or(false);-- let live_connected = gw_configured && gw_running && gw_probe_ok;- connected = live_connected;- }- }- }-- Ok(TelegramConfig {- bot_token,- bot_username,- connected,- pairing_code: None,- paired_users,- })-}--/// Clear all pending Telegram pairing codes.-///-/// OpenClaw caps pending pairing requests at 3 per channel. After that,-/// `/start` silently does nothing until a code is approved or expires (1 h).-/// By resetting the pairing state file we guarantee the user always gets a-/// fresh code slot when they open the wizard or tap `/start` again.-///-/// After clearing, we restart the gateway so it reloads the empty state from-/// disk (the running process may have the old requests cached in memory).-#[tauri::command]-pub async fn telegram_clear_pending_pairing() -> Result<(), String> {- log::info!("Clearing pending Telegram pairing codes");-- let config_dir = get_openclaw_config_dir()?;- let pairing_path = config_dir.join("credentials").join("telegram-pairing.json");-- if pairing_path.exists() {- // Reset to an empty request list (keep the version marker)- let empty = serde_json::json!({ "version": 1, "requests": [] });- std::fs::write(&pairing_path, serde_json::to_string_pretty(&empty).unwrap())- .map_err(|e| format!("Failed to clear pairing state: {}", e))?;- log::info!("Cleared pending pairing codes at {:?}", pairing_path);-- // Restart gateway so it picks up the clean state- if check_gateway_responding().await {- log::info!("Restarting gateway to reload pairing state");- let _ = restart_gateway_cli().await;- wait_for_gateway_ready(8).await;- }- } else {- log::info!("No pairing state file to clear");- }-- Ok(())-}--/// Read pending Telegram pairing codes from the credentials file.-///-/// Returns a list of pairing code strings that are currently pending approval.-/// The frontend can poll this to auto-populate the pairing code input field-/// when a user types `/start` in Telegram.-#[tauri::command]-pub async fn telegram_get_pending_pairing_codes() -> Result<Vec<String>, String> {- let config_dir = get_openclaw_config_dir()?;- let pairing_path = config_dir.join("credentials").join("telegram-pairing.json");-- if !pairing_path.exists() {- return Ok(vec![]);- }-- let content = std::fs::read_to_string(&pairing_path)- .map_err(|e| format!("Failed to read pairing file: {}", e))?;- let data: serde_json::Value = serde_json::from_str(&content)- .map_err(|e| format!("Failed to parse pairing file: {}", e))?;-- let codes = data- .get("requests")- .and_then(|r| r.as_array())- .map(|arr| {- arr.iter()- .filter_map(|req| {- req.get("code")- .and_then(|c| c.as_str())- .map(String::from)- })- .collect::<Vec<_>>()- })- .unwrap_or_default();-- Ok(codes)-}--/// Check if Telegram channel is actually connected in OpenClaw gateway-#[tauri::command]-pub async fn telegram_check_pairing() -> Result<bool, String> {- log::info!("Checking Telegram channel status via OpenClaw gateway");-- // Try gateway WebSocket API first (same pattern as WhatsApp status check)- let params = serde_json::json!({- "probe": true,- "timeoutMs": 10000- });-- if let Ok(status) = gateway_request("channels.status", params).await {- if let Some(channels) = status.get("channels") {- if let Some(telegram) = channels.get("telegram") {- // Telegram uses configured+running+probe.ok (not connected/linked like WhatsApp)- let configured = telegram.get("configured")- .and_then(|v| v.as_bool())- .unwrap_or(false);- let running = telegram.get("running")- .and_then(|v| v.as_bool())- .unwrap_or(false);- let probe_ok = telegram.get("probe")- .and_then(|p| p.get("ok"))- .and_then(|v| v.as_bool())- .unwrap_or(false);-- log::info!("Telegram channel status - configured: {}, running: {}, probe.ok: {}", configured, running, probe_ok);- return Ok(configured && running && probe_ok);- }- }- log::info!("Telegram channel not found in gateway status response");- return Ok(false);- }-- // Fallback: try openclaw channels status --probe CLI- log::info!("Gateway WebSocket unavailable, falling back to CLI check");- let status_output = openclaw_command(&["channels", "status", "--probe"]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await;-- match status_output {- Ok(output) => {- let stdout = String::from_utf8_lossy(&output.stdout).to_lowercase();- // Look for telegram in the output with connected/enabled/online status- for line in stdout.lines() {- if line.contains("telegram") {- let is_connected = line.contains("connected")- || line.contains("online")- || line.contains("enabled");- log::info!("Telegram CLI status line: {}, connected: {}", line.trim(), is_connected);- return Ok(is_connected);- }- }- log::info!("Telegram not found in channels status output");- Ok(false)- }- Err(e) => {- log::warn!("Failed to check channel status via CLI: {}", e);- // Last resort: check local config- let config_dir = get_openclaw_config_dir()?;- let telegram_config_path = config_dir.join("telegram.json");- if telegram_config_path.exists() {- let config_json = std::fs::read_to_string(&telegram_config_path)- .map_err(|e| format!("Failed to read Telegram config: {}", e))?;- let settings: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse Telegram config: {}", e))?;- Ok(settings.get("connected").and_then(|v| v.as_bool()).unwrap_or(false))- } else {- Ok(false)- }- }- }-}--/// Approve a Telegram pairing code so the user can chat with Jan via the bot-///-/// When dmPolicy is set to "pairing", users must be approved before they can-/// interact with the bot. This runs `openclaw pairing approve telegram <code>`-#[tauri::command]-pub async fn telegram_approve_pairing(code: String) -> Result<(), String> {- log::info!("Approving Telegram pairing code: {}", code);-- let output = openclaw_command(&["pairing", "approve", "telegram", &code]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw pairing approve: {}", e))?;-- let stdout = String::from_utf8_lossy(&output.stdout);- let stderr = String::from_utf8_lossy(&output.stderr);-- log::info!("Pairing approve stdout: {}", stdout);- if !stderr.is_empty() {- log::info!("Pairing approve stderr: {}", stderr);- }-- if output.status.success() {- Ok(())- } else {- let error_msg = if !stderr.is_empty() {- stderr.to_string()- } else {- stdout.to_string()- };- Err(format!("Failed to approve pairing: {}", error_msg.trim()))- }-}--/// Disconnect Telegram channel-#[tauri::command]-pub async fn telegram_disconnect() -> Result<(), String> {- log::info!("Disconnecting Telegram channel");-- // 1. Remove channel from openclaw.json — gateway hot-reloads on file change- if let Ok(mut config) = read_openclaw_config() {- if let Some(channels) = config.get_mut("channels").and_then(|c| c.as_object_mut()) {- channels.remove("telegram");- write_openclaw_config(&config)- .map_err(|e| format!("Failed to update config: {}", e))?;- log::info!("Telegram channel removed from openclaw.json (hot-reload will stop bot)");- }- }-- // 2. Delete local config file- let config_dir = get_openclaw_config_dir()?;- let telegram_config_path = config_dir.join("telegram.json");- if telegram_config_path.exists() {- let _ = std::fs::remove_file(&telegram_config_path);- }-- // Also clean up pairing file- let pairing_path = config_dir.join("credentials").join("telegram-pairing.json");- if pairing_path.exists() {- let _ = std::fs::remove_file(&pairing_path);- }-- log::info!("Telegram channel fully disconnected and credentials removed");- Ok(())-}--// ============================================-// Channel List and Status Commands-// ============================================--/// Channel status information-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ChannelStatus {- /// Channel name (e.g., "telegram", "whatsapp", "discord")- pub name: String,- /// Account ID- pub account_id: String,- /// Whether the channel is enabled- pub enabled: bool,- /// Whether the channel is connected/authenticated- pub connected: bool,- /// Additional status info- pub status_info: Option<String>,-}--/// List of available and configured channels-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ChannelList {- /// Configured channels with their status- pub configured: Vec<ChannelStatus>,- /// All supported channel types (for showing available options)- pub supported: Vec<String>,-}--/// Get list of configured channels from OpenClaw-#[tauri::command]-pub async fn openclaw_list_channels() -> Result<ChannelList, String> {- log::info!("Listing OpenClaw channels");-- // Run openclaw channels list to get configured channels- let list_output = openclaw_command(&["channels", "list"]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw channels list: {}", e))?;-- let stdout = String::from_utf8_lossy(&list_output.stdout);- let stderr = String::from_utf8_lossy(&list_output.stderr);-- log::debug!("channels list output: {}", stdout);- if !stderr.is_empty() {- log::debug!("channels list stderr: {}", stderr);- }-- let mut configured = Vec::new();-- // Parse the output to extract configured channels- // Format expected: "- channelName accountId: enabled/disabled"- for line in stdout.lines() {- let line = line.trim();- if line.starts_with("- ") || line.starts_with("* ") {- let parts: Vec<&str> = line[2..].split_whitespace().collect();- if !parts.is_empty() {- let channel_name = parts[0].to_string();- let account_id = parts.get(1).unwrap_or(&"default").to_string();- let is_enabled = line.contains("enabled") || !line.contains("disabled");-- configured.push(ChannelStatus {- name: channel_name.clone(),- account_id: account_id.replace(":", ""),- enabled: is_enabled,- connected: is_enabled, // Assume enabled means connected for now- status_info: None,- });- }- }- }-- // List of all supported channel types from OpenClaw- let supported = vec![- "telegram".to_string(),- "whatsapp".to_string(),- "discord".to_string(),- "slack".to_string(),- "signal".to_string(),- "imessage".to_string(),- "matrix".to_string(),- "msteams".to_string(),- "googlechat".to_string(),- "mattermost".to_string(),- "irc".to_string(),- ];-- Ok(ChannelList {- configured,- supported,- })-}--/// Get detailed status of a specific channel-#[tauri::command]-pub async fn openclaw_channel_status(channel: String) -> Result<ChannelStatus, String> {- log::info!("Getting status for channel: {}", channel);-- // Run openclaw channels status to get detailed status- let status_output = openclaw_command(&["channels", "status", "--probe"]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw channels status: {}", e))?;-- let stdout = String::from_utf8_lossy(&status_output.stdout);-- // Find the channel in the output- let channel_lower = channel.to_lowercase();- let mut found = false;- let mut is_enabled = false;- let mut status_info = None;-- for line in stdout.lines() {- let line_lower = line.to_lowercase();- if line_lower.contains(&channel_lower) {- found = true;- is_enabled = line_lower.contains("enabled") || line_lower.contains("connected") || line_lower.contains("online");- if line.contains(":") {- let parts: Vec<&str> = line.split(':').collect();- if parts.len() > 1 {- status_info = Some(parts[1..].join(":").trim().to_string());- }- }- break;- }- }-- if !found {- // Channel not configured- return Ok(ChannelStatus {- name: channel,- account_id: "default".to_string(),- enabled: false,- connected: false,- status_info: Some("Not configured".to_string()),- });- }-- Ok(ChannelStatus {- name: channel,- account_id: "default".to_string(),- enabled: is_enabled,- connected: is_enabled,- status_info,- })-}--// ============================================-// WhatsApp Integration Commands-// ============================================--/// WhatsApp configuration structure-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct WhatsAppConfig {- /// Account ID (e.g., "default")- pub account_id: String,- /// Session path for WhatsApp session data- pub session_path: String,- /// Whether the channel is connected- pub connected: bool,- /// Phone number of the connected account (if connected)- pub phone_number: Option<String>,- /// QR code data (base64 encoded image) for authentication- pub qr_code: Option<String>,- /// Number of contacts synced- pub contacts_count: u32,-}--impl Default for WhatsAppConfig {- fn default() -> Self {- Self {- account_id: "default".to_string(),- session_path: String::new(),- connected: false,- phone_number: None,- qr_code: None,- contacts_count: 0,- }- }-}--/// WhatsApp authentication status-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct WhatsAppAuthStatus {- /// Whether authentication is in progress- pub in_progress: bool,- /// Whether the QR code is ready to be scanned- pub qr_code_ready: bool,- /// QR code data (base64 encoded image)- pub qr_code: Option<String>,- /// Whether authentication is complete- pub authenticated: bool,- /// Error message if any- pub error: Option<String>,-}--/// Get the WhatsApp configuration file path-fn get_whatsapp_config_path() -> Result<std::path::PathBuf, String> {- let config_dir = get_openclaw_config_dir()?;- Ok(config_dir.join("whatsapp.json"))-}--/// Check if WhatsApp is connected by reading the config.-/// Delegates to `whatsapp_get_config` which reconciles across sandbox modes.-#[tauri::command]-pub async fn whatsapp_validate_connection() -> Result<bool, String> {- log::info!("Validating WhatsApp connection");- let config = whatsapp_get_config().await?;- Ok(config.connected)-}--/// Start WhatsApp authentication - 1-click setup that handles everything-///-/// This function handles the complete setup flow automatically:-/// 1. Ensures OpenClaw is installed and configured-/// 2. Starts the Gateway if not running-/// 3. Ensures device pairing for Gateway connection-/// 4. Enables the WhatsApp plugin-/// 5. Adds the WhatsApp channel configuration-/// 6. Initiates the QR code login flow-///-/// Users don't need to run any terminal commands - everything is automatic.-#[tauri::command]-pub async fn whatsapp_start_auth(state: tauri::State<'_, OpenClawState>) -> Result<WhatsAppAuthStatus, String> {- log::info!("Starting WhatsApp 1-click setup and authentication");-- // Reset the restart counter for this new auth session- WA_RESTART_COUNT.store(0, Ordering::SeqCst);-- // Step 1: Run the unified setup to ensure OpenClaw is ready- log::info!("Running OpenClaw setup...");- let setup_result = openclaw_setup_for_channels(state).await?;-- if !setup_result.success {- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(format!(- "OpenClaw setup failed at step '{}': {}",- setup_result.step,- setup_result.error.unwrap_or_else(|| "Unknown error".to_string())- )),- });- }-- log::info!("OpenClaw setup complete, checking if WhatsApp is already linked...");-- // Step 2: Check if WhatsApp is already linked (authenticated with a phone)- // If so, we don't need to show QR code- let params = serde_json::json!({- "probe": false,- "timeoutMs": 5000- });-- if let Ok(status) = gateway_request("channels.status", params).await {- if let Some(channels) = status.get("channels") {- if let Some(whatsapp) = channels.get("whatsapp") {- let linked = whatsapp.get("linked")- .and_then(|v| v.as_bool())- .unwrap_or(false);- let connected = whatsapp.get("connected")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- if linked {- log::info!("WhatsApp is already linked to a phone");-- // Update local config to reflect linked status- update_whatsapp_connected_status(true).await.ok();-- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: true,- error: None,- });- }-- if connected {- log::info!("WhatsApp is connected but not yet linked, need QR code");- }- }- }- }-- log::info!("WhatsApp not linked, proceeding with QR code setup");-- // Get the WhatsApp session/auth directory- let config_dir = get_openclaw_config_dir()?;- let auth_dir = config_dir.join("whatsapp_auth");-- if !auth_dir.exists() {- std::fs::create_dir_all(&auth_dir)- .map_err(|e| format!("Failed to create WhatsApp auth directory: {}", e))?;- }-- // Enable the WhatsApp plugin (must be done before adding channel)- enable_channel_plugin("whatsapp").await?;-- // Now add WhatsApp channel using CLI.- // With config directory isolation, auth_dir is always the correct host path- // for the active sandbox — no Docker-specific path rewriting needed.- let add_output = openclaw_command(&[- "channels",- "add",- "--channel", "whatsapp",- "--account", "default",- "--auth-dir", &auth_dir.to_string_lossy(),- ]).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run openclaw channels add: {}", e))?;-- let add_stderr = String::from_utf8_lossy(&add_output.stderr);- let add_stdout = String::from_utf8_lossy(&add_output.stdout);-- log::info!("OpenClaw channels add output: {}", add_stdout);- if !add_stderr.is_empty() {- log::info!("OpenClaw channels add stderr: {}", add_stderr);- }-- if !add_output.status.success() {- // Check if it failed because channel already exists (which is fine)- let combined = format!("{}{}", add_stdout, add_stderr);- if !combined.contains("already exists") && !combined.contains("Added") && !combined.contains("updated") {- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(format!(- "Failed to add WhatsApp channel: {}",- if !add_stderr.is_empty() { add_stderr.to_string() } else { add_stdout.to_string() }- )),- });- }- }-- // Now get QR code via Gateway RPC (web.login.start)- // This returns the QR as a base64 PNG data URL that can be displayed in the UI- log::info!("Requesting QR code via Gateway RPC...");-- let qr_params = serde_json::json!({- "accountId": "default",- "timeoutMs": 60000,- "force": true- });-- // Use 65s transport timeout so the server-side 60s timeoutMs can fire first- match gateway_request_with_timeout("web.login.start", qr_params, 65).await {- Ok(qr_payload) => {- let qr_code = qr_payload.get("qrDataUrl")- .and_then(|v| v.as_str())- .map(String::from);-- if qr_code.is_some() {- log::info!("QR code received successfully");-- // Save state to local config- let whatsapp_config = WhatsAppConfig {- account_id: "default".to_string(),- session_path: auth_dir.to_string_lossy().to_string(),- connected: false,- phone_number: None,- qr_code: qr_code.clone(),- contacts_count: 0,- };-- let config_path = get_whatsapp_config_path()?;- std::fs::write(- &config_path,- serde_json::to_string_pretty(&whatsapp_config).unwrap()- ).map_err(|e| format!("Failed to save WhatsApp config: {}", e))?;-- return Ok(WhatsAppAuthStatus {- in_progress: true,- qr_code_ready: true,- qr_code,- authenticated: false,- error: None,- });- } else {- log::warn!("QR code response missing qrDataUrl");- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some("QR code generation failed - missing qrDataUrl".to_string()),- });- }- }- Err(e) => {- log::error!("Failed to get QR code: {}", e);-- // Check for specific error messages- if e.contains("Unsupported channel") || e.contains("web login provider is not available") {- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(- "WhatsApp channel is not yet supported in this version of OpenClaw. \- Please check for OpenClaw updates.".to_string()- ),- });- }-- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(format!("Failed to get QR code: {}", e)),- });- }- }-}--/// Get the QR code for WhatsApp authentication-/// This polls OpenClaw's Gateway for the QR code-#[tauri::command]-pub async fn whatsapp_get_qr_code() -> Result<WhatsAppAuthStatus, String> {- log::info!("Getting WhatsApp QR code from OpenClaw Gateway");-- // First check if Gateway is running- if !check_gateway_responding().await {- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some("OpenClaw Gateway is not running".to_string()),- });- }-- // Check channel status via Gateway- let params = serde_json::json!({- "probe": true,- "timeoutMs": 5000- });-- match gateway_request("channels.status", params).await {- Ok(payload) => {- log::debug!("Channel status response: {:?}", payload);-- // Check if WhatsApp channel is linked (authenticated) or connected- if let Some(channels) = payload.get("channels") {- if let Some(whatsapp) = channels.get("whatsapp") {- let connected = whatsapp.get("connected")- .and_then(|v| v.as_bool())- .unwrap_or(false);- let linked = whatsapp.get("linked")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- // If linked, WhatsApp is already authenticated - no QR needed- if linked {- log::info!("WhatsApp is already linked, no QR code needed");- update_whatsapp_connected_status(true).await?;-- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: true,- error: None,- });- }-- if connected && !linked {- log::info!("WhatsApp connected but not linked, need to get QR code");- }- }- }-- // If not linked, try to get/refresh QR code- let qr_params = serde_json::json!({- "accountId": "default",- "timeoutMs": 30000- });-- match gateway_request("web.login.start", qr_params).await {- Ok(qr_payload) => {- let qr_code = qr_payload.get("qrDataUrl")- .and_then(|v| v.as_str())- .map(String::from);-- Ok(WhatsAppAuthStatus {- in_progress: true,- qr_code_ready: qr_code.is_some(),- qr_code,- authenticated: false,- error: None,- })- }- Err(e) => {- // Fall back to local config- let config_path = get_whatsapp_config_path()?;- if config_path.exists() {- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read WhatsApp config: {}", e))?;- let settings: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse WhatsApp config: {}", e))?;- let qr_code = settings.get("qr_code").and_then(|v| v.as_str()).map(String::from);-- Ok(WhatsAppAuthStatus {- in_progress: true,- qr_code_ready: qr_code.is_some(),- qr_code,- authenticated: false,- error: Some(format!("Could not refresh QR code: {}", e)),- })- } else {- Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(format!("Failed to get QR code: {}", e)),- })- }- }- }- }- Err(e) => {- log::error!("Failed to get channel status: {}", e);- Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(format!("Failed to check WhatsApp status: {}", e)),- })- }- }-}--/// Update local WhatsApp connected status-async fn update_whatsapp_connected_status(connected: bool) -> Result<(), String> {- let config_path = get_whatsapp_config_path()?;-- let mut config = if config_path.exists() {- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read WhatsApp config: {}", e))?;- serde_json::from_str::<WhatsAppConfig>(&config_json)- .unwrap_or_default()- } else {- WhatsAppConfig::default()- };-- config.connected = connected;- if connected {- config.qr_code = None; // Clear QR code when connected- }-- std::fs::write(- &config_path,- serde_json::to_string_pretty(&config).unwrap()- ).map_err(|e| format!("Failed to save WhatsApp config: {}", e))?;-- Ok(())-}--/// Check if WhatsApp authentication is complete-#[tauri::command]-pub async fn whatsapp_check_auth() -> Result<WhatsAppAuthStatus, String> {- log::info!("Checking WhatsApp authentication status via OpenClaw Gateway");-- // Check Gateway status first- if !check_gateway_responding().await {- // Fall back to local config- let config_path = get_whatsapp_config_path()?;- if !config_path.exists() {- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some("WhatsApp not configured".to_string()),- });- }-- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read WhatsApp config: {}", e))?;- let settings: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse WhatsApp config: {}", e))?;-- let connected = settings.get("connected").and_then(|v| v.as_bool()).unwrap_or(false);- let qr_code = settings.get("qr_code").and_then(|v| v.as_str()).map(String::from);-- return Ok(WhatsAppAuthStatus {- in_progress: !connected,- qr_code_ready: qr_code.is_some(),- qr_code,- authenticated: connected,- error: if !connected { Some("OpenClaw Gateway is not running".to_string()) } else { None },- });- }-- // Check channel status via Gateway- let params = serde_json::json!({- "probe": true,- "timeoutMs": 5000- });-- match gateway_request("channels.status", params).await {- Ok(payload) => {- log::debug!("Channel status response: {:?}", payload);-- // Check if WhatsApp channel is connected or linked- if let Some(channels) = payload.get("channels") {- if let Some(whatsapp) = channels.get("whatsapp") {- let connected = whatsapp.get("connected")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- let linked = whatsapp.get("linked")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- let running = whatsapp.get("running")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- // "linked" means the account is paired with a phone (QR scanned)- // "connected" means the WebSocket is currently active- // "running" means the channel process is running- // All three must be true for WhatsApp to actually work- if linked && connected && running {- log::info!("WhatsApp is fully connected (linked + running + connected)");- update_whatsapp_connected_status(true).await?;-- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: true,- error: None,- });- }-- if linked && (!connected || !running) {- // QR was scanned but the Gateway hasn't established the WhatsApp- // WebSocket connection yet. This is a transient state — the- // Gateway may need a restart to kick-start the connection.- log::info!(- "WhatsApp linked but not fully connected (running: {}, connected: {}), \- waiting for gateway to establish connection",- running, connected- );-- // Restart the gateway up to MAX_WA_RESTART_ATTEMPTS times per- // auth session to nudge it into connecting. Counter is reset- // in whatsapp_start_auth.- let attempt = WA_RESTART_COUNT.fetch_add(1, Ordering::SeqCst);- if attempt < MAX_WA_RESTART_ATTEMPTS {- log::info!(- "Restarting gateway to establish WhatsApp connection (attempt {}/{})",- attempt + 1, MAX_WA_RESTART_ATTEMPTS- );- let _ = restart_gateway_cli().await;- // Give the gateway time to come back before the next poll- wait_for_gateway_ready(8).await;- }-- // Return in_progress so the frontend keeps polling- return Ok(WhatsAppAuthStatus {- in_progress: true,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: None,- });- }-- if connected && !linked {- // Connected but not linked - waiting for QR scan- log::info!("WhatsApp connected but waiting for QR scan");- }-- // Check for errors- let last_error = whatsapp.get("lastError")- .and_then(|v| v.as_str())- .map(String::from);-- // Only report fatal errors, not transient ones like 515 stream errors- // These can occur during connection establishment but the link often succeeds after- if let Some(ref err) = last_error {- let is_transient = err.contains("515") ||- err.contains("restart required") ||- err.contains("Stream Errored") ||- err.contains("not linked") ||- err.contains("not configured");-- if !is_transient && !linked {- return Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: last_error,- });- }- // For transient errors, continue checking - don't report as error yet- }- }- }-- // Still waiting for authentication — refresh the QR code from Gateway.- // WhatsApp QR codes expire every ~20s, so we must fetch a fresh one- // rather than serving the stale one from local config.- let qr_params = serde_json::json!({- "accountId": "default",- "timeoutMs": 5000- });-- let qr_code = match gateway_request("web.login.start", qr_params).await {- Ok(qr_payload) => {- let qr = qr_payload.get("qrDataUrl")- .and_then(|v| v.as_str())- .map(String::from);-- // Update local config with fresh QR- if let Some(ref qr_data) = qr {- if let Ok(config_path) = get_whatsapp_config_path() {- if config_path.exists() {- if let Ok(content) = std::fs::read_to_string(&config_path) {- if let Ok(mut cfg) = serde_json::from_str::<serde_json::Value>(&content) {- cfg["qr_code"] = serde_json::json!(qr_data);- let _ = std::fs::write(&config_path, serde_json::to_string_pretty(&cfg).unwrap_or_default());- }- }- }- }- }- qr- }- Err(_) => {- // Fall back to local config if Gateway call fails- let config_path = get_whatsapp_config_path()?;- if config_path.exists() {- std::fs::read_to_string(&config_path).ok()- .and_then(|json| serde_json::from_str::<serde_json::Value>(&json).ok())- .and_then(|settings| settings.get("qr_code").and_then(|v| v.as_str()).map(String::from))- } else {- None- }- }- };-- Ok(WhatsAppAuthStatus {- in_progress: true,- qr_code_ready: qr_code.is_some(),- qr_code,- authenticated: false,- error: None,- })- }- Err(e) => {- log::error!("Failed to check channel status: {}", e);-- // Fall back to local config- let config_path = get_whatsapp_config_path()?;- if config_path.exists() {- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read WhatsApp config: {}", e))?;- let settings: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse WhatsApp config: {}", e))?;-- let connected = settings.get("connected").and_then(|v| v.as_bool()).unwrap_or(false);- let qr_code = settings.get("qr_code").and_then(|v| v.as_str()).map(String::from);-- Ok(WhatsAppAuthStatus {- in_progress: !connected,- qr_code_ready: qr_code.is_some(),- qr_code,- authenticated: connected,- error: Some(format!("Gateway error: {}", e)),- })- } else {- Ok(WhatsAppAuthStatus {- in_progress: false,- qr_code_ready: false,- qr_code: None,- authenticated: false,- error: Some(format!("Failed to check WhatsApp status: {}", e)),- })- }- }- }-}--/// Get current WhatsApp configuration.-///-/// Reconciles across sandbox modes (Docker vs direct process):-/// 1. Reads local `whatsapp.json` first-/// 2. Falls back to `openclaw.json` if local file is absent or empty (cross-mode recovery)-/// 3. Probes live gateway `channels.status` to verify actual connected/linked state-/// 4. Persists reconciled state back to local file-///-/// This ensures the UI shows the correct status regardless of whether the-/// channel was originally configured in Docker mode or direct process mode.-#[tauri::command]-pub async fn whatsapp_get_config() -> Result<WhatsAppConfig, String> {- let config_path = get_whatsapp_config_path()?;-- // Start with local file data (if it exists)- let mut account_id = "default".to_string();- let mut session_path = String::new();- let mut connected = false;- let mut phone_number: Option<String> = None;- let mut qr_code: Option<String> = None;- let mut contacts_count: u32 = 0;- let mut has_local_data = false;-- if config_path.exists() {- if let Ok(config_json) = std::fs::read_to_string(&config_path) {- if let Ok(settings) = serde_json::from_str::<serde_json::Value>(&config_json) {- account_id = settings.get("account_id").and_then(|v| v.as_str()).unwrap_or("default").to_string();- session_path = settings.get("session_path").and_then(|v| v.as_str()).unwrap_or("").to_string();- connected = settings.get("connected").and_then(|v| v.as_bool()).unwrap_or(false);- phone_number = settings.get("phone_number").and_then(|v| v.as_str()).map(String::from);- qr_code = settings.get("qr_code").and_then(|v| v.as_str()).map(String::from);- contacts_count = settings.get("contacts_count").and_then(|v| v.as_u64()).unwrap_or(0) as u32;- // Consider local data present if connected or has phone number- has_local_data = connected || phone_number.is_some();- }- }- }-- // If no meaningful local data, check openclaw.json (read-only — never write- // back here; only explicit user actions should modify local files)- if !has_local_data {- if let Ok(main_config) = read_openclaw_config() {- if let Some(wa) = main_config.get("channels").and_then(|c| c.get("whatsapp")) {- let enabled = wa.get("enabled").and_then(|v| v.as_bool()).unwrap_or(false);- if enabled {- log::info!("WhatsApp channel enabled in openclaw.json (in-memory only)");- }- }- }- }-- // If the gateway is running, check live channel status (read-only — report- // actual state but never persist it; only connect/disconnect actions write)- if check_gateway_responding().await {- let params = serde_json::json!({ "probe": true, "timeoutMs": 5000 });- if let Ok(status) = gateway_request("channels.status", params).await {- if let Some(whatsapp) = status.get("channels").and_then(|c| c.get("whatsapp")) {- let gw_running = whatsapp.get("running")- .and_then(|v| v.as_bool())- .unwrap_or(false);- let gw_linked = whatsapp.get("linked")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- // linked=true just means session auth exists (credentials kept after disconnect).- // The channel is only truly active when the gateway is running it.- connected = gw_running && gw_linked;- }- }- }-- Ok(WhatsAppConfig {- account_id,- session_path,- connected,- phone_number,- qr_code,- contacts_count,- })-}--/// Get connected WhatsApp contacts-#[tauri::command]-pub async fn whatsapp_get_contacts() -> Result<Vec<String>, String> {- log::info!("Getting WhatsApp contacts");-- let config_path = get_whatsapp_config_path()?;-- if !config_path.exists() {- return Ok(vec![]);- }-- let config_json = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read WhatsApp config: {}", e))?;-- let settings: serde_json::Value = serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse WhatsApp config: {}", e))?;-- // In production, this would return actual contacts from OpenClaw- // For now, return the phone number if connected- let connected = settings.get("connected").and_then(|v| v.as_bool()).unwrap_or(false);- let phone_number = settings.get("phone_number").and_then(|v| v.as_str()).map(String::from);-- if connected {- if let Some(phone) = phone_number {- return Ok(vec![phone]);- }- }-- Ok(vec![])-}--/// Disconnect WhatsApp session-#[tauri::command]-pub async fn whatsapp_disconnect() -> Result<(), String> {- log::info!("Disconnecting WhatsApp channel");-- // 1. Remove channel from openclaw.json — gateway hot-reloads on file change- if let Ok(mut config) = read_openclaw_config() {- if let Some(channels) = config.get_mut("channels").and_then(|c| c.as_object_mut()) {- channels.remove("whatsapp");- write_openclaw_config(&config)- .map_err(|e| format!("Failed to update config: {}", e))?;- log::info!("WhatsApp channel removed from openclaw.json (hot-reload will stop bot)");- }- }-- // 2. Delete local config file- let config_path = get_whatsapp_config_path()?;- if config_path.exists() {- let _ = std::fs::remove_file(&config_path);- }-- // 3. Delete WhatsApp auth/session directory- let config_dir = get_openclaw_config_dir()?;- let auth_dir = config_dir.join("whatsapp_auth");- if auth_dir.exists() {- let _ = std::fs::remove_dir_all(&auth_dir);- }-- log::info!("WhatsApp channel fully disconnected and credentials removed");- Ok(())-}--// ============================================-// Tailscale Integration Commands-// ============================================--use crate::core::openclaw::tailscale;--/// Check if Tailscale is installed on the system-///-/// Returns detailed status including whether Tailscale is installed,-/// running, and the user is logged in.-#[tauri::command]-pub async fn tailscale_detect() -> TailscaleStatus {- log::info!("Detecting Tailscale installation");- tailscale::detect_tailscale().await-}--/// Get current Tailscale status and tailnet information-///-/// Returns information about the current tailnet, including hostname,-/// IP addresses, DNS name, and serve/funnel status.-#[tauri::command]-pub async fn tailscale_get_status() -> TailscaleInfo {- log::info!("Getting Tailscale status");- tailscale::get_tailscale_status().await-}--/// Configure Tailscale Serve for the OpenClaw gateway-///-/// Sets up Tailscale Serve to proxy HTTPS traffic to the local-/// OpenClaw gateway port (default 18789).-#[tauri::command]-pub async fn tailscale_configure_serve(port: Option<u16>) -> Result<String, String> {- let port = port.unwrap_or(OPENCLAW_PORT);- log::info!("Configuring Tailscale Serve for port {}", port);- tailscale::configure_tailscale_serve(port).await-}--/// Remove Tailscale Serve configuration-///-/// Disables Tailscale Serve, stopping the HTTPS proxy to the local gateway.-#[tauri::command]-pub async fn tailscale_remove_serve() -> Result<(), String> {- log::info!("Removing Tailscale Serve configuration");- tailscale::remove_tailscale_serve().await-}--/// Enable Tailscale Funnel for public access-///-/// Enables Tailscale Funnel to make the OpenClaw gateway accessible-/// from the public internet via a secure HTTPS URL.-#[tauri::command]-pub async fn tailscale_enable_funnel(port: Option<u16>) -> Result<String, String> {- let port = port.unwrap_or(OPENCLAW_PORT);- log::info!("Enabling Tailscale Funnel for port {}", port);- tailscale::enable_tailscale_funnel(port).await-}--/// Disable Tailscale Funnel-///-/// Disables public internet access via Tailscale Funnel.-#[tauri::command]-pub async fn tailscale_disable_funnel() -> Result<(), String> {- log::info!("Disabling Tailscale Funnel");- tailscale::disable_tailscale_funnel().await-}--/// Get the Tailscale URL for accessing the gateway-///-/// Returns the HTTPS URL that can be used to access the OpenClaw gateway-/// via Tailscale Serve or Funnel, if configured.-#[tauri::command]-pub async fn tailscale_get_url() -> Result<Option<String>, String> {- log::info!("Getting Tailscale URL");- tailscale::get_tailscale_url().await-}--// ============================================-// Security Configuration Commands-// ============================================--use crate::core::openclaw::security;--/// Get current security configuration status-///-/// Returns a summary of the security configuration including-/// auth mode, whether token/password are set, and device counts.-#[tauri::command]-pub async fn security_get_status() -> Result<SecurityStatus, String> {- log::info!("Getting security status");-- let config = security::load_security_config().await?;- let recent_failures = security::count_recent_auth_failures().await?;-- Ok(SecurityStatus {- auth_mode: config.auth_mode,- has_token: config.token_hash.is_some(),- has_password: config.password_hash.is_some(),- require_pairing: config.require_pairing,- approved_device_count: config.approved_devices.len() as u32,- recent_auth_failures: recent_failures,- })-}--/// Set the authentication mode.-#[tauri::command]-pub async fn security_set_auth_mode(mode: AuthMode) -> Result<(), String> {- log::info!("Setting auth mode to {:?}", mode);-- let mut config = security::load_security_config().await?;- config.auth_mode = mode.clone();- security::save_security_config(&config).await?;-- if mode == AuthMode::None {- if let Ok(mut oc_config) = read_openclaw_config() {- if let Some(auth) = oc_config.pointer_mut("/gateway/auth") {- if let Some(obj) = auth.as_object_mut() {- obj.remove("token");- }- }- if let Err(e) = write_openclaw_config(&oc_config) {- log::warn!("Failed to clear gateway auth token: {}", e);- }- }- }-- Ok(())-}--/// Generate and store a new access token.-/// Returns the plaintext token (only shown once).-#[tauri::command]-pub async fn security_generate_token() -> Result<String, String> {- log::info!("Generating new access token");-- let token = security::generate_access_token();- let hash = security::hash_token(&token);-- let mut config = security::load_security_config().await?;- config.token_hash = Some(hash);- config.auth_mode = AuthMode::Token;- security::save_security_config(&config).await?;-- // Also write to gateway config so OpenClaw enforces this token- if let Ok(mut oc_config) = read_openclaw_config() {- oc_config["gateway"]["auth"]["token"] = serde_json::json!(token);- if let Err(e) = write_openclaw_config(&oc_config) {- log::warn!("Failed to sync token to gateway config: {}", e);- }- }-- Ok(token)-}--/// Set password authentication-///-/// Stores the password hash and sets auth mode to Password.-#[tauri::command]-pub async fn security_set_password(password: String) -> Result<(), String> {- log::info!("Setting password authentication");-- if password.len() < 8 {- return Err("Password must be at least 8 characters".to_string());- }-- let hash = security::hash_token(&password);-- let mut config = security::load_security_config().await?;- config.password_hash = Some(hash);- config.auth_mode = AuthMode::Password;- security::save_security_config(&config).await-}--/// Verify a token against the stored hash-///-/// Returns true if the token is valid.-#[tauri::command]-pub async fn security_verify_token(token: String) -> Result<bool, String> {- log::info!("Verifying token");-- let config = security::load_security_config().await?;-- match config.auth_mode {- AuthMode::Token => {- if let Some(hash) = config.token_hash {- Ok(security::verify_token(&token, &hash))- } else {- Ok(false)- }- }- AuthMode::Password => {- if let Some(hash) = config.password_hash {- Ok(security::verify_token(&token, &hash))- } else {- Ok(false)- }- }- AuthMode::None => Ok(true),- }-}--/// Set whether device pairing is required-///-/// When enabled, only approved devices can access the gateway.-#[tauri::command]-pub async fn security_set_require_pairing(require: bool) -> Result<(), String> {- log::info!("Setting require_pairing to {}", require);-- let mut config = security::load_security_config().await?;- config.require_pairing = require;- security::save_security_config(&config).await-}--/// Get list of approved devices-#[tauri::command]-pub async fn security_get_devices() -> Result<Vec<DeviceInfo>, String> {- log::info!("Getting approved devices");- security::get_approved_devices().await-}--/// Approve a device for access-///-/// Adds the device to the approved list or updates an existing device.-#[tauri::command]-pub async fn security_approve_device(device: DeviceInfo) -> Result<(), String> {- log::info!("Approving device: {} ({})", device.name, device.id);- security::approve_device(device).await-}--/// Revoke device access-///-/// Removes the device from the approved list.-#[tauri::command]-pub async fn security_revoke_device(device_id: String) -> Result<(), String> {- log::info!("Revoking device: {}", device_id);- security::revoke_device(&device_id).await-}--/// Get recent access logs-///-/// Returns the most recent access log entries.-#[tauri::command]-pub async fn security_get_logs(limit: u32) -> Result<Vec<AccessLogEntry>, String> {- log::info!("Getting access logs (limit: {})", limit);- security::get_access_logs(limit as usize).await-}--/// Clear all access logs-#[tauri::command]-pub async fn security_clear_logs() -> Result<(), String> {- log::info!("Clearing access logs");- security::clear_access_logs().await-}--/// Generate a new pairing code-///-/// Returns an 8-character alphanumeric code for device pairing.-#[tauri::command]-pub fn security_generate_pairing_code() -> String {- log::info!("Generating pairing code");- security::generate_pairing_code()-}--// ============================================-// Sandbox Commands-// ============================================--use crate::core::openclaw::sandbox::SandboxMode;--/// Get sandbox logs-///-/// Returns the last N lines of logs from the sandboxed OpenClaw process.-#[tauri::command]-pub async fn sandbox_get_logs(- state: State<'_, OpenClawState>,- lines: usize,-) -> Result<Vec<String>, String> {- log::info!("Getting sandbox logs (lines: {})", lines);-- let mode = state.sandbox_mode.lock().await;- let sandbox_guard = state.sandbox.lock().await;-- match (&*mode, &*sandbox_guard) {- (SandboxMode::Active { handle, .. }, Some(sandbox)) => {- sandbox.logs(handle, lines).await- }- _ => {- // Try to read from the gateway log file directly- let config_dir = get_openclaw_config_dir()?;- let log_path = config_dir.join("gateway.log");-- if log_path.exists() {- let content = tokio::fs::read_to_string(&log_path)- .await- .map_err(|e| format!("Failed to read log file: {}", e))?;-- let all_lines: Vec<String> = content.lines().map(|s| s.to_string()).collect();- let start = if all_lines.len() > lines {- all_lines.len() - lines- } else {- 0- };- Ok(all_lines[start..].to_vec())- } else {- Ok(vec!["No logs available. OpenClaw may not be running.".to_string()])- }- }- }-}--/// Restart the sandboxed OpenClaw process-///-/// Stops the current sandbox (if running) and starts a fresh one.-/// This is useful for recovering from errors or applying configuration changes.-#[tauri::command]-pub async fn sandbox_restart(state: State<'_, OpenClawState>) -> Result<(), String> {- log::info!("Restarting sandbox");-- // Stop the current sandbox if active- {- let mut mode = state.sandbox_mode.lock().await;- let sandbox_guard = state.sandbox.lock().await;-- if let SandboxMode::Active { handle, sandbox_name, isolation_tier } = std::mem::take(&mut *mode) {- if let Some(sandbox) = &*sandbox_guard {- log::info!("Stopping sandbox {} ({:?})", sandbox_name, isolation_tier);- let mut handle = handle;- let _ = sandbox.stop(&mut handle).await;- }- }- *mode = SandboxMode::Inactive;- }-- // Start fresh- openclaw_start(state).await-}--// ============================================-// Tunnel Provider Commands-// ============================================--use crate::core::openclaw::tunnels;--/// Get status of all tunnel providers-///-/// Returns the installation and authentication status of all supported-/// tunnel providers (Tailscale, ngrok, Cloudflare).-#[tauri::command]-pub async fn tunnel_get_providers(- state: State<'_, OpenClawState>,-) -> Result<TunnelProvidersStatus, String> {- log::info!("Getting tunnel providers status");- let tunnel_state = state.tunnel_state.clone();- Ok(tunnels::get_tunnel_providers(&tunnel_state).await)-}--/// Detect all installed tunnel providers-///-/// Runs detection for all supported tunnel providers in parallel-/// and returns their installation/authentication status.-#[tauri::command]-pub async fn tunnel_detect_all(- state: State<'_, OpenClawState>,-) -> Result<TunnelProvidersStatus, String> {- log::info!("Detecting all tunnel providers");- let tunnel_state = state.tunnel_state.clone();- Ok(tunnels::get_tunnel_providers(&tunnel_state).await)-}--/// Set the preferred tunnel provider-///-/// Sets which tunnel provider should be used when starting a tunnel.-#[tauri::command]-pub async fn tunnel_set_provider(- state: State<'_, OpenClawState>,- provider: TunnelProvider,-) -> Result<(), String> {- log::info!("Setting tunnel provider to {:?}", provider);- let tunnel_state = state.tunnel_state.clone();- tunnels::set_tunnel_provider(&tunnel_state, provider).await-}--/// Start a tunnel with the preferred provider-///-/// Starts a tunnel using the configured preferred provider on the specified port.-#[tauri::command]-pub async fn tunnel_start(- state: State<'_, OpenClawState>,- port: u16,-) -> Result<TunnelInfo, String> {- log::info!("Starting tunnel on port {}", port);- let tunnel_state = state.tunnel_state.clone();- tunnels::start_tunnel(&tunnel_state, port).await-}--/// Stop the active tunnel-///-/// Stops the currently running tunnel, if any.-#[tauri::command]-pub async fn tunnel_stop(- state: State<'_, OpenClawState>,-) -> Result<(), String> {- log::info!("Stopping tunnel");- let tunnel_state = state.tunnel_state.clone();- tunnels::stop_tunnel(&tunnel_state).await-}--/// Get active tunnel information-///-/// Returns information about the currently active tunnel, if any.-#[tauri::command]-pub async fn tunnel_get_active(- state: State<'_, OpenClawState>,-) -> Result<Option<TunnelInfo>, String> {- log::info!("Getting active tunnel info");- let tunnel_state = state.tunnel_state.clone();- Ok(tunnels::get_active_tunnel(&tunnel_state).await)-}--/// Set ngrok authentication token-///-/// Configures ngrok with the provided auth token and saves it for future use.-#[tauri::command]-pub async fn tunnel_set_ngrok_token(- state: State<'_, OpenClawState>,- token: String,-) -> Result<(), String> {- log::info!("Setting ngrok auth token");- let tunnel_state = state.tunnel_state.clone();- tunnels::set_ngrok_token(&tunnel_state, token).await-}--/// Set Cloudflare tunnel ID-///-/// Configures a named Cloudflare tunnel for use with cloudflared.-#[tauri::command]-pub async fn tunnel_set_cloudflare_tunnel(- state: State<'_, OpenClawState>,- tunnel_id: String,-) -> Result<(), String> {- log::info!("Setting Cloudflare tunnel ID");- let tunnel_state = state.tunnel_state.clone();- tunnels::set_cloudflare_tunnel(&tunnel_state, tunnel_id).await-}--/// Get tunnel configuration-///-/// Returns the current tunnel configuration including preferred provider-/// and stored credentials.-#[tauri::command]-pub async fn tunnel_get_config(- state: State<'_, OpenClawState>,-) -> Result<TunnelConfig, String> {- log::info!("Getting tunnel configuration");- let config = state.tunnel_state.config.lock().await;- Ok(config.clone())-}--/// Start ngrok tunnel directly-///-/// Starts an ngrok tunnel on the specified port, optionally using a provided auth token.-#[tauri::command]-pub async fn tunnel_start_ngrok(- state: State<'_, OpenClawState>,- port: u16,- auth_token: Option<String>,-) -> Result<TunnelInfo, String> {- log::info!("Starting ngrok tunnel on port {}", port);- let tunnel_state = state.tunnel_state.clone();- tunnels::start_ngrok_tunnel(&tunnel_state, port, auth_token).await-}--/// Stop ngrok tunnel-///-/// Stops the active ngrok tunnel.-#[tauri::command]-pub async fn tunnel_stop_ngrok(- state: State<'_, OpenClawState>,-) -> Result<(), String> {- log::info!("Stopping ngrok tunnel");- let tunnel_state = state.tunnel_state.clone();- tunnels::stop_ngrok_tunnel(&tunnel_state).await-}--/// Start cloudflared tunnel directly-///-/// Starts a cloudflared tunnel on the specified port. If no tunnel_name is provided,-/// a quick tunnel (no account required) will be created.-#[tauri::command]-pub async fn tunnel_start_cloudflared(- state: State<'_, OpenClawState>,- port: u16,- tunnel_name: Option<String>,-) -> Result<TunnelInfo, String> {- log::info!("Starting cloudflared tunnel on port {}", port);- let tunnel_state = state.tunnel_state.clone();- tunnels::start_cloudflared_tunnel(&tunnel_state, port, tunnel_name).await-}--/// Stop cloudflared tunnel-///-/// Stops the active cloudflared tunnel.-#[tauri::command]-pub async fn tunnel_stop_cloudflared(- state: State<'_, OpenClawState>,-) -> Result<(), String> {- log::info!("Stopping cloudflared tunnel");- let tunnel_state = state.tunnel_state.clone();- tunnels::stop_cloudflared_tunnel(&tunnel_state).await-}diff --git a/src-tauri/src/core/openclaw/constants.rs b/src-tauri/src/core/openclaw/constants.rsdeleted file mode 100644index 7ad9ebada..000000000--- a/src-tauri/src/core/openclaw/constants.rs+++ /dev/null@@ -1,25 +0,0 @@-/// OpenClaw package name on npm-pub const OPENCLAW_PACKAGE_NAME: &str = "openclaw";--/// Pinned OpenClaw version (npm semver and Docker image tag)-/// This ensures config compatibility across installs.-pub const OPENCLAW_VERSION: &str = "2026.3.8";--/// Default OpenClaw gateway port-pub const DEFAULT_OPENCLAW_PORT: u16 = 18789;--/// Default Jan API base URL (direct process — same host)-pub const DEFAULT_JAN_BASE_URL: &str = "http://localhost:1337/v1";--/// Jan API base URL for Docker sandbox (container → host networking)-pub const DOCKER_JAN_BASE_URL: &str = "http://host.docker.internal:1337/v1";--/// Gateway bind mode — "lan" for all sandbox types.-pub const GATEWAY_BIND_MODE: &str = "lan";--/// Default API type for Jan-pub const DEFAULT_JAN_API_TYPE: &str = "openai-completions";--pub const DEFAULT_JAN_API_KEY: &str = "jan-local";--pub const DEFAULT_MODEL_ID: &str = "Jan-v3-4b-base-instruct-Q4_K_XL";\ No newline at end of filediff --git a/src-tauri/src/core/openclaw/health.rs b/src-tauri/src/core/openclaw/health.rsdeleted file mode 100644index 32ec97ef2..000000000--- a/src-tauri/src/core/openclaw/health.rs+++ /dev/null@@ -1,87 +0,0 @@-use std::sync::Arc;-use std::time::Duration;--use tauri::Emitter;-use tokio::sync::Mutex;--use super::lifecycle::is_port_in_use;-use super::sandbox::{Sandbox, SandboxMode};-use super::OpenClawState;--const HEALTH_CHECK_INTERVAL: Duration = Duration::from_secs(15);-const MAX_RESTART_ATTEMPTS: u32 = 3;--/// Spawn a background task that monitors the sandbox health.-/// Returns a JoinHandle that can be used to cancel the monitor.-pub fn spawn_health_monitor(- sandbox: Arc<Mutex<Option<Box<dyn Sandbox>>>>,- state: Arc<OpenClawState>,- app_handle: tauri::AppHandle,-) -> tokio::task::JoinHandle<()> {- tokio::spawn(async move {- let mut was_healthy = true;- let mut restart_count: u32 = 0;-- loop {- tokio::time::sleep(HEALTH_CHECK_INTERVAL).await;-- let mode = state.sandbox_mode.lock().await;- let is_active = matches!(*mode, SandboxMode::Active { .. });- drop(mode);-- if !is_active {- // Sandbox is not active, nothing to monitor- was_healthy = true;- restart_count = 0;- continue;- }-- // Check health by probing the port- let is_healthy = is_port_in_use(super::OPENCLAW_PORT).await;-- if is_healthy && !was_healthy {- // Recovered- log::info!("OpenClaw health restored");- restart_count = 0;- let _ = app_handle.emit("openclaw-health-changed", "healthy");- } else if !is_healthy && was_healthy {- // Became unhealthy- log::warn!("OpenClaw health check failed — gateway not responding");- let _ = app_handle.emit("openclaw-health-changed", "unhealthy");- }-- if !is_healthy && restart_count < MAX_RESTART_ATTEMPTS {- log::info!(- "Attempting auto-restart ({}/{})",- restart_count + 1,- MAX_RESTART_ATTEMPTS- );-- // Attempt restart through the sandbox- let sandbox_guard = sandbox.lock().await;- if let Some(ref sandbox_impl) = *sandbox_guard {- let mut mode = state.sandbox_mode.lock().await;- if let SandboxMode::Active { ref mut handle, .. } = *mode {- // Stop, then restart is handled by the caller re-starting.- // For auto-restart, we just stop and let the next cycle detect it.- let _ = sandbox_impl.stop(handle).await;- }- *mode = SandboxMode::Inactive;- }- drop(sandbox_guard);-- restart_count += 1;-- if restart_count >= MAX_RESTART_ATTEMPTS {- log::error!(- "OpenClaw failed after {} restart attempts",- MAX_RESTART_ATTEMPTS- );- let _ = app_handle.emit("openclaw-failed", "max_restarts_exceeded");- }- }-- was_healthy = is_healthy;- }- })-}diff --git a/src-tauri/src/core/openclaw/lifecycle.rs b/src-tauri/src/core/openclaw/lifecycle.rsdeleted file mode 100644index 1b7303ed9..000000000--- a/src-tauri/src/core/openclaw/lifecycle.rs+++ /dev/null@@ -1,270 +0,0 @@-use std::path::Path;-use std::time::Duration;--use super::sandbox::{- IsolationTier, Sandbox, SandboxConfig, SandboxMode, SandboxStatus,-};-use super::security::ensure_secure_config_permissions;-use super::{get_openclaw_config_dir, OpenClawState, OPENCLAW_PORT};--/// Build a SandboxConfig from the current OpenClaw configuration.-pub fn build_sandbox_config(jan_api_url: &str) -> Result<SandboxConfig, String> {- let config_dir = get_openclaw_config_dir()?;-- Ok(SandboxConfig {- config_dir: config_dir.clone(),- port: OPENCLAW_PORT,- jan_api_url: jan_api_url.to_string(),- env_vars: vec![(- "OPENCLAW_CONFIG".into(),- config_dir- .join("openclaw.json")- .to_string_lossy()- .into_owned(),- )],- })-}--/// Start OpenClaw using the provided sandbox implementation.-pub async fn start_openclaw(- sandbox: &dyn Sandbox,- config: &SandboxConfig,- state: &OpenClawState,-) -> Result<(), String> {- ensure_secure_config_permissions(&config.config_dir).await?;- let _ = patch_config_for_sandbox(sandbox, &config.config_dir)?;- let handle = sandbox.start(config).await?;- wait_for_port(config.port, Duration::from_secs(30)).await?;- let mut mode = state.sandbox_mode.lock().await;- *mode = SandboxMode::Active {- sandbox_name: sandbox.name().to_string(),- isolation_tier: sandbox.isolation_tier(),- handle,- };-- log::info!("OpenClaw started via {} (tier: {})", sandbox.name(), sandbox.isolation_tier());- Ok(())-}--/// Stop OpenClaw regardless of which sandbox type is in use.-pub async fn stop_openclaw(- sandbox: &dyn Sandbox,- state: &OpenClawState,-) -> Result<(), String> {- let mut mode = state.sandbox_mode.lock().await;- match *mode {- SandboxMode::Active {- ref mut handle, ..- } => {- sandbox.stop(handle).await?;- }- SandboxMode::Inactive => {- if is_port_in_use(OPENCLAW_PORT).await {- let mut dummy = super::sandbox::SandboxHandle::Named("stop-fallback".to_string());- sandbox.stop(&mut dummy).await?;- }- }- }- *mode = SandboxMode::Inactive;-- for _i in 0..10 {- if !is_port_in_use(OPENCLAW_PORT).await {- return Ok(());- }- tokio::time::sleep(Duration::from_millis(500)).await;- }-- log::warn!("OpenClaw port may still be in use after stop");- Ok(())-}--/// Get OpenClaw status using the sandbox.-pub async fn get_openclaw_status(- sandbox: &dyn Sandbox,- state: &OpenClawState,-) -> Result<(SandboxStatus, Option<String>, Option<IsolationTier>), String> {- let mode = state.sandbox_mode.lock().await;-- match &*mode {- SandboxMode::Active {- sandbox_name,- isolation_tier,- handle,- } => {- let status = sandbox.status(handle).await?;- Ok((- status,- Some(sandbox_name.clone()),- Some(isolation_tier.clone()),- ))- }- SandboxMode::Inactive => {- if is_port_in_use(OPENCLAW_PORT).await {- Ok((SandboxStatus::Running, None, None))- } else {- Ok((SandboxStatus::Stopped, None, None))- }- }- }-}--/// Poll a port until it responds or timeout.-pub async fn wait_for_port(port: u16, timeout: Duration) -> Result<(), String> {- let start = tokio::time::Instant::now();- let interval = Duration::from_millis(500);-- loop {- if is_port_in_use(port).await {- return Ok(());- }-- if start.elapsed() >= timeout {- return Err(format!(- "Timed out waiting for port {} to respond ({}s)",- port,- timeout.as_secs()- ));- }-- tokio::time::sleep(interval).await;- }-}--/// Check if a port has something listening.-pub async fn is_port_in_use(port: u16) -> bool {- tokio::net::TcpStream::connect(format!("127.0.0.1:{}", port))- .await- .is_ok()-}--/// Patch OpenClaw config for the active sandbox: bind mode, Jan API baseUrl,-/// agent paths, and agent model URLs. Returns `true` if config was modified.-pub fn patch_config_for_sandbox(sandbox: &dyn Sandbox, config_dir: &Path) -> Result<bool, String> {- use super::constants;-- let config_path = config_dir.join("openclaw.json");- if !config_path.exists() {- return Ok(false);- }-- let content = std::fs::read_to_string(&config_path)- .map_err(|e| format!("Failed to read config: {}", e))?;-- let mut config: serde_json::Value = serde_json::from_str(&content)- .map_err(|e| format!("Failed to parse config: {}", e))?;-- let mut modified = false;-- match sandbox.isolation_tier() {- IsolationTier::FullContainer => {- if let Some(bind) = config.pointer_mut("/gateway/bind") {- if bind.as_str() != Some(constants::GATEWAY_BIND_MODE) {- *bind = serde_json::json!(constants::GATEWAY_BIND_MODE);- modified = true;- }- }- if let Some(base_url) = config.pointer_mut("/models/providers/jan/baseUrl") {- if base_url.as_str() != Some(constants::DOCKER_JAN_BASE_URL) {- *base_url = serde_json::json!(constants::DOCKER_JAN_BASE_URL);- modified = true;- }- }- }- IsolationTier::PlatformSandbox | IsolationTier::None => {- if let Some(base_url) = config.pointer_mut("/models/providers/jan/baseUrl") {- if base_url.as_str() != Some(constants::DEFAULT_JAN_BASE_URL) {- *base_url = serde_json::json!(constants::DEFAULT_JAN_BASE_URL);- modified = true;- }- }- }- }-- // Rewrite cross-mode agent paths (Docker ↔ host)- let config_dir_str = config_dir.to_string_lossy();- let docker_prefix = "/home/node/.openclaw/";- let is_docker = matches!(sandbox.isolation_tier(), IsolationTier::FullContainer);-- if let Some(agents_list) = config.pointer_mut("/agents/list") {- if let Some(arr) = agents_list.as_array_mut() {- for agent in arr.iter_mut() {- for field in &["workspace", "agentDir"] {- if let Some(val) = agent.get_mut(*field) {- if let Some(s) = val.as_str() {- if is_docker && !s.starts_with(docker_prefix) && s.contains("/.openclaw/") {- if let Some(pos) = s.find("/.openclaw/") {- let suffix = &s[pos + "/.openclaw/".len()..];- let new_path = format!("{}{}", docker_prefix, suffix);- *val = serde_json::json!(new_path);- modified = true;- }- } else if !is_docker && s.starts_with(docker_prefix) {- let suffix = &s[docker_prefix.len()..];- let new_path = format!("{}/{}", config_dir_str, suffix);- *val = serde_json::json!(new_path);- modified = true;- }- }- }- }- }- }- }-- if modified {- let updated = serde_json::to_string_pretty(&config)- .map_err(|e| format!("Failed to serialize config: {}", e))?;- std::fs::write(&config_path, updated)- .map_err(|e| format!("Failed to write config: {}", e))?;- log::info!("Patched config for {} sandbox", sandbox.name());- }-- // Fix agent models.json baseUrl for current sandbox mode- let target_base_url = if is_docker {- constants::DOCKER_JAN_BASE_URL- } else {- constants::DEFAULT_JAN_BASE_URL- };- let wrong_base_url = if is_docker {- constants::DEFAULT_JAN_BASE_URL- } else {- constants::DOCKER_JAN_BASE_URL- };- patch_agent_models_base_url(config_dir, target_base_url, wrong_base_url);-- Ok(modified)-}--/// Patch baseUrl in all `agents/*/agent/models.json` files for the current sandbox mode.-fn patch_agent_models_base_url(config_dir: &Path, target_url: &str, wrong_url: &str) {- let agents_dir = config_dir.join("agents");- if !agents_dir.exists() {- return;- }-- let entries = match std::fs::read_dir(&agents_dir) {- Ok(e) => e,- Err(_) => return,- };-- for entry in entries.flatten() {- let models_path = entry.path().join("agent").join("models.json");- if !models_path.exists() {- continue;- }-- let content = match std::fs::read_to_string(&models_path) {- Ok(c) => c,- Err(_) => continue,- };-- if !content.contains(wrong_url) {- continue;- }-- let updated = content.replace(wrong_url, target_url);- if let Err(e) = std::fs::write(&models_path, &updated) {- log::warn!("Failed to patch {}: {}", models_path.display(), e);- }- }-}diff --git a/src-tauri/src/core/openclaw/mod.rs b/src-tauri/src/core/openclaw/mod.rsdeleted file mode 100644index 122403b36..000000000--- a/src-tauri/src/core/openclaw/mod.rs+++ /dev/null@@ -1,158 +0,0 @@-pub mod cli;-pub mod commands;-pub mod constants;-pub mod health;-pub mod lifecycle;-pub mod models;-pub mod sandbox;-pub mod sandbox_direct;-#[cfg(feature = "docker")]-pub mod sandbox_docker;-pub mod security;-pub mod tailscale;-pub mod tunnels;--#[cfg(test)]-mod tests;--use std::path::PathBuf;-use std::sync::atomic::{AtomicBool, Ordering};-use std::sync::Arc;--use tokio::sync::Mutex;--use sandbox::{Sandbox, SandboxMode};-use tunnels::TunnelState;--static DOCKER_MODE_ACTIVE: AtomicBool = AtomicBool::new(false);--pub fn set_docker_mode(active: bool) {- DOCKER_MODE_ACTIVE.store(active, Ordering::SeqCst);-}--pub fn is_docker_mode() -> bool {- DOCKER_MODE_ACTIVE.load(Ordering::SeqCst)-}--/// Base directory for all OpenClaw data, rooted under Jan's data folder.-/// Returns `<jan_data_folder>/openclaw/`.-pub fn get_openclaw_base_dir() -> Result<PathBuf, String> {- let jan_data = crate::core::app::commands::resolve_jan_data_folder();- let base = jan_data.join("openclaw");- if !base.exists() {- std::fs::create_dir_all(&base).map_err(|e| e.to_string())?;- }- Ok(base)-}--/// OpenClaw configuration directory, isolated per sandbox mode.-pub fn get_openclaw_config_dir() -> Result<PathBuf, String> {- let home = dirs::home_dir().ok_or("Could not find home directory")?;- let config_dir = if is_docker_mode() {- home.join(".openclaw").join("sandbox").join("docker")- } else {- home.join(".openclaw")- };- if !config_dir.exists() {- std::fs::create_dir_all(&config_dir).map_err(|e| e.to_string())?;- }- Ok(config_dir)-}--/// OpenClaw configuration file path-pub fn get_openclaw_config_path() -> Result<PathBuf, String> {- Ok(get_openclaw_config_dir()?.join("openclaw.json"))-}--/// OpenClaw gateway port-pub const OPENCLAW_PORT: u16 = 18789;--/// Minimum Bun version required-pub const MIN_BUN_VERSION: &str = "1.0";--/// OpenClaw runtime directory (where Bun and OpenClaw are installed)-pub fn get_openclaw_runtime_dir() -> Result<std::path::PathBuf, String> {- let base = get_openclaw_base_dir()?;- let runtime_dir = base.join("bunx");- if !runtime_dir.exists() {- std::fs::create_dir_all(&runtime_dir).map_err(|e| e.to_string())?;- }- Ok(runtime_dir)-}--/// Path to the OpenClaw binary in the runtime directory-pub fn get_openclaw_bin_path() -> Result<std::path::PathBuf, String> {- let runtime_dir = get_openclaw_runtime_dir()?;- let bin_path = if cfg!(target_os = "windows") {- runtime_dir.join("bin").join("openclaw.exe")- } else {- runtime_dir.join("bin").join("openclaw")- };- Ok(bin_path)-}--/// Resolve the bundled Bun path. Returns None if unavailable.-///-/// Looks for bun next to the current executable (same approach as MCP).-pub fn resolve_bundled_bun() -> Option<std::path::PathBuf> {- let bun_name = if cfg!(target_os = "windows") { "bun.exe" } else { "bun" };-- if let Ok(exe_path) = std::env::current_exe() {- if let Some(bin_path) = exe_path.parent() {- let candidate = bin_path.join(bun_name);- if candidate.exists() {- let s = candidate.to_string_lossy().to_string();- if jan_utils::system::can_override_npx(s) {- return Some(candidate);- }- }- }- }-- None-}--pub const PATH_SEPARATOR: &str = if cfg!(target_os = "windows") { ";" } else { ":" };--/// Prepend bundled Bun dir and openclaw-runtime/bin to PATH.-pub fn build_augmented_path() -> Option<String> {- let mut path_entries = Vec::new();- if let Some(bun_path) = resolve_bundled_bun() {- if let Some(bun_dir) = bun_path.parent() {- path_entries.push(bun_dir.to_string_lossy().to_string());- }- }- if let Ok(runtime_dir) = get_openclaw_runtime_dir() {- path_entries.push(runtime_dir.join("bin").to_string_lossy().to_string());- }- if path_entries.is_empty() {- return None;- }- let current_path = std::env::var("PATH").unwrap_or_default();- Some(format!(- "{}{}{}",- path_entries.join(PATH_SEPARATOR),- PATH_SEPARATOR,- current_path- ))-}--/// OpenClaw Manager state-pub struct OpenClawState {- /// Tunnel state for managing tunnel processes- pub tunnel_state: TunnelState,- /// Current sandbox mode (inactive or active with handle)- pub sandbox_mode: Arc<Mutex<SandboxMode>>,- /// Detected sandbox implementation (set once on first use via detect_sandbox())- pub sandbox: Arc<Mutex<Option<Box<dyn Sandbox>>>>,-}--impl Default for OpenClawState {- fn default() -> Self {- Self {- tunnel_state: TunnelState::default(),- sandbox_mode: Arc::new(Mutex::new(SandboxMode::Inactive)),- sandbox: Arc::new(Mutex::new(None)),- }- }-}diff --git a/src-tauri/src/core/openclaw/models.rs b/src-tauri/src/core/openclaw/models.rsdeleted file mode 100644index 1eab056d8..000000000--- a/src-tauri/src/core/openclaw/models.rs+++ /dev/null@@ -1,639 +0,0 @@-use serde::{Deserialize, Serialize};--use super::constants;--/// OpenClaw configuration structure-/// Only includes keys that OpenClaw actually recognizes.-/// Unknown keys (like agents.defaults.systemPrompt) cause OpenClaw to reject the config.-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct OpenClawConfig {- /// Gateway configuration- pub gateway: GatewayConfig,- /// Model providers configuration- pub models: ModelsConfig,-}--impl Default for OpenClawConfig {- fn default() -> Self {- Self {- gateway: GatewayConfig::default(),- models: ModelsConfig::default(),- }- }-}--/// Gateway configuration-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct GatewayConfig {- /// Gateway mode: "local" (run server here) or "remote" (connect to remote)- pub mode: String,- /// Bind address (loopback or 0.0.0.0)- pub bind: String,- /// Port number- pub port: u16,- /// Authentication configuration- pub auth: AuthConfig,- /// Control UI configuration (for WebSocket origin validation)- #[serde(rename = "controlUi", skip_serializing_if = "Option::is_none")]- pub control_ui: Option<ControlUiConfig>,-}--impl Default for GatewayConfig {- fn default() -> Self {- Self {- mode: "local".to_string(),- bind: "lan".to_string(),- port: super::OPENCLAW_PORT,- auth: AuthConfig::default(),- control_ui: Some(ControlUiConfig::default()),- }- }-}--/// Control UI configuration for the Gateway-/// This controls WebSocket origin validation for security-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ControlUiConfig {- /// Allowed origins for WebSocket connections- /// Required for non-loopback connections (e.g., from Tauri apps)- #[serde(rename = "allowedOrigins")]- pub allowed_origins: Vec<String>,-}--impl Default for ControlUiConfig {- fn default() -> Self {- Self {- // Allow connections from Tauri app and local development- allowed_origins: vec![- "tauri://localhost".to_string(),- "http://tauri.localhost".to_string(),- "http://localhost".to_string(),- "http://localhost:1420".to_string(), // Tauri dev server- "http://127.0.0.1".to_string(),- ],- }- }-}--/// Authentication configuration-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct AuthConfig {- /// Authentication mode (token, etc.)- pub mode: String,-}--impl Default for AuthConfig {- fn default() -> Self {- Self {- mode: "token".to_string(),- }- }-}--/// Models configuration-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ModelsConfig {- /// Provider configurations- pub providers: ProvidersConfig,-}--impl Default for ModelsConfig {- fn default() -> Self {- Self {- providers: ProvidersConfig::default(),- }- }-}--/// Providers configuration-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ProvidersConfig {- /// Jan provider configuration- #[serde(rename = "jan")]- pub jan: JanProviderConfig,-}--impl Default for ProvidersConfig {- fn default() -> Self {- Self {- jan: JanProviderConfig::default(),- }- }-}--/// A single model definition for OpenClaw's provider config.-/// Only `id` and `name` are required by OpenClaw's Zod schema.-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ModelDefinition {- /// Model identifier (plain name, no provider prefix)- pub id: String,- /// Human-readable display name- pub name: String,- /// Context window size in tokens- #[serde(rename = "contextWindow", skip_serializing_if = "Option::is_none")]- pub context_window: Option<u32>,- /// Maximum output tokens- #[serde(rename = "maxTokens", skip_serializing_if = "Option::is_none")]- pub max_tokens: Option<u32>,-}--/// Jan provider configuration-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct JanProviderConfig {- /// Base URL for Jan API- #[serde(rename = "baseUrl")]- pub base_url: String,- /// API type (openai-completions, etc.)- pub api: String,- /// API key for authentication.- /// For local models this is a placeholder (Jan doesn't require auth).- /// For remote providers routed through Jan, this carries the real key.- #[serde(rename = "apiKey")]- pub api_key: String,- /// List of model definitions (objects with at least { id, name })- pub models: Vec<ModelDefinition>,-}--impl Default for JanProviderConfig {- fn default() -> Self {- Self {- base_url: constants::DEFAULT_JAN_BASE_URL.to_string(),- api: constants::DEFAULT_JAN_API_TYPE.to_string(),- api_key: constants::DEFAULT_JAN_API_KEY.to_string(),- // Start with the pinned default model; openclaw_sync_all_models- // replaces this list with the full catalog from Jan.- models: vec![ModelDefinition {- id: constants::DEFAULT_MODEL_ID.to_string(),- name: constants::DEFAULT_MODEL_ID.to_string(),- context_window: Some(128000),- max_tokens: Some(4096),- }],- }- }-}--// NOTE: OpenClaw uses strict Zod validation on its config — unknown keys-// cause the gateway to refuse to start. The `agents.defaults` section accepts-// known keys like `model` (object: {primary, fallbacks}), `maxConcurrent`,-// `subagents`, `compaction`, `workspace`, etc. Custom keys like `systemPrompt`-// are NOT valid and will be rejected. See: https://docs.openclaw.ai/gateway/configuration-reference--/// OpenClaw status response-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct OpenClawStatus {- /// Whether OpenClaw is installed- pub installed: bool,- /// Whether the gateway is running- pub running: bool,- /// Runtime version (Bun or Node.js, if installed)- pub runtime_version: Option<String>,- /// Installed OpenClaw version (if installed)- pub openclaw_version: Option<String>,- /// Port status (available or in use)- pub port_available: bool,- /// Error message (if any)- pub error: Option<String>,- /// Active sandbox type name (e.g., "Linux Namespaces", "WSL2", "Docker", "Direct Process")- #[serde(skip_serializing_if = "Option::is_none")]- pub sandbox_type: Option<String>,- /// Isolation tier ("none", "platform_sandbox", "full_container")- #[serde(skip_serializing_if = "Option::is_none")]- pub isolation_tier: Option<String>,-}--/// Node.js check result-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct NodeCheckResult {- /// Whether Node.js is installed- pub installed: bool,- /// Node.js version (if installed)- pub version: Option<String>,- /// Major version number- pub major_version: Option<u32>,- /// Whether the version meets minimum requirements (22+)- pub meets_requirements: bool,- /// Error message (if any)- pub error: Option<String>,-}--/// Installation result-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct InstallResult {- /// Whether installation was successful- pub success: bool,- /// Installed version (if successful)- pub version: Option<String>,- /// Error message (if failed)- pub error: Option<String>,-}--/// Port check result-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct PortCheckResult {- /// Whether the port is available- pub available: bool,- /// The port number checked- pub port: u16,- /// Error message (if any)- pub error: Option<String>,-}--/// Custom configuration input for OpenClaw-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct OpenClawConfigInput {- /// Optional custom Jan base URL- #[serde(rename = "janBaseUrl")]- pub jan_base_url: Option<String>,- /// Optional custom model ID (sets agents.defaults.model.primary)- #[serde(rename = "modelId")]- pub model_id: Option<String>,- /// Optional custom port- pub port: Option<u16>,- /// Optional bind address- pub bind: Option<String>,- /// Optional API key for Jan's local API server- #[serde(rename = "janApiKey")]- pub jan_api_key: Option<String>,-}--// ============================================-// Tailscale Integration Models-// ============================================--/// Tailscale installation and connection status-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TailscaleStatus {- /// Whether Tailscale is installed on the system- pub installed: bool,- /// Whether Tailscale daemon is running- pub running: bool,- /// Whether user is logged in to Tailscale- pub logged_in: bool,- /// Tailscale version (if installed)- pub version: Option<String>,- /// Error message (if any)- pub error: Option<String>,-}--impl Default for TailscaleStatus {- fn default() -> Self {- Self {- installed: false,- running: false,- logged_in: false,- version: None,- error: None,- }- }-}--/// Tailscale network information-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TailscaleInfo {- /// Machine hostname in the tailnet- pub hostname: Option<String>,- /// Name of the tailnet- pub tailnet: Option<String>,- /// Tailscale IP addresses assigned to this machine- pub ip_addresses: Vec<String>,- /// DNS name for this machine in the tailnet- pub dns_name: Option<String>,- /// Whether Tailscale Serve is enabled- pub serve_enabled: bool,- /// Whether Tailscale Funnel is enabled- pub funnel_enabled: bool,- /// URL for accessing via Tailscale Serve/Funnel- pub serve_url: Option<String>,-}--impl Default for TailscaleInfo {- fn default() -> Self {- Self {- hostname: None,- tailnet: None,- ip_addresses: Vec::new(),- dns_name: None,- serve_enabled: false,- funnel_enabled: false,- serve_url: None,- }- }-}--// ============================================-// Tunnel Provider Models-// ============================================--/// Available tunnel providers-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]-#[serde(rename_all = "lowercase")]-pub enum TunnelProvider {- #[default]- None,- Tailscale,- Ngrok,- Cloudflare,- LocalOnly,-}--/// Status of a tunnel provider-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TunnelProviderStatus {- /// The tunnel provider type- pub provider: TunnelProvider,- /// Whether the provider CLI is installed- pub installed: bool,- /// Whether the provider is authenticated- pub authenticated: bool,- /// Version of the installed CLI (if available)- pub version: Option<String>,- /// Error message if detection failed- pub error: Option<String>,-}--impl Default for TunnelProviderStatus {- fn default() -> Self {- Self {- provider: TunnelProvider::None,- installed: false,- authenticated: false,- version: None,- error: None,- }- }-}--/// Status of all tunnel providers-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TunnelProvidersStatus {- /// Tailscale status- pub tailscale: TunnelProviderStatus,- /// ngrok status- pub ngrok: TunnelProviderStatus,- /// Cloudflare (cloudflared) status- pub cloudflare: TunnelProviderStatus,- /// Currently active/preferred provider- pub active_provider: TunnelProvider,- /// Currently active tunnel information (if any)- pub active_tunnel: Option<TunnelInfo>,-}--impl Default for TunnelProvidersStatus {- fn default() -> Self {- Self {- tailscale: TunnelProviderStatus {- provider: TunnelProvider::Tailscale,- ..Default::default()- },- ngrok: TunnelProviderStatus {- provider: TunnelProvider::Ngrok,- ..Default::default()- },- cloudflare: TunnelProviderStatus {- provider: TunnelProvider::Cloudflare,- ..Default::default()- },- active_provider: TunnelProvider::None,- active_tunnel: None,- }- }-}--/// Active tunnel information-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct TunnelInfo {- /// The tunnel provider being used- pub provider: TunnelProvider,- /// Public URL for the tunnel- pub url: String,- /// ISO 8601 timestamp when tunnel started- pub started_at: String,- /// Local port being tunneled- pub port: u16,- /// Whether the tunnel is publicly accessible- pub is_public: bool,-}--/// Tunnel configuration stored in config file-#[derive(Debug, Clone, Serialize, Deserialize, Default)]-pub struct TunnelConfig {- /// Preferred tunnel provider- pub preferred_provider: TunnelProvider,- /// ngrok authentication token- pub ngrok_auth_token: Option<String>,- /// Cloudflare tunnel ID- pub cloudflare_tunnel_id: Option<String>,- /// Whether to auto-start tunnel when OpenClaw starts- pub auto_start: bool,-}--// ============================================-// Security Configuration Models-// ============================================--/// Authentication mode for the gateway-#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]-#[serde(rename_all = "lowercase")]-pub enum AuthMode {- #[default]- Token,- Password,- None,-}--/// Security configuration for OpenClaw gateway-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct SecurityConfig {- /// Authentication mode (token, password, or none)- pub auth_mode: AuthMode,- /// Hashed access token (if auth_mode is Token)- pub token_hash: Option<String>,- /// Hashed password (if auth_mode is Password)- pub password_hash: Option<String>,- /// Whether device pairing is required- pub require_pairing: bool,- /// List of approved devices- pub approved_devices: Vec<DeviceInfo>,- /// Maximum authentication attempts before rate limiting- pub rate_limit_attempts: u32,- /// Time window for rate limiting in seconds- pub rate_limit_window_secs: u32,-}--impl Default for SecurityConfig {- fn default() -> Self {- Self {- auth_mode: AuthMode::Token,- token_hash: None,- password_hash: None,- require_pairing: true,- approved_devices: vec![],- rate_limit_attempts: 5,- rate_limit_window_secs: 300,- }- }-}--/// Approved device information-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct DeviceInfo {- /// Unique device identifier- pub id: String,- /// Human-readable device name- pub name: String,- /// Communication channel (telegram, whatsapp, discord)- pub channel: String,- /// User ID on the channel- pub user_id: String,- /// ISO 8601 timestamp when device was approved- pub approved_at: String,- /// ISO 8601 timestamp of last access (if any)- pub last_access: Option<String>,-}--/// Access log entry for security auditing-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct AccessLogEntry {- /// ISO 8601 timestamp of the event- pub timestamp: String,- /// Device ID (if known)- pub device_id: Option<String>,- /// Communication channel- pub channel: String,- /// User ID on the channel- pub user_id: String,- /// Action performed (message, pairing, auth_success, auth_fail)- pub action: String,- /// IP address (if available)- pub ip_address: Option<String>,- /// Whether the action was successful- pub success: bool,- /// Error message (if any)- pub error: Option<String>,-}--/// Entry for bulk model sync from Jan to OpenClaw-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct ModelSyncEntry {- /// Model ID (e.g., "llama-3.2-3b", "gpt-4o")- #[serde(rename = "modelId")]- pub model_id: String,- /// Jan's internal provider name (e.g., "llamacpp", "openai", "anthropic")- pub provider: String,- /// Human-readable display name- #[serde(rename = "displayName")]- pub display_name: String,- /// Context window size from Jan's model settings (ctx_len). None = use default.- #[serde(rename = "contextWindow")]- pub context_window: Option<u32>,-}--/// Result of bulk model sync-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct BulkSyncResult {- /// Number of models synced- pub synced_count: u32,- /// Default model that was set (if any)- pub default_model: Option<String>,-}--// ============================================-// 1-Click Enable Models-// ============================================--/// Steps in the 1-click enable flow-#[derive(Debug, Clone, Serialize, Deserialize)]-pub enum EnableStep {- CheckingDependencies,- CheckingInstallation,- Installing,- Configuring,- Starting,- ValidatingConfig,- SyncingModels,-}--/// Result of the 1-click enable orchestrator-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct EnableResult {- /// Whether the enable flow completed successfully- pub success: bool,- /// Whether OpenClaw was already installed before this run- pub already_installed: bool,- /// Steps that were completed- pub steps_completed: Vec<EnableStep>,- /// Final OpenClaw status- pub status: OpenClawStatus,-}--/// Progress event emitted during the enable flow-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct EnableProgressEvent {- /// Current step identifier- pub step: String,- /// Progress percentage (0-100)- pub progress: u32,- /// Human-readable message- pub message: String,- /// Optional sandbox info for display (e.g., "Linux Namespaces", "Docker 24.0.7")- #[serde(skip_serializing_if = "Option::is_none")]- pub sandbox_info: Option<String>,-}--/// Error with recovery options for the enable flow-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct EnableError {- /// Error code for programmatic handling- pub code: EnableErrorCode,- /// Human-readable error message- pub message: String,- /// Recovery options the user can take- pub recovery: Vec<RecoveryOption>,-}--/// Error codes for the enable flow-#[derive(Debug, Clone, Serialize, Deserialize)]-pub enum EnableErrorCode {- RuntimeNotFound,- RuntimeVersionTooLow,- InstallFailed,- PortInUse,- ConfigWriteFailed,- GatewayStartFailed,- ValidationFailed,-}--/// A recovery option the user can take-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct RecoveryOption {- /// Button label- pub label: String,- /// Recovery action type- pub action: RecoveryAction,- /// Description of what this action does- pub description: String,-}--/// Recovery actions the frontend can execute-#[derive(Debug, Clone, Serialize, Deserialize)]-pub enum RecoveryAction {- Retry,- UseDifferentPort { port: u16 },-}--/// Security status response for the frontend-#[derive(Debug, Clone, Serialize, Deserialize)]-pub struct SecurityStatus {- /// Current authentication mode- pub auth_mode: AuthMode,- /// Whether an access token has been configured- pub has_token: bool,- /// Whether a password has been configured- pub has_password: bool,- /// Whether device pairing is required- pub require_pairing: bool,- /// Number of approved devices- pub approved_device_count: u32,- /// Number of recent authentication failures- pub recent_auth_failures: u32,-}\ No newline at end of filediff --git a/src-tauri/src/core/openclaw/sandbox.rs b/src-tauri/src/core/openclaw/sandbox.rsdeleted file mode 100644index adc3cc280..000000000--- a/src-tauri/src/core/openclaw/sandbox.rs+++ /dev/null@@ -1,109 +0,0 @@-use serde::{Deserialize, Serialize};-use std::path::PathBuf;--/// Configuration passed to any sandbox implementation.-/// Platform-agnostic — no Docker-specific, WSL-specific, or namespace-specific fields.-pub struct SandboxConfig {- /// Path to the OpenClaw config directory on the host (~/.openclaw/)- pub config_dir: PathBuf,- /// The port OpenClaw should listen on- pub port: u16,- /// The Jan API base URL that OpenClaw should connect to- pub jan_api_url: String,- /// Environment variables to pass to the OpenClaw process- pub env_vars: Vec<(String, String)>,-}--/// Opaque handle returned by `start()`. Each implementation stores what it needs.-pub enum SandboxHandle {- /// PID-based handle (Linux namespaces, macOS)- Pid(u32),- /// Named handle (WSL2 distro name, Docker container name)- Named(String),- /// Process handle for direct process fallback- Process(tokio::process::Child),-}--#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]-pub enum SandboxStatus {- Running,- Stopped,- Failed { error: String },- Unknown,-}--#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]-#[serde(rename_all = "snake_case")]-pub enum IsolationTier {- /// Tier 0: No isolation (direct process)- None,- /// Tier 2: Namespace/VM isolation (bubblewrap, WSL2, Apple Containerization)- PlatformSandbox,- /// Tier 3: Full OCI container (Docker/Podman)- FullContainer,-}--impl std::fmt::Display for IsolationTier {- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {- match self {- IsolationTier::None => write!(f, "none"),- IsolationTier::PlatformSandbox => write!(f, "platform_sandbox"),- IsolationTier::FullContainer => write!(f, "full_container"),- }- }-}--#[async_trait::async_trait]-pub trait Sandbox: Send + Sync {- /// Human-readable name for this sandbox type- fn name(&self) -> &str;-- /// The isolation tier this sandbox provides- fn isolation_tier(&self) -> IsolationTier;-- /// Returns true if this sandbox mechanism is available on the current system- async fn is_available(&self) -> bool;-- /// Start OpenClaw in the sandbox. Returns a handle for subsequent operations.- async fn start(&self, config: &SandboxConfig) -> Result<SandboxHandle, String>;-- /// Stop the sandboxed OpenClaw process.- async fn stop(&self, handle: &mut SandboxHandle) -> Result<(), String>;-- /// Check current status of the sandboxed process.- async fn status(&self, handle: &SandboxHandle) -> Result<SandboxStatus, String>;-- /// Retrieve recent log lines from the sandboxed process.- async fn logs(&self, handle: &SandboxHandle, lines: usize) -> Result<Vec<String>, String>;-}--/// Active sandbox mode — stored in OpenClawState.-pub enum SandboxMode {- /// No sandbox active- Inactive,- /// Sandbox is running- Active {- sandbox_name: String,- isolation_tier: IsolationTier,- handle: SandboxHandle,- },-}--impl Default for SandboxMode {- fn default() -> Self {- SandboxMode::Inactive- }-}--/// Auto-detect the best available sandbox: Docker if available, otherwise direct process.-pub async fn detect_sandbox() -> Box<dyn Sandbox> {- #[cfg(feature = "docker")]- {- let docker = super::sandbox_docker::DockerSandbox::new();- if docker.is_available().await {- return Box::new(docker);- }- }-- Box::new(super::sandbox_direct::DirectProcessSandbox)-}diff --git a/src-tauri/src/core/openclaw/sandbox_apple.rs b/src-tauri/src/core/openclaw/sandbox_apple.rsdeleted file mode 100644index 75683d347..000000000--- a/src-tauri/src/core/openclaw/sandbox_apple.rs+++ /dev/null@@ -1,275 +0,0 @@-/// Apple Containerization Framework sandbox for macOS 26+ (Tahoe).-///-/// Delegates to a Swift helper binary (`container-helper`) that wraps-/// Apple's Containerization.framework. This follows the same pattern as-/// the `mlx-server` integration: a Swift binary built separately and-/// bundled in `src-tauri/resources/bin/`.-///-/// The helper communicates via a simple JSON protocol over stdout.-///-/// Network model: the helper configures the container with host networking,-/// so `localhost:1337` reaches Jan's API without config patching.-#[cfg(target_os = "macos")]-use std::process::Stdio;--#[cfg(target_os = "macos")]-use super::sandbox::{IsolationTier, Sandbox, SandboxConfig, SandboxHandle, SandboxStatus};--#[cfg(target_os = "macos")]-const HELPER_BINARY: &str = "container-helper";--#[cfg(target_os = "macos")]-pub struct AppleContainerSandbox;--#[cfg(target_os = "macos")]-impl AppleContainerSandbox {- /// Check if the macOS version is 26.0 (Tahoe) or later.- async fn is_macos_26_or_later() -> bool {- match tokio::process::Command::new("sw_vers")- .args(["-productVersion"])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- {- Ok(output) => {- let version = String::from_utf8_lossy(&output.stdout);- let trimmed = version.trim();- let parts: Vec<&str> = trimmed.split('.').collect();- if let Some(major) = parts.first() {- if let Ok(major_num) = major.parse::<u32>() {- return major_num >= 26;- }- }- log::info!(- "AppleContainerSandbox: could not parse macOS version: '{}'",- trimmed- );- false- }- Err(e) => {- log::info!("AppleContainerSandbox: sw_vers failed: {}", e);- false- }- }- }-- /// Resolve the path to the container-helper binary from Tauri resources.- fn helper_path() -> Option<std::path::PathBuf> {- // Try the standard resource locations- let candidates = [- std::path::PathBuf::from("resources/bin").join(HELPER_BINARY),- // In development, the binary might be at the src-tauri level- std::path::PathBuf::from("src-tauri/resources/bin").join(HELPER_BINARY),- ];-- for candidate in &candidates {- if candidate.exists() {- return Some(candidate.clone());- }- }-- // Try resolving relative to the current executable- if let Ok(exe_path) = std::env::current_exe() {- if let Some(exe_dir) = exe_path.parent() {- let resource_path = exe_dir.join("resources/bin").join(HELPER_BINARY);- if resource_path.exists() {- return Some(resource_path);- }- // macOS .app bundle: Contents/MacOS/../Resources/- let bundle_path = exe_dir- .join("../Resources/resources/bin")- .join(HELPER_BINARY);- if bundle_path.exists() {- return Some(bundle_path);- }- }- }-- None- }-}--#[cfg(target_os = "macos")]-#[async_trait::async_trait]-impl Sandbox for AppleContainerSandbox {- fn name(&self) -> &str {- "Apple Containerization"- }-- fn isolation_tier(&self) -> IsolationTier {- IsolationTier::PlatformSandbox- }-- async fn is_available(&self) -> bool {- if !Self::is_macos_26_or_later().await {- log::info!("AppleContainerSandbox: macOS version < 26");- return false;- }-- if Self::helper_path().is_none() {- log::info!("AppleContainerSandbox: container-helper binary not found");- return false;- }-- true- }-- async fn start(&self, config: &SandboxConfig) -> Result<SandboxHandle, String> {- let helper = Self::helper_path()- .ok_or("container-helper binary not found in resources")?;-- log::info!(- "AppleContainerSandbox: starting via {:?}",- helper- );-- let output = tokio::process::Command::new(&helper)- .args([- "start",- "--config-dir",- &config.config_dir.to_string_lossy(),- "--port",- &config.port.to_string(),- "--jan-api-url",- &config.jan_api_url,- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run container-helper: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("container-helper start failed: {}", stderr));- }-- // Parse JSON output: {"container_id": "..."}- let stdout = String::from_utf8_lossy(&output.stdout);- let parsed: serde_json::Value = serde_json::from_str(stdout.trim())- .map_err(|e| format!("Failed to parse container-helper output: {}", e))?;-- let container_id = parsed- .get("container_id")- .and_then(|v| v.as_str())- .ok_or("container-helper did not return container_id")?- .to_string();-- log::info!(- "AppleContainerSandbox: started container '{}'",- container_id- );- Ok(SandboxHandle::Named(container_id))- }-- async fn stop(&self, handle: &mut SandboxHandle) -> Result<(), String> {- let container_id = match handle {- SandboxHandle::Named(id) => id.clone(),- _ => return Err("Invalid handle for AppleContainerSandbox".to_string()),- };-- let helper = Self::helper_path()- .ok_or("container-helper binary not found")?;-- log::info!(- "AppleContainerSandbox: stopping container '{}'",- container_id- );-- let output = tokio::process::Command::new(&helper)- .args(["stop", "--container-id", &container_id])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to run container-helper stop: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("AppleContainerSandbox: stop returned error: {}", stderr);- }-- Ok(())- }-- async fn status(&self, handle: &SandboxHandle) -> Result<SandboxStatus, String> {- // Primary check: port connectivity- match tokio::net::TcpStream::connect(format!("127.0.0.1:{}", super::OPENCLAW_PORT)).await {- Ok(_) => return Ok(SandboxStatus::Running),- Err(_) => {}- }-- // Secondary check: ask the helper- let container_id = match handle {- SandboxHandle::Named(id) => id.clone(),- _ => return Ok(SandboxStatus::Unknown),- };-- if let Some(helper) = Self::helper_path() {- let output = tokio::process::Command::new(&helper)- .args(["status", "--container-id", &container_id])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await;-- if let Ok(output) = output {- if output.status.success() {- let stdout = String::from_utf8_lossy(&output.stdout);- if let Ok(parsed) = serde_json::from_str::<serde_json::Value>(stdout.trim()) {- if parsed.get("running").and_then(|v| v.as_bool()) == Some(true) {- return Ok(SandboxStatus::Running);- }- }- }- }- }-- Ok(SandboxStatus::Stopped)- }-- async fn logs(- &self,- handle: &SandboxHandle,- lines: usize,- ) -> Result<Vec<String>, String> {- let container_id = match handle {- SandboxHandle::Named(id) => id.clone(),- _ => return Ok(vec!["Invalid handle".to_string()]),- };-- let helper = match Self::helper_path() {- Some(p) => p,- None => return Ok(vec!["container-helper not found".to_string()]),- };-- let output = tokio::process::Command::new(&helper)- .args([- "logs",- "--container-id",- &container_id,- "--lines",- &lines.to_string(),- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to read container logs: {}", e))?;-- if output.status.success() {- let stdout = String::from_utf8_lossy(&output.stdout);- // Try to parse as JSON array, fall back to raw lines- if let Ok(log_lines) = serde_json::from_str::<Vec<String>>(stdout.trim()) {- Ok(log_lines)- } else {- Ok(stdout.lines().map(String::from).collect())- }- } else {- Ok(vec![- "Failed to retrieve logs from Apple Container sandbox.".to_string(),- ])- }- }-}diff --git a/src-tauri/src/core/openclaw/sandbox_direct.rs b/src-tauri/src/core/openclaw/sandbox_direct.rsdeleted file mode 100644index 628c108de..000000000--- a/src-tauri/src/core/openclaw/sandbox_direct.rs+++ /dev/null@@ -1,322 +0,0 @@-use std::process::Stdio;--use super::sandbox::{IsolationTier, Sandbox, SandboxConfig, SandboxHandle, SandboxStatus};--pub struct DirectProcessSandbox;--/// Returns the BUN_INSTALL directory under Jan's data folder, creating it if needed.-fn get_bunx_dir() -> Option<std::path::PathBuf> {- let dir = super::get_openclaw_base_dir().ok()?.join("bunx");- if let Err(e) = std::fs::create_dir_all(&dir) {- log::warn!("Failed to create BUN_INSTALL dir {:?}: {}", dir, e);- }- Some(dir)-}--/// Installs openclaw globally into the BUN_INSTALL dir using `bun add -g openclaw`.-/// After this, the binary lives at `$BUN_INSTALL/bin/openclaw[.exe]`.-async fn install_openclaw_globally() -> Result<(), String> {- let bun_path = super::resolve_bundled_bun().ok_or("Bundled bun not found")?;- let bunx_dir = get_bunx_dir().ok_or("Could not resolve home directory")?;-- log::info!("Installing openclaw globally into {:?}", bunx_dir);-- let mut cmd = tokio::process::Command::new(&bun_path);- cmd.args(["add", "-g", &format!("openclaw@{}", super::constants::OPENCLAW_VERSION)])- .env("BUN_INSTALL", &bunx_dir)- .stdout(Stdio::piped())- .stderr(Stdio::piped());-- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);- }-- let output = cmd.output().await.map_err(|e| format!("Failed to run bun add -g openclaw: {}", e))?;- log::info!("bun add -g openclaw stdout: {}", String::from_utf8_lossy(&output.stdout).trim());- log::info!("bun add -g openclaw stderr: {}", String::from_utf8_lossy(&output.stderr).trim());-- if !output.status.success() {- return Err(format!(- "bun add -g openclaw failed: {}",- String::from_utf8_lossy(&output.stderr).trim()- ));- }-- Ok(())-}--/// Build a command that runs the globally-installed openclaw binary from BUN_INSTALL/bin/.-/// Falls back to `bun x openclaw` if the installed binary is not found.-fn build_openclaw_command(args: &[&str], config_dir: &std::path::Path) -> tokio::process::Command {- let bunx_dir = get_bunx_dir();-- let installed_bin = bunx_dir.as_ref().map(|d| {- if cfg!(target_os = "windows") {- d.join("bin").join("openclaw.exe")- } else {- d.join("bin").join("openclaw")- }- });-- let mut cmd = if installed_bin.as_ref().map(|p| p.exists()).unwrap_or(false) {- let bin = installed_bin.unwrap();- #[cfg(not(target_os = "windows"))]- let cmd = {- log::info!("Running openclaw via node from installed path: {:?}", bin);- let mut c = tokio::process::Command::new("node");- c.arg(&bin);- c- };- #[cfg(target_os = "windows")]- let cmd = {- log::info!("Running openclaw from installed path: {:?}", bin);- tokio::process::Command::new(&bin)- };- cmd- } else if let Some(bun) = super::resolve_bundled_bun() {- log::info!("openclaw not installed yet, falling back to bun x");- let mut c = tokio::process::Command::new(bun);- c.arg("x");- c.arg("openclaw");- c- } else {- tokio::process::Command::new("openclaw")- };-- cmd.args(args)- .stdout(Stdio::piped())- .stderr(Stdio::piped());-- if let Some(dir) = bunx_dir {- cmd.env("BUN_INSTALL", dir);- }-- // if let Some(new_path) = super::build_augmented_path() {- // cmd.env("PATH", new_path);- // }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);- }-- cmd-}--#[async_trait::async_trait]-impl Sandbox for DirectProcessSandbox {- fn name(&self) -> &str {- "Direct Process"- }-- fn isolation_tier(&self) -> IsolationTier {- IsolationTier::None- }-- async fn is_available(&self) -> bool {- true // Always available as fallback- }-- async fn start(&self, config: &SandboxConfig) -> Result<SandboxHandle, String> {- let use_child_process = if cfg!(target_os = "windows") {- true- } else {- if let Err(e) = install_openclaw_globally().await {- log::warn!("openclaw global install failed, will attempt to run anyway: {}", e);- }- let install_args = vec!["gateway", "install"];- let mut install_cmd = build_openclaw_command(&install_args.iter().map(|s| *s).collect::<Vec<_>>(), &config.config_dir);- match install_cmd.output().await {- Ok(output) if output.status.success() => false,- Ok(output) => {- let stderr = String::from_utf8_lossy(&output.stderr);- log::error!("gateway install failed: {}", stderr.trim());- true- }- Err(e) => {- log::error!("Failed to run gateway install: {}", e);- true- }- }- };-- if !use_child_process {-- let mut cmd =- build_openclaw_command(&["gateway", "start"], &config.config_dir);- for (key, value) in &config.env_vars {- cmd.env(key, value);- }--- let mut child = cmd- .spawn()- .map_err(|e| format!("Failed to spawn openclaw gateway: {}", e))?;-- // Drain stdout and stderr in background so the pipes don't block- if let Some(stdout) = child.stdout.take() {- tokio::spawn(async move {- use tokio::io::{AsyncBufReadExt, BufReader};- let mut lines = BufReader::new(stdout).lines();- while let Ok(Some(line)) = lines.next_line().await {- log::info!("openclaw stdout: {}", line);- }- });- }- if let Some(stderr) = child.stderr.take() {- tokio::spawn(async move {- use tokio::io::{AsyncBufReadExt, BufReader};- let mut lines = BufReader::new(stderr).lines();- while let Ok(Some(line)) = lines.next_line().await {- log::info!("openclaw stderr: {}", line);- }- });- }-- // Log when the process exits- let pid = child.id();- tokio::spawn(async move {- // We can't await the child here since we've already moved it into the handle,- // so poll the port instead as a proxy for the process being alive.- loop {- tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;- let alive = tokio::net::TcpStream::connect(- format!("127.0.0.1:{}", super::OPENCLAW_PORT)- ).await.is_ok();- if !alive {- log::warn!("openclaw gateway process (pid {:?}) appears to have exited", pid);- break;- }- }- });-- Ok(SandboxHandle::Process(child))- } else {- log::info!("Starting gateway as child process");- let mut cmd = build_openclaw_command(&["gateway"], &config.config_dir);- cmd.stdin(Stdio::null())- .stdout(Stdio::null())- .stderr(Stdio::null());- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- // CREATE_NO_WINDOW only — DETACHED_PROCESS conflicts and can- // cause Windows to allocate a visible console for the child.- cmd.creation_flags(0x08000000);- }- for (key, value) in &config.env_vars {- cmd.env(key, value);- }-- let child = cmd- .spawn()- .map_err(|e| format!("Failed to spawn openclaw gateway: {}", e))?;-- Ok(SandboxHandle::Process(child))- }- }-- async fn stop(&self, handle: &mut SandboxHandle) -> Result<(), String> {- if let SandboxHandle::Process(child) = handle {- #[cfg(target_os = "windows")]- {- if let Some(pid) = child.id() {- use std::os::windows::process::CommandExt;- let mut cmd = tokio::process::Command::new("taskkill");- cmd.args(["/F", "/T", "/PID", &pid.to_string()]);- cmd.creation_flags(0x08000000);- let _ = cmd.output().await;- } else {- let _ = child.kill().await;- }- }- #[cfg(not(target_os = "windows"))]- {- let _ = child.kill().await;- }- return Ok(());- }-- let mut stopped_via_cli = false;- let config_dir =- super::get_openclaw_config_dir().unwrap_or_else(|_| std::path::PathBuf::from("."));- let mut stop_cmd = build_openclaw_command(&["gateway", "stop"], &config_dir);- if let Ok(output) = stop_cmd.output().await {- stopped_via_cli = output.status.success();- }-- if !stopped_via_cli {- #[cfg(any(target_os = "macos", target_os = "linux"))]- {- let _ = tokio::process::Command::new("pkill")- .args(["-f", "openclaw"])- .output()- .await;- }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- let kill = |im: &'static str| async move {- let mut cmd = tokio::process::Command::new("taskkill");- cmd.args(["/F", "/T", "/IM", im]);- cmd.creation_flags(0x08000000);- let _ = cmd.output().await;- };- kill("bun.exe").await;- kill("node.exe").await;- kill("openclaw.exe").await;- }- }-- // Port-based kill fallback- if tokio::net::TcpStream::connect(format!("127.0.0.1:{}", super::OPENCLAW_PORT))- .await- .is_ok()- {- log::warn!(- "Port {} still in use after stop attempts, trying port-based kill",- super::OPENCLAW_PORT- );- #[cfg(any(target_os = "macos", target_os = "linux"))]- {- let _ = tokio::process::Command::new("sh")- .args([- "-c",- &format!("lsof -ti :{} | xargs kill -9", super::OPENCLAW_PORT),- ])- .output()- .await;- }-- #[cfg(target_os = "windows")]- {- use std::os::windows::process::CommandExt;- let mut cmd = tokio::process::Command::new("cmd");- cmd.args(["/C", &format!("for /f \"tokens=5\" %%a in ('netstat -aon ^| findstr :{} ^| findstr LISTENING') do taskkill /F /T /PID %%a", super::OPENCLAW_PORT)]);- cmd.creation_flags(0x08000000);- let _ = cmd.output().await;- }- }-- Ok(())- }-- async fn status(&self, _handle: &SandboxHandle) -> Result<SandboxStatus, String> {- match tokio::net::TcpStream::connect(format!("127.0.0.1:{}", super::OPENCLAW_PORT)).await {- Ok(_) => Ok(SandboxStatus::Running),- Err(_) => Ok(SandboxStatus::Stopped),- }- }-- async fn logs(&self, _handle: &SandboxHandle, _lines: usize) -> Result<Vec<String>, String> {- Ok(vec!["Check /tmp/openclaw/ for logs.".to_string()])- }-}diff --git a/src-tauri/src/core/openclaw/sandbox_docker.rs b/src-tauri/src/core/openclaw/sandbox_docker.rsdeleted file mode 100644index 54e00ea89..000000000--- a/src-tauri/src/core/openclaw/sandbox_docker.rs+++ /dev/null@@ -1,593 +0,0 @@-/// Docker/Podman sandbox using Bollard (pure Rust Docker API client).-///-/// This is an optional Tier 3 sandbox — only used if Docker is already installed.-/// Jan never prompts users to install Docker. Bollard also works with Podman's-/// Docker-compatible socket, so this implementation covers both.-///-/// Security hardening (Phase 3):-/// - cap_drop: ALL — drop all Linux capabilities-/// - cap_add: NET_BIND_SERVICE only — minimum needed for port binding-/// - readonly_rootfs: true — container filesystem is read-only-/// - tmpfs at /tmp — writable scratch space (noexec, nosuid)-/// - no-new-privileges — prevent privilege escalation via setuid binaries-/// - pids_limit: 256 — prevent fork bombs-/// - memory: 512MB — prevent memory exhaustion-/// - nano_cpus: 1 CPU — prevent CPU starvation of host-/// - seccomp profile — custom syscall allowlist loaded from resources-///-/// Network model: Docker uses network isolation. The config patching in-/// `lifecycle.rs` replaces `localhost:1337` with `host.docker.internal:1337`-/// for `IsolationTier::FullContainer`.-#[cfg(feature = "docker")]-use std::collections::HashMap;--#[cfg(feature = "docker")]-use bollard::container::{- Config, CreateContainerOptions, ListContainersOptions, LogsOptions, RemoveContainerOptions,- StartContainerOptions, StopContainerOptions,-};-#[cfg(feature = "docker")]-use bollard::image::CreateImageOptions;-#[cfg(feature = "docker")]-use bollard::models::{HostConfig, PortBinding, PortMap};-#[cfg(feature = "docker")]-use futures::StreamExt;--#[cfg(feature = "docker")]-use super::sandbox::{IsolationTier, Sandbox, SandboxConfig, SandboxHandle, SandboxStatus};-#[cfg(feature = "docker")]-use super::constants::OPENCLAW_VERSION;--#[cfg(feature = "docker")]-const CONTAINER_NAME: &str = "jan-openclaw";--#[cfg(feature = "docker")]-const IMAGE_REPO: &str = "ghcr.io/openclaw/openclaw";--#[cfg(feature = "docker")]-fn image_name() -> String {- format!("{}:{}", IMAGE_REPO, OPENCLAW_VERSION)-}--#[cfg(feature = "docker")]-pub struct DockerSandbox;--#[cfg(feature = "docker")]-impl DockerSandbox {- pub fn new() -> Self {- Self- }-- /// Check if Docker is available and the OpenClaw container exists.- /// Returns Some(true) if container exists, Some(false) if Docker available but no container,- /// None if Docker is not available.- pub async fn is_installed() -> Option<bool> {- let client = match Self::get_client().await {- Ok(c) => c,- Err(_) => return None,- };-- // Check if Docker is responding- if client.ping().await.is_err() {- return None;- }-- // Check if container exists- Some(Self::container_exists(&client).await)- }-- async fn get_client() -> Result<bollard::Docker, String> {- // Windows: Docker Desktop uses a named pipe (//./pipe/docker_engine).- // connect_with_local_defaults() handles this and DOCKER_HOST.- #[cfg(target_os = "windows")]- {- return bollard::Docker::connect_with_local_defaults()- .map_err(|e| format!("Failed to connect to Docker: {}", e));- }-- // macOS/Linux: try DOCKER_HOST, then probe known socket paths.- #[cfg(not(target_os = "windows"))]- {- if std::env::var("DOCKER_HOST").is_ok() {- return bollard::Docker::connect_with_local_defaults()- .map_err(|e| format!("Failed to connect to Docker: {}", e));- }-- let mut candidates: Vec<String> = vec![- "/var/run/docker.sock".to_string(),- ];-- if let Ok(home) = std::env::var("HOME") {- candidates.push(format!("{}/.docker/run/docker.sock", home));- }-- #[cfg(target_os = "linux")]- {- let uid = unsafe { libc::getuid() };- candidates.push(format!("/run/user/{}/docker.sock", uid));- }-- for socket_path in &candidates {- if !std::path::Path::new(socket_path).exists() {- continue;- }- let uri = format!("unix://{}", socket_path);- match bollard::Docker::connect_with_socket(- &uri,- 120,- &bollard::API_DEFAULT_VERSION,- ) {- Ok(client) => {- log::info!("DockerSandbox: connected via {}", socket_path);- return Ok(client);- }- Err(e) => {- log::info!("DockerSandbox: socket {} found but connect failed: {}", socket_path, e);- }- }- }-- // Fallback for non-standard socket locations (Colima, Rancher Desktop, etc.)- bollard::Docker::connect_with_local_defaults()- .map_err(|_| "Failed to connect to Docker: no working socket found".to_string())- }- }-- /// Check if the jan-openclaw container already exists (running or stopped).- async fn container_exists(client: &bollard::Docker) -> bool {- let mut filters = HashMap::new();- filters.insert("name", vec![CONTAINER_NAME]);-- let options = ListContainersOptions {- all: true,- filters,- ..Default::default()- };-- match client.list_containers(Some(options)).await {- Ok(containers) => !containers.is_empty(),- Err(_) => false,- }- }-- /// Check if the image exists locally (internal).- async fn image_exists(client: &bollard::Docker) -> bool {- client.inspect_image(&image_name()).await.is_ok()- }-- /// Check if the Docker image is available locally (public).- /// Returns true if Docker is available AND the image exists.- pub async fn is_image_available() -> bool {- let client = match Self::get_client().await {- Ok(c) => c,- Err(_) => return false,- };- Self::image_exists(&client).await- }-- /// Load the custom seccomp profile from the resources directory.- /// Returns the JSON string if found, None otherwise.- /// The Docker daemon will use its default seccomp profile as fallback.- fn load_seccomp_profile() -> Option<String> {- // Try resource locations- let candidates = [- std::path::PathBuf::from("resources/openclaw-seccomp.json"),- std::path::PathBuf::from("src-tauri/resources/openclaw-seccomp.json"),- ];-- for candidate in &candidates {- if let Ok(content) = std::fs::read_to_string(candidate) {- return Some(content);- }- }-- // Try relative to current executable (production builds)- if let Ok(exe_path) = std::env::current_exe() {- if let Some(exe_dir) = exe_path.parent() {- let resource_path = exe_dir.join("resources/openclaw-seccomp.json");- if let Ok(content) = std::fs::read_to_string(&resource_path) {- return Some(content);- }- // macOS .app bundle- let bundle_path = exe_dir.join("../Resources/resources/openclaw-seccomp.json");- if let Ok(content) = std::fs::read_to_string(&bundle_path) {- return Some(content);- }- }- }-- log::info!("DockerSandbox: seccomp profile not found, using Docker default");- None- }-- /// Pull the OpenClaw image (internal, no progress events).- async fn pull_image(client: &bollard::Docker) -> Result<(), String> {- let img = image_name();- log::info!("DockerSandbox: pulling image {}", img);-- let options = CreateImageOptions {- from_image: img.as_str(),- ..Default::default()- };-- let mut stream = client.create_image(Some(options), None, None);-- while let Some(result) = stream.next().await {- match result {- Ok(info) => {- if let Some(status) = info.status {- log::debug!("DockerSandbox: pull: {}", status);- }- }- Err(e) => {- return Err(format!("Failed to pull image {}: {}", img, e));- }- }- }-- log::info!("DockerSandbox: image pulled successfully");- Ok(())- }-- /// Pull the Docker image if not already present, emitting progress events.- /// Called from `openclaw_enable()` to provide real-time feedback during the- /// potentially long image download.- pub async fn pull_image_if_needed_with_progress(- app: &tauri::AppHandle,- sandbox_info: Option<&str>,- ) -> Result<(), String> {- use tauri::Emitter;- use super::models::EnableProgressEvent;-- let client = Self::get_client().await?;-- let img = image_name();-- // Check if image already exists locally- if Self::image_exists(&client).await {- log::info!("DockerSandbox: image {} already exists locally", img);- let _ = app.emit(- "openclaw-enable-progress",- EnableProgressEvent {- step: "installing".to_string(),- progress: 55,- message: "Docker image already available.".to_string(),- sandbox_info: sandbox_info.map(|s| s.to_string()),- },- );- return Ok(());- }-- log::info!("DockerSandbox: pulling image {} with progress", img);-- let options = CreateImageOptions {- from_image: img.as_str(),- ..Default::default()- };-- let mut stream = client.create_image(Some(options), None, None);-- // Track per-layer progress to compute aggregate percentage.- // Docker reports current/total per layer — we sum across all layers- // so the progress bar only moves forward.- let mut layer_current: std::collections::HashMap<String, i64> = std::collections::HashMap::new();- let mut layer_total: std::collections::HashMap<String, i64> = std::collections::HashMap::new();- let mut last_progress_pct: u32 = 40; // Start at 40% (where installing step begins)-- while let Some(result) = stream.next().await {- match result {- Ok(info) => {- // Update per-layer byte tracking- if let Some(ref id) = info.id {- if let Some(ref detail) = info.progress_detail {- if let (Some(current), Some(total)) = (detail.current, detail.total) {- if total > 0 {- layer_current.insert(id.clone(), current);- layer_total.insert(id.clone(), total);- }- }- }- }-- // Compute aggregate progress across all layers- let sum_current: i64 = layer_current.values().sum();- let sum_total: i64 = layer_total.values().sum();- if sum_total > 0 {- let pct = (sum_current as f64 / sum_total as f64 * 15.0) as u32 + 40;- // Only move forward — never let the bar go backward- let clamped = pct.min(55);- if clamped > last_progress_pct {- last_progress_pct = clamped;- }- }-- if let Some(ref status) = info.status {- if status.contains("Pulling") || status.contains("Downloading")- || status.contains("Extracting") || status.contains("Pull complete")- || status.contains("Already exists")- {- let display_msg = if let Some(ref id) = info.id {- format!("{}: {}", status, id)- } else {- status.clone()- };-- let _ = app.emit(- "openclaw-enable-progress",- EnableProgressEvent {- step: "installing".to_string(),- progress: last_progress_pct,- message: format!("Pulling image... {}", display_msg),- sandbox_info: sandbox_info.map(|s| s.to_string()),- },- );- }- }-- log::debug!("DockerSandbox: pull: {:?}", info.status);- }- Err(e) => {- return Err(format!("Failed to pull image {}: {}", img, e));- }- }- }-- log::info!("DockerSandbox: image pulled successfully");- let _ = app.emit(- "openclaw-enable-progress",- EnableProgressEvent {- step: "installing".to_string(),- progress: 58,- message: "Docker image pulled successfully.".to_string(),- sandbox_info: sandbox_info.map(|s| s.to_string()),- },- );-- Ok(())- }-}--#[cfg(feature = "docker")]-#[async_trait::async_trait]-impl Sandbox for DockerSandbox {- fn name(&self) -> &str {- "Docker"- }-- fn isolation_tier(&self) -> IsolationTier {- IsolationTier::FullContainer- }-- async fn is_available(&self) -> bool {- match Self::get_client().await {- Ok(client) => {- match client.ping().await {- Ok(_) => {- log::info!("DockerSandbox: Docker daemon is responsive");- true- }- Err(e) => {- log::info!("DockerSandbox: Docker ping failed: {}", e);- false- }- }- }- Err(e) => {- log::info!("DockerSandbox: {}", e);- false- }- }- }-- async fn start(&self, config: &SandboxConfig) -> Result<SandboxHandle, String> {- let client = Self::get_client().await?;-- // Pull image if not present- if !Self::image_exists(&client).await {- Self::pull_image(&client).await?;- }-- // Remove existing container if it exists (stopped from a previous run)- if Self::container_exists(&client).await {- log::info!("DockerSandbox: removing existing container '{}'", CONTAINER_NAME);- let _ = client- .remove_container(- CONTAINER_NAME,- Some(RemoveContainerOptions {- force: true,- ..Default::default()- }),- )- .await;- }-- // Build port bindings: 127.0.0.1:18789 -> 18789/tcp- let port_key = format!("{}/tcp", config.port);- let mut port_bindings: PortMap = HashMap::new();- port_bindings.insert(- port_key.clone(),- Some(vec![PortBinding {- host_ip: Some("127.0.0.1".to_string()),- host_port: Some(config.port.to_string()),- }]),- );-- // Build environment variables- // Note: the official OpenClaw image runs as user `node` (home = /home/node)- let mut env_vars: Vec<String> = config- .env_vars- .iter()- .filter(|(k, _)| k != "OPENCLAW_CONFIG") // Remove host path, we set the container path below- .map(|(k, v)| format!("{}={}", k, v))- .collect();- // Override config path for inside the container (node user's home)- env_vars.push("OPENCLAW_CONFIG=/home/node/.openclaw/openclaw.json".to_string());- // V8 default heap limit on arm64 is ~512MB which is too small for OpenClaw.- // Explicitly raise it so the gateway doesn't OOM during startup.- env_vars.push("NODE_OPTIONS=--max-old-space-size=768".to_string());-- // Build volume bind: ~/.openclaw -> /home/node/.openclaw- // The official image runs as `node` user, NOT root- let host_config_dir = config.config_dir.to_string_lossy();- let binds = vec![format!("{}:/home/node/.openclaw", host_config_dir)];-- // Build extra hosts for Docker-to-host networking- let extra_hosts = vec!["host.docker.internal:host-gateway".to_string()];-- // Writable tmpfs mounts on top of the read-only root filesystem.- // /tmp — general scratch space for Node.js and OpenClaw- // /home/node/.npm — npm cache (plugin enable/install writes here)- // /home/node/.cache — generic cache dir used by various Node tools- let mut tmpfs = HashMap::new();- tmpfs.insert(- "/tmp".to_string(),- "rw,noexec,nosuid,size=65536k".to_string(),- );- tmpfs.insert(- "/home/node/.npm".to_string(),- "rw,noexec,nosuid,size=131072k".to_string(),- );- tmpfs.insert(- "/home/node/.cache".to_string(),- "rw,noexec,nosuid,size=131072k".to_string(),- );-- // Security: load custom seccomp profile if available- let seccomp_profile = Self::load_seccomp_profile();- let mut security_opt = vec!["no-new-privileges".to_string()];- if let Some(profile_json) = seccomp_profile {- security_opt.push(format!("seccomp={}", profile_json));- log::info!("DockerSandbox: custom seccomp profile loaded");- }-- let host_config = HostConfig {- port_bindings: Some(port_bindings),- binds: Some(binds),- extra_hosts: Some(extra_hosts),- // Security hardening- cap_drop: Some(vec!["ALL".to_string()]),- cap_add: Some(vec!["NET_BIND_SERVICE".to_string()]),- readonly_rootfs: Some(true),- tmpfs: Some(tmpfs),- security_opt: Some(security_opt),- pids_limit: Some(256),- memory: Some(1024 * 1024 * 1024), // 1 GB — Node.js V8 heap needs headroom- nano_cpus: Some(1_000_000_000), // 1 CPU- ..Default::default()- };-- let mut exposed_ports = HashMap::new();- exposed_ports.insert(port_key, HashMap::new());-- let container_config = Config {- image: Some(image_name()),- env: Some(env_vars),- exposed_ports: Some(exposed_ports),- host_config: Some(host_config),- ..Default::default()- };-- let options = CreateContainerOptions {- name: CONTAINER_NAME,- platform: None,- };-- log::info!("DockerSandbox: creating container '{}'", CONTAINER_NAME);- client- .create_container(Some(options), container_config)- .await- .map_err(|e| format!("Failed to create Docker container: {}", e))?;-- log::info!("DockerSandbox: starting container '{}'", CONTAINER_NAME);- client- .start_container(CONTAINER_NAME, None::<StartContainerOptions<String>>)- .await- .map_err(|e| format!("Failed to start Docker container: {}", e))?;-- Ok(SandboxHandle::Named(CONTAINER_NAME.to_string()))- }-- async fn stop(&self, _handle: &mut SandboxHandle) -> Result<(), String> {- let client = Self::get_client().await?;-- log::info!("DockerSandbox: stopping container '{}'", CONTAINER_NAME);-- // Stop with a 10-second grace period- let _ = client- .stop_container(- CONTAINER_NAME,- Some(StopContainerOptions { t: 10 }),- )- .await;-- // Remove the container- let _ = client- .remove_container(- CONTAINER_NAME,- Some(RemoveContainerOptions {- force: true,- ..Default::default()- }),- )- .await;-- log::info!("DockerSandbox: container '{}' stopped and removed", CONTAINER_NAME);- Ok(())- }-- async fn status(&self, _handle: &SandboxHandle) -> Result<SandboxStatus, String> {- let client = match Self::get_client().await {- Ok(c) => c,- Err(_) => return Ok(SandboxStatus::Unknown),- };-- match client.inspect_container(CONTAINER_NAME, None).await {- Ok(info) => {- if let Some(state) = info.state {- if state.running == Some(true) {- return Ok(SandboxStatus::Running);- }- if let Some(error) = state.error {- if !error.is_empty() {- return Ok(SandboxStatus::Failed { error });- }- }- }- Ok(SandboxStatus::Stopped)- }- Err(_) => Ok(SandboxStatus::Stopped),- }- }-- async fn logs(- &self,- _handle: &SandboxHandle,- lines: usize,- ) -> Result<Vec<String>, String> {- let client = Self::get_client().await?;-- let options = LogsOptions::<String> {- stdout: true,- stderr: true,- tail: lines.to_string(),- ..Default::default()- };-- let mut stream = client.logs(CONTAINER_NAME, Some(options));- let mut log_lines = Vec::new();-- while let Some(result) = stream.next().await {- match result {- Ok(output) => {- log_lines.push(output.to_string());- }- Err(e) => {- log::warn!("DockerSandbox: error reading logs: {}", e);- break;- }- }- }-- Ok(log_lines)- }-}diff --git a/src-tauri/src/core/openclaw/sandbox_wsl2.rs b/src-tauri/src/core/openclaw/sandbox_wsl2.rsdeleted file mode 100644index 3be4e8211..000000000--- a/src-tauri/src/core/openclaw/sandbox_wsl2.rs+++ /dev/null@@ -1,365 +0,0 @@-/// WSL2-based sandbox for Windows.-///-/// Uses the `wsl` CLI to manage a dedicated "Jan.OpenClaw" WSL2 distribution.-/// The distribution runs a minimal Linux environment with OpenClaw installed.-/// WSL2 provides VM-level isolation (separate Linux kernel in Hyper-V).-///-/// Security hardening (Phase 3):-/// - Non-root user: OpenClaw runs as `openclaw` user (UID 1001) inside the distro-/// - Resource limits: ulimit -v (memory), ulimit -n (files), ulimit -u (procs)-/// - WSL2 already provides VM-level isolation (Hyper-V lightweight VM)-/// - Users can further limit resources via .wslconfig (memory, processors)-///-/// Network model: WSL2 default NAT mode — the guest can reach the Windows host-/// via `localhost`, so Jan's API at `localhost:1337` is accessible without-/// config patching.-#[cfg(target_os = "windows")]-use std::process::Stdio;--#[cfg(target_os = "windows")]-use super::sandbox::{IsolationTier, Sandbox, SandboxConfig, SandboxHandle, SandboxStatus};--#[cfg(target_os = "windows")]-const DISTRO_NAME: &str = "Jan.OpenClaw";--#[cfg(target_os = "windows")]-pub struct Wsl2Sandbox {- distro_name: String,-}--#[cfg(target_os = "windows")]-impl Wsl2Sandbox {- pub fn new() -> Self {- Self {- distro_name: DISTRO_NAME.to_string(),- }- }-- /// Check if WSL2 is available by probing wslapi.dll and running wsl --status.- async fn check_wsl2_available() -> bool {- // Step 1: Verify wslapi.dll exists (means WSL feature is installed)- if unsafe { libloading::Library::new("wslapi.dll") }.is_err() {- log::info!("Wsl2Sandbox: wslapi.dll not available");- return false;- }-- // Step 2: Verify WSL2 is functional by running wsl --status- match tokio::process::Command::new("wsl")- .args(["--status"])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- {- Ok(output) => {- if !output.status.success() {- log::info!("Wsl2Sandbox: wsl --status failed");- return false;- }- true- }- Err(e) => {- log::info!("Wsl2Sandbox: failed to run wsl --status: {}", e);- false- }- }- }-- /// Check if the Jan.OpenClaw distribution is registered.- async fn is_distro_registered(&self) -> bool {- match tokio::process::Command::new("wsl")- .args(["--list", "--quiet"])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- {- Ok(output) => {- let stdout = String::from_utf8_lossy(&output.stdout);- stdout- .lines()- .any(|line| line.trim() == self.distro_name)- }- Err(_) => false,- }- }-- /// Get the installation directory for the WSL2 distro.- fn install_dir(&self) -> std::path::PathBuf {- dirs::data_dir()- .unwrap_or_else(|| std::path::PathBuf::from("C:\\"))- .join("Jan")- .join("wsl")- .join(&self.distro_name)- }-- /// Get the expected rootfs path from Tauri resources.- fn rootfs_path(&self) -> std::path::PathBuf {- // The rootfs tar.gz is expected in the resources/wsl/ directory.- // This is a build-time artifact — if not present, start() fails gracefully.- std::path::PathBuf::from("resources")- .join("wsl")- .join("jan-openclaw-rootfs.tar.gz")- }-- /// Register the distro from a rootfs tar.gz.- async fn register_distro(&self, rootfs_path: &std::path::Path) -> Result<(), String> {- let install_dir = self.install_dir();- std::fs::create_dir_all(&install_dir)- .map_err(|e| format!("Failed to create WSL install dir: {}", e))?;-- let output = tokio::process::Command::new("wsl")- .args([- "--import",- &self.distro_name,- &install_dir.to_string_lossy(),- &rootfs_path.to_string_lossy(),- "--version",- "2",- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to register WSL2 distro: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("WSL2 distro registration failed: {}", stderr));- }-- log::info!(- "Wsl2Sandbox: registered distro '{}' from {:?}",- self.distro_name,- rootfs_path- );- Ok(())- }-- /// Set up security inside the distro after import.- /// Creates a non-root `openclaw` user (UID 1001) and sets it as the default user.- async fn setup_distro_security(&self) -> Result<(), String> {- // Create the openclaw user if it doesn't exist- let setup_script = concat!(- "id -u openclaw >/dev/null 2>&1 || ",- "(addgroup -g 1001 openclaw 2>/dev/null || true; ",- "adduser -u 1001 -G openclaw -s /bin/sh -D openclaw 2>/dev/null || true; ",- "mkdir -p /home/openclaw/.openclaw; ",- "chown -R openclaw:openclaw /home/openclaw)"- );-- let output = tokio::process::Command::new("wsl")- .args([- "-d",- &self.distro_name,- "--user",- "root",- "--",- "sh",- "-c",- setup_script,- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to setup distro security: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!(- "Wsl2Sandbox: security setup had warnings (non-fatal): {}",- stderr- );- }-- log::info!(- "Wsl2Sandbox: security setup complete for distro '{}'",- self.distro_name- );- Ok(())- }-- /// Convert a Windows path to a WSL-compatible path.- /// e.g., C:\Users\foo\.openclaw -> /mnt/c/Users/foo/.openclaw- fn windows_to_wsl_path(win_path: &std::path::Path) -> String {- let path_str = win_path.to_string_lossy();- // Replace backslashes with forward slashes- let unix_path = path_str.replace('\\', "/");- // Convert drive letter: C:/... -> /mnt/c/...- if unix_path.len() >= 2 && unix_path.as_bytes()[1] == b':' {- let drive = unix_path.as_bytes()[0].to_ascii_lowercase() as char;- format!("/mnt/{}/{}", drive, &unix_path[3..])- } else {- unix_path- }- }-}--#[cfg(target_os = "windows")]-#[async_trait::async_trait]-impl Sandbox for Wsl2Sandbox {- fn name(&self) -> &str {- "WSL2"- }-- fn isolation_tier(&self) -> IsolationTier {- IsolationTier::PlatformSandbox- }-- async fn is_available(&self) -> bool {- Self::check_wsl2_available().await- }-- async fn start(&self, config: &SandboxConfig) -> Result<SandboxHandle, String> {- log::info!(- "Wsl2Sandbox: starting OpenClaw in WSL2 distro '{}' (hardened)",- self.distro_name- );-- // Register distro if not already present- if !self.is_distro_registered().await {- let rootfs = self.rootfs_path();- if !rootfs.exists() {- return Err(format!(- "WSL2 rootfs not found at {:?}. \- The WSL2 sandbox requires a bundled rootfs which is not yet available. \- Falling back to direct process mode.",- rootfs- ));- }- self.register_distro(&rootfs).await?;- }-- // Security: set up non-root user inside the distro- if let Err(e) = self.setup_distro_security().await {- log::warn!("Wsl2Sandbox: security setup failed (non-fatal): {}", e);- }-- // Convert the host config dir to a WSL-compatible path- let wsl_config_dir = Self::windows_to_wsl_path(&config.config_dir);-- // Start OpenClaw inside the WSL2 distro as non-root user with resource limits.- // The sh -c wrapper applies ulimit constraints before launching openclaw:- // ulimit -v 524288 : virtual memory limit (512 MB in KB)- // ulimit -n 4096 : max open file descriptors- // ulimit -u 256 : max user processes- // ulimit -c 0 : disable core dumps- let start_script = format!(- "ulimit -v 524288; ulimit -n 4096; ulimit -u 256; ulimit -c 0; \- export OPENCLAW_CONFIG='{}/openclaw.json'; \- exec openclaw gateway start",- wsl_config_dir- );-- let mut cmd = tokio::process::Command::new("wsl");- cmd.args([- "-d",- &self.distro_name,- "--user",- "openclaw",- "--",- "sh",- "-c",- &start_script,- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped());-- // Pass environment variables- for (key, value) in &config.env_vars {- cmd.env(key, value);- }-- let output = cmd- .output()- .await- .map_err(|e| format!("Failed to start OpenClaw in WSL2: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("OpenClaw start in WSL2 failed: {}", stderr));- }-- log::info!(- "Wsl2Sandbox: OpenClaw started in distro '{}' as user 'openclaw'",- self.distro_name- );- Ok(SandboxHandle::Named(self.distro_name.clone()))- }-- async fn stop(&self, _handle: &mut SandboxHandle) -> Result<(), String> {- log::info!("Wsl2Sandbox: terminating distro '{}'", self.distro_name);-- // First try to gracefully stop OpenClaw inside the distro- let _ = tokio::process::Command::new("wsl")- .args([- "-d",- &self.distro_name,- "--",- "openclaw",- "gateway",- "stop",- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await;-- // Then terminate the entire distro- let output = tokio::process::Command::new("wsl")- .args(["--terminate", &self.distro_name])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to terminate WSL2 distro: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("Wsl2Sandbox: terminate returned error: {}", stderr);- }-- Ok(())- }-- async fn status(&self, _handle: &SandboxHandle) -> Result<SandboxStatus, String> {- // Check if the gateway is responding on its port- match tokio::net::TcpStream::connect(format!("127.0.0.1:{}", super::OPENCLAW_PORT)).await {- Ok(_) => Ok(SandboxStatus::Running),- Err(_) => Ok(SandboxStatus::Stopped),- }- }-- async fn logs(- &self,- _handle: &SandboxHandle,- lines: usize,- ) -> Result<Vec<String>, String> {- let output = tokio::process::Command::new("wsl")- .args([- "-d",- &self.distro_name,- "--",- "tail",- "-n",- &lines.to_string(),- "/tmp/openclaw/gateway.log",- ])- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await- .map_err(|e| format!("Failed to read WSL2 logs: {}", e))?;-- if output.status.success() {- let stdout = String::from_utf8_lossy(&output.stdout);- Ok(stdout.lines().map(String::from).collect())- } else {- Ok(vec![- "Log retrieval from WSL2 distro failed. Check /tmp/openclaw/ inside the distro."- .to_string(),- ])- }- }-}diff --git a/src-tauri/src/core/openclaw/security.rs b/src-tauri/src/core/openclaw/security.rsdeleted file mode 100644index 016c4e4ea..000000000--- a/src-tauri/src/core/openclaw/security.rs+++ /dev/null@@ -1,352 +0,0 @@-//! Security configuration module for OpenClaw gateway-//!-//! Handles authentication tokens, device pairing, and access logging-//! for the OpenClaw remote access feature.--use chrono::Utc;-use sha2::{Digest, Sha256};-use uuid::Uuid;--use super::get_openclaw_config_dir;-use super::models::{AccessLogEntry, DeviceInfo, SecurityConfig};--#[cfg(unix)]-use std::os::unix::fs::PermissionsExt;--/// Checks and fixes permissions on the OpenClaw config directory.-///-/// Ensures the config directory has restrictive permissions (700) to prevent-/// unauthorized access to sensitive files like security tokens and credentials.-/// This is called before starting any sandbox to ensure the config is secure.-pub async fn ensure_secure_config_permissions(config_dir: &std::path::Path) -> Result<(), String> {- #[cfg(unix)]- {- // Ensure the config directory exists- if !config_dir.exists() {- tokio::fs::create_dir_all(config_dir)- .await- .map_err(|e| format!("Failed to create config dir: {}", e))?;- }-- let metadata = tokio::fs::metadata(config_dir)- .await- .map_err(|e| format!("Cannot stat config dir: {}", e))?;-- let mode = metadata.permissions().mode() & 0o777;-- // Check if group/other have any permissions- if mode & 0o077 != 0 {- let mut perms = metadata.permissions();- perms.set_mode(0o700);- tokio::fs::set_permissions(config_dir, perms)- .await- .map_err(|e| format!("Cannot fix config dir permissions: {}", e))?;- log::info!("Fixed ~/.openclaw permissions to 700");- }- }-- #[cfg(not(unix))]- {- // On non-Unix systems (Windows), we don't have the same permission model- // but we still ensure the directory exists- if !config_dir.exists() {- tokio::fs::create_dir_all(config_dir)- .await- .map_err(|e| format!("Failed to create config dir: {}", e))?;- }- }-- Ok(())-}--/// Maximum number of access log entries to keep-const MAX_ACCESS_LOG_ENTRIES: usize = 1000;--/// Security configuration file name-const SECURITY_CONFIG_FILE: &str = "security.json";--/// Access logs file name-const ACCESS_LOGS_FILE: &str = "access_logs.json";--/// Generate a new secure access token-///-/// Returns a UUID-based token that can be used for authentication.-pub fn generate_access_token() -> String {- Uuid::new_v4().to_string()-}--/// Hash an access token or password for storage-///-/// Uses SHA-256 to create a secure hash of the input.-pub fn hash_token(token: &str) -> String {- let mut hasher = Sha256::new();- hasher.update(token.as_bytes());- let result = hasher.finalize();- hex::encode(result)-}--/// Verify a token or password against a stored hash-///-/// Returns true if the token matches the stored hash.-pub fn verify_token(token: &str, hash: &str) -> bool {- let token_hash = hash_token(token);- token_hash == hash-}--/// Generate a pairing code for device authentication-///-/// Returns an 8-character alphanumeric code that's easy to type.-pub fn generate_pairing_code() -> String {- use rand::Rng;-- let mut rng = rand::thread_rng();- let chars: Vec<char> = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"- .chars()- .collect();-- (0..8)- .map(|_| {- let idx = rng.gen_range(0..chars.len());- chars[idx]- })- .collect()-}--/// Get the path to the security configuration file-fn get_security_config_path() -> Result<std::path::PathBuf, String> {- let config_dir = get_openclaw_config_dir()?;- Ok(config_dir.join(SECURITY_CONFIG_FILE))-}--/// Get the path to the access logs file-fn get_access_logs_path() -> Result<std::path::PathBuf, String> {- let config_dir = get_openclaw_config_dir()?;- Ok(config_dir.join(ACCESS_LOGS_FILE))-}--/// Load the security configuration from disk-pub async fn load_security_config() -> Result<SecurityConfig, String> {- let config_path = get_security_config_path()?;-- if !config_path.exists() {- return Ok(SecurityConfig::default());- }-- let config_json = tokio::fs::read_to_string(&config_path)- .await- .map_err(|e| format!("Failed to read security config: {}", e))?;-- serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse security config: {}", e))-}--/// Save the security configuration to disk-pub async fn save_security_config(config: &SecurityConfig) -> Result<(), String> {- let config_path = get_security_config_path()?;-- let config_json = serde_json::to_string_pretty(config)- .map_err(|e| format!("Failed to serialize security config: {}", e))?;-- tokio::fs::write(&config_path, config_json)- .await- .map_err(|e| format!("Failed to write security config: {}", e))?;-- Ok(())-}--/// Record an access log entry-///-/// Appends the entry to the access logs file, rotating if necessary.-pub async fn log_access(entry: AccessLogEntry) -> Result<(), String> {- let logs_path = get_access_logs_path()?;-- // Load existing logs- let mut logs = load_access_logs_internal(&logs_path).await?;-- // Add new entry- logs.push(entry);-- // Rotate if we exceed the maximum- if logs.len() > MAX_ACCESS_LOG_ENTRIES {- let excess = logs.len() - MAX_ACCESS_LOG_ENTRIES;- logs.drain(0..excess);- }-- // Save back to disk- let logs_json = serde_json::to_string_pretty(&logs)- .map_err(|e| format!("Failed to serialize access logs: {}", e))?;-- tokio::fs::write(&logs_path, logs_json)- .await- .map_err(|e| format!("Failed to write access logs: {}", e))?;-- Ok(())-}--/// Load access logs from the file-async fn load_access_logs_internal(path: &std::path::Path) -> Result<Vec<AccessLogEntry>, String> {- if !path.exists() {- return Ok(Vec::new());- }-- let logs_json = tokio::fs::read_to_string(path)- .await- .map_err(|e| format!("Failed to read access logs: {}", e))?;-- serde_json::from_str(&logs_json)- .map_err(|e| format!("Failed to parse access logs: {}", e))-}--/// Get recent access logs-///-/// Returns the most recent `limit` entries.-pub async fn get_access_logs(limit: usize) -> Result<Vec<AccessLogEntry>, String> {- let logs_path = get_access_logs_path()?;- let logs = load_access_logs_internal(&logs_path).await?;-- // Return the most recent entries- let start = if logs.len() > limit {- logs.len() - limit- } else {- 0- };-- Ok(logs[start..].to_vec())-}--/// Clear all access logs-pub async fn clear_access_logs() -> Result<(), String> {- let logs_path = get_access_logs_path()?;-- if logs_path.exists() {- tokio::fs::write(&logs_path, "[]")- .await- .map_err(|e| format!("Failed to clear access logs: {}", e))?;- }-- Ok(())-}--/// Add a device to the approved list-pub async fn approve_device(device: DeviceInfo) -> Result<(), String> {- let mut config = load_security_config().await?;-- // Check if device already exists (by ID)- let existing_index = config.approved_devices- .iter()- .position(|d| d.id == device.id);-- if let Some(index) = existing_index {- // Update existing device- config.approved_devices[index] = device;- } else {- // Add new device- config.approved_devices.push(device);- }-- save_security_config(&config).await-}--/// Remove a device from the approved list-pub async fn revoke_device(device_id: &str) -> Result<(), String> {- let mut config = load_security_config().await?;-- let original_len = config.approved_devices.len();- config.approved_devices.retain(|d| d.id != device_id);-- if config.approved_devices.len() == original_len {- return Err(format!("Device '{}' not found", device_id));- }-- save_security_config(&config).await-}--/// Get list of approved devices-pub async fn get_approved_devices() -> Result<Vec<DeviceInfo>, String> {- let config = load_security_config().await?;- Ok(config.approved_devices)-}--/// Update the last access time for a device-pub async fn update_device_last_access(device_id: &str) -> Result<(), String> {- let mut config = load_security_config().await?;-- if let Some(device) = config.approved_devices.iter_mut().find(|d| d.id == device_id) {- device.last_access = Some(Utc::now().to_rfc3339());- save_security_config(&config).await- } else {- Err(format!("Device '{}' not found", device_id))- }-}--/// Count recent authentication failures within the rate limit window-pub async fn count_recent_auth_failures() -> Result<u32, String> {- let config = load_security_config().await?;- let logs = get_access_logs(100).await?;-- let window_start = Utc::now()- .checked_sub_signed(chrono::Duration::seconds(config.rate_limit_window_secs as i64))- .map(|t| t.to_rfc3339())- .unwrap_or_default();-- let failures = logs- .iter()- .filter(|entry| {- entry.action == "auth_fail"- && entry.timestamp > window_start- })- .count();-- Ok(failures as u32)-}--#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn test_generate_access_token() {- let token = generate_access_token();- assert!(!token.is_empty());- // UUID format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx- assert_eq!(token.len(), 36);- }-- #[test]- fn test_hash_token() {- let token = "test-token-12345";- let hash = hash_token(token);-- // SHA-256 produces 64 hex characters- assert_eq!(hash.len(), 64);-- // Same input should produce same hash- let hash2 = hash_token(token);- assert_eq!(hash, hash2);-- // Different input should produce different hash- let hash3 = hash_token("different-token");- assert_ne!(hash, hash3);- }-- #[test]- fn test_verify_token() {- let token = "my-secret-token";- let hash = hash_token(token);-- assert!(verify_token(token, &hash));- assert!(!verify_token("wrong-token", &hash));- }-- #[test]- fn test_generate_pairing_code() {- let code = generate_pairing_code();- assert_eq!(code.len(), 8);-- // All characters should be alphanumeric (excluding confusing chars like 0, O, 1, I)- for c in code.chars() {- assert!(c.is_ascii_alphanumeric());- assert!(c != '0' && c != 'O' && c != '1' && c != 'I');- }- }-}diff --git a/src-tauri/src/core/openclaw/tailscale.rs b/src-tauri/src/core/openclaw/tailscale.rsdeleted file mode 100644index 111992b83..000000000--- a/src-tauri/src/core/openclaw/tailscale.rs+++ /dev/null@@ -1,480 +0,0 @@-//! Tailscale integration for OpenClaw remote access-//!-//! This module provides functions to detect, configure, and manage Tailscale-//! for secure remote access to the OpenClaw gateway.--use serde::Deserialize;-use tokio::process::Command;--use super::models::{TailscaleInfo, TailscaleStatus};--#[cfg(target_os = "windows")]-fn hide_window(cmd: &mut Command) {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);-}--#[cfg(not(target_os = "windows"))]-fn hide_window(_cmd: &mut Command) {}--/// Tailscale status JSON response structure-#[derive(Debug, Deserialize)]-#[serde(rename_all = "PascalCase")]-struct TailscaleStatusJson {- #[serde(default)]- backend_state: String,- #[serde(rename = "Self")]- self_node: Option<TailscaleSelfNode>,- #[serde(default)]- current_tailnet: Option<TailscaleCurrentTailnet>,-}--/// Tailscale self node information-#[derive(Debug, Deserialize)]-#[serde(rename_all = "PascalCase")]-struct TailscaleSelfNode {- #[serde(default)]- host_name: String,- #[serde(rename = "DNSName")]- #[serde(default)]- dns_name: String,- #[serde(rename = "TailscaleIPs")]- #[serde(default)]- tailscale_ips: Vec<String>,-}--/// Tailscale current tailnet information-#[derive(Debug, Deserialize)]-#[serde(rename_all = "PascalCase")]-#[allow(dead_code)]-struct TailscaleCurrentTailnet {- #[serde(default)]- name: String,- #[serde(rename = "MagicDNSSuffix")]- #[serde(default)]- magic_dns_suffix: String,-}--/// Get the Tailscale CLI command based on the platform-fn get_tailscale_cmd() -> &'static str {- #[cfg(target_os = "macos")]- {- // On macOS, Tailscale is typically installed via App Store or direct download- // The CLI is usually available at /Applications/Tailscale.app/Contents/MacOS/Tailscale- // or via /usr/local/bin/tailscale if installed via Homebrew- "tailscale"- }- #[cfg(target_os = "windows")]- {- "tailscale"- }- #[cfg(target_os = "linux")]- {- "tailscale"- }- #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]- {- "tailscale"- }-}--/// Check if Tailscale is installed on the system-pub async fn detect_tailscale() -> TailscaleStatus {- log::info!("Detecting Tailscale installation");-- // Try to get Tailscale version- let mut cmd = Command::new(get_tailscale_cmd());- cmd.arg("version");- hide_window(&mut cmd);- let version_output = cmd.output().await;-- match version_output {- Ok(output) => {- if output.status.success() {- let version_str = String::from_utf8_lossy(&output.stdout)- .lines()- .next()- .unwrap_or("")- .trim()- .to_string();-- // Check if Tailscale daemon is running and user is logged in- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args(["status", "--json"]);- hide_window(&mut cmd);- let status_output = cmd.output().await;-- match status_output {- Ok(status) => {- if status.status.success() {- let status_json = String::from_utf8_lossy(&status.stdout);- match serde_json::from_str::<TailscaleStatusJson>(&status_json) {- Ok(parsed) => {- let running = !parsed.backend_state.is_empty();- let logged_in = parsed.backend_state == "Running"- && parsed.self_node.is_some();-- TailscaleStatus {- installed: true,- running,- logged_in,- version: Some(version_str),- error: None,- }- }- Err(e) => {- log::warn!("Failed to parse Tailscale status JSON: {}", e);- TailscaleStatus {- installed: true,- running: true,- logged_in: false,- version: Some(version_str),- error: Some(format!(- "Failed to parse status: {}",- e- )),- }- }- }- } else {- let stderr = String::from_utf8_lossy(&status.stderr);- // Check for common error messages- let (running, error) = if stderr.contains("not running") {- (false, Some("Tailscale daemon is not running".to_string()))- } else if stderr.contains("not logged in") {- (true, Some("Not logged in to Tailscale".to_string()))- } else {- (false, Some(stderr.trim().to_string()))- };-- TailscaleStatus {- installed: true,- running,- logged_in: false,- version: Some(version_str),- error,- }- }- }- Err(e) => TailscaleStatus {- installed: true,- running: false,- logged_in: false,- version: Some(version_str),- error: Some(format!("Failed to check Tailscale status: {}", e)),- },- }- } else {- TailscaleStatus {- installed: false,- running: false,- logged_in: false,- version: None,- error: Some("Tailscale is not installed".to_string()),- }- }- }- Err(e) => {- log::info!("Tailscale not found: {}", e);- TailscaleStatus {- installed: false,- running: false,- logged_in: false,- version: None,- error: Some("Tailscale is not installed".to_string()),- }- }- }-}--/// Get the current tailnet name and status-pub async fn get_tailscale_status() -> TailscaleInfo {- log::info!("Getting Tailscale status");-- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args(["status", "--json"]);- hide_window(&mut cmd);- let output = cmd.output().await;-- let mut info = TailscaleInfo::default();-- match output {- Ok(output) => {- if output.status.success() {- let status_json = String::from_utf8_lossy(&output.stdout);- if let Ok(parsed) = serde_json::from_str::<TailscaleStatusJson>(&status_json) {- if let Some(self_node) = parsed.self_node {- info.hostname = Some(self_node.host_name);- info.dns_name = if self_node.dns_name.is_empty() {- None- } else {- // Remove trailing dot if present- Some(self_node.dns_name.trim_end_matches('.').to_string())- };- info.ip_addresses = self_node.tailscale_ips;- }-- if let Some(tailnet) = parsed.current_tailnet {- info.tailnet = if tailnet.name.is_empty() {- None- } else {- Some(tailnet.name)- };- }- }- }- }- Err(e) => {- log::warn!("Failed to get Tailscale status: {}", e);- }- }-- // Check serve status- let serve_status = check_serve_status().await;- info.serve_enabled = serve_status.0;- info.funnel_enabled = serve_status.1;- info.serve_url = serve_status.2;-- info-}--/// Check the current Tailscale Serve status-/// Returns (serve_enabled, funnel_enabled, serve_url)-async fn check_serve_status() -> (bool, bool, Option<String>) {- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args(["serve", "status", "--json"]);- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- let status_str = String::from_utf8_lossy(&output.stdout);- // Parse the serve status JSON- // The structure varies but typically contains "Services" or similar- if let Ok(json) = serde_json::from_str::<serde_json::Value>(&status_str) {- // Check if there are any active services- let has_services = json.get("Services").map(|s| !s.is_null()).unwrap_or(false)- || json.get("TCP").map(|s| !s.is_null()).unwrap_or(false)- || json.get("Web").map(|s| !s.is_null()).unwrap_or(false);-- // Check for funnel- let funnel_enabled = json.get("AllowFunnel")- .and_then(|v| v.as_bool())- .unwrap_or(false);-- // Try to extract the serve URL- let serve_url = json.get("ServeConfig")- .and_then(|c| c.get("DNS"))- .and_then(|d| d.as_str())- .map(|s| format!("https://{}", s));-- return (has_services, funnel_enabled, serve_url);- }- }- }- Err(e) => {- log::debug!("Failed to check serve status: {}", e);- }- }-- (false, false, None)-}--/// Configure Tailscale Serve for OpenClaw gateway-///-/// This sets up Tailscale Serve to proxy HTTPS traffic to the local OpenClaw port.-pub async fn configure_tailscale_serve(port: u16) -> Result<String, String> {- log::info!("Configuring Tailscale Serve for port {}", port);-- // First, check if Tailscale is ready- let status = detect_tailscale().await;- if !status.installed {- return Err("Tailscale is not installed".to_string());- }- if !status.running {- return Err("Tailscale daemon is not running".to_string());- }- if !status.logged_in {- return Err("Not logged in to Tailscale. Please run 'tailscale login' first.".to_string());- }-- // Configure Tailscale Serve to forward HTTPS to localhost:port- // The command is: tailscale serve https / http://localhost:PORT- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args([- "serve",- "https",- "/",- &format!("http://localhost:{}", port),- ]);- hide_window(&mut cmd);- let output = cmd- .output()- .await- .map_err(|e| format!("Failed to run tailscale serve: {}", e))?;-- if output.status.success() {- // Get the serve URL- let info = get_tailscale_status().await;- let url = info.serve_url.unwrap_or_else(|| {- // Construct URL from DNS name if available- info.dns_name- .map(|dns| format!("https://{}", dns))- .unwrap_or_else(|| "URL not available".to_string())- });-- log::info!("Tailscale Serve configured successfully: {}", url);- Ok(url)- } else {- let stderr = String::from_utf8_lossy(&output.stderr);- Err(format!("Failed to configure Tailscale Serve: {}", stderr.trim()))- }-}--/// Remove Tailscale Serve configuration-pub async fn remove_tailscale_serve() -> Result<(), String> {- log::info!("Removing Tailscale Serve configuration");-- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args(["serve", "off"]);- hide_window(&mut cmd);- let output = cmd- .output()- .await- .map_err(|e| format!("Failed to run tailscale serve off: {}", e))?;-- if output.status.success() {- log::info!("Tailscale Serve configuration removed");- Ok(())- } else {- let stderr = String::from_utf8_lossy(&output.stderr);- // If already off, that's fine- if stderr.contains("no serve config") || stderr.is_empty() {- Ok(())- } else {- Err(format!("Failed to remove Tailscale Serve: {}", stderr.trim()))- }- }-}--/// Enable Tailscale Funnel for public access-///-/// This allows the OpenClaw gateway to be accessed from the public internet-/// via Tailscale's Funnel feature.-pub async fn enable_tailscale_funnel(port: u16) -> Result<String, String> {- log::info!("Enabling Tailscale Funnel for port {}", port);-- // First, check if Tailscale is ready- let status = detect_tailscale().await;- if !status.installed {- return Err("Tailscale is not installed".to_string());- }- if !status.running {- return Err("Tailscale daemon is not running".to_string());- }- if !status.logged_in {- return Err("Not logged in to Tailscale. Please run 'tailscale login' first.".to_string());- }-- // Enable Funnel - this also sets up serve if not already configured- // The command is: tailscale funnel PORT- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args(["funnel", &port.to_string()]);- hide_window(&mut cmd);- let output = cmd- .output()- .await- .map_err(|e| format!("Failed to run tailscale funnel: {}", e))?;-- if output.status.success() {- // Get the funnel URL- let info = get_tailscale_status().await;- let url = info.serve_url.unwrap_or_else(|| {- info.dns_name- .map(|dns| format!("https://{}", dns))- .unwrap_or_else(|| "URL not available".to_string())- });-- log::info!("Tailscale Funnel enabled: {}", url);- Ok(url)- } else {- let stderr = String::from_utf8_lossy(&output.stderr);- // Check for common errors- if stderr.contains("Funnel not available") || stderr.contains("not enabled") {- Err("Tailscale Funnel is not enabled for your account. Please enable it in the Tailscale admin console.".to_string())- } else {- Err(format!("Failed to enable Tailscale Funnel: {}", stderr.trim()))- }- }-}--/// Disable Tailscale Funnel-pub async fn disable_tailscale_funnel() -> Result<(), String> {- log::info!("Disabling Tailscale Funnel");-- let mut cmd = Command::new(get_tailscale_cmd());- cmd.args(["funnel", "off"]);- hide_window(&mut cmd);- let output = cmd- .output()- .await- .map_err(|e| format!("Failed to run tailscale funnel off: {}", e))?;-- if output.status.success() {- log::info!("Tailscale Funnel disabled");- Ok(())- } else {- let stderr = String::from_utf8_lossy(&output.stderr);- // If already off, that's fine- if stderr.contains("no funnel") || stderr.is_empty() {- Ok(())- } else {- Err(format!("Failed to disable Tailscale Funnel: {}", stderr.trim()))- }- }-}--/// Get the tailnet URL for accessing the gateway-///-/// Returns the HTTPS URL that can be used to access the OpenClaw gateway-/// via Tailscale Serve or Funnel.-pub async fn get_tailscale_url() -> Result<Option<String>, String> {- log::info!("Getting Tailscale URL");-- let info = get_tailscale_status().await;-- // If serve is enabled and we have a URL, return it- if info.serve_enabled {- if let Some(url) = info.serve_url {- return Ok(Some(url));- }- }-- // Otherwise, construct from DNS name if available- if let Some(dns_name) = info.dns_name {- // If serve is enabled, use HTTPS- if info.serve_enabled {- return Ok(Some(format!("https://{}", dns_name)));- }- // Otherwise, return the Tailscale IP-based URL for direct access- // (though this won't work without serve for HTTP services)- return Ok(Some(format!("http://{}", dns_name)));- }-- // No URL available- Ok(None)-}--#[cfg(test)]-mod tests {- use super::*;-- #[tokio::test]- async fn test_detect_tailscale() {- // This test will vary based on whether Tailscale is installed- let status = detect_tailscale().await;- // Just verify we get a valid response- assert!(status.installed || status.error.is_some());- }-}diff --git a/src-tauri/src/core/openclaw/tests.rs b/src-tauri/src/core/openclaw/tests.rsdeleted file mode 100644index 4a560f6c0..000000000--- a/src-tauri/src/core/openclaw/tests.rs+++ /dev/null@@ -1,28 +0,0 @@-use super::commands::needs_upgrade;--#[test]-fn test_needs_upgrade_older_version() {- assert!(needs_upgrade("2026.3.1", "2026.3.2"));- assert!(needs_upgrade("2026.2.26", "2026.3.2"));- assert!(needs_upgrade("2025.1.0", "2026.3.2"));-}--#[test]-fn test_needs_upgrade_same_version() {- assert!(!needs_upgrade("2026.3.2", "2026.3.2"));-}--#[test]-fn test_needs_upgrade_newer_version() {- assert!(!needs_upgrade("2026.4.0", "2026.3.2"));- assert!(!needs_upgrade("2026.3.3", "2026.3.2"));- assert!(!needs_upgrade("2027.0.0", "2026.3.2"));-}--#[test]-fn test_needs_upgrade_unparseable() {- assert!(!needs_upgrade("custom-build", "2026.3.2"));- assert!(!needs_upgrade("", "2026.3.2"));- assert!(!needs_upgrade("2026.3.2", "custom"));- assert!(!needs_upgrade("abc", "def"));-}diff --git a/src-tauri/src/core/openclaw/tunnels.rs b/src-tauri/src/core/openclaw/tunnels.rsdeleted file mode 100644index 65f77a608..000000000--- a/src-tauri/src/core/openclaw/tunnels.rs+++ /dev/null@@ -1,884 +0,0 @@-//! Tunnel provider detection and management for OpenClaw remote access.-//!-//! This module provides support for multiple tunnel providers (ngrok, cloudflared, Tailscale)-//! to enable remote access to the Jan OpenClaw gateway.--use std::process::Stdio;-use std::sync::Arc;--use chrono::Utc;-use tokio::io::{AsyncBufReadExt, BufReader};-use tokio::process::Command;-use tokio::sync::Mutex;--use super::models::{TunnelConfig, TunnelInfo, TunnelProvider, TunnelProviderStatus, TunnelProvidersStatus};-use super::get_openclaw_config_dir;--#[cfg(target_os = "windows")]-fn hide_window(cmd: &mut Command) {- use std::os::windows::process::CommandExt;- cmd.creation_flags(0x08000000);-}--#[cfg(not(target_os = "windows"))]-fn hide_window(_cmd: &mut Command) {}--/// Shared tunnel state for managing active tunnel processes-#[derive(Clone)]-pub struct TunnelState {- /// Process handle for the active tunnel- pub process_handle: Arc<Mutex<Option<tokio::process::Child>>>,- /// Information about the active tunnel- pub active_tunnel: Arc<Mutex<Option<TunnelInfo>>>,- /// Current tunnel configuration- pub config: Arc<Mutex<TunnelConfig>>,-}--impl Default for TunnelState {- fn default() -> Self {- Self {- process_handle: Arc::new(Mutex::new(None)),- active_tunnel: Arc::new(Mutex::new(None)),- config: Arc::new(Mutex::new(TunnelConfig::default())),- }- }-}--/// Get the tunnel configuration file path-pub fn get_tunnel_config_path() -> Result<std::path::PathBuf, String> {- Ok(get_openclaw_config_dir()?.join("tunnel.json"))-}--/// Load tunnel configuration from disk-pub async fn load_tunnel_config() -> Result<TunnelConfig, String> {- let config_path = get_tunnel_config_path()?;-- if !config_path.exists() {- return Ok(TunnelConfig::default());- }-- let config_json = tokio::fs::read_to_string(&config_path)- .await- .map_err(|e| format!("Failed to read tunnel config: {}", e))?;-- serde_json::from_str(&config_json)- .map_err(|e| format!("Failed to parse tunnel config: {}", e))-}--/// Save tunnel configuration to disk-pub async fn save_tunnel_config(config: &TunnelConfig) -> Result<(), String> {- let config_path = get_tunnel_config_path()?;-- let config_json = serde_json::to_string_pretty(config)- .map_err(|e| format!("Failed to serialize tunnel config: {}", e))?;-- tokio::fs::write(&config_path, config_json)- .await- .map_err(|e| format!("Failed to write tunnel config: {}", e))-}--/// Check if ngrok is installed and get its status-pub async fn detect_ngrok() -> TunnelProviderStatus {- log::debug!("Detecting ngrok installation");-- let mut cmd = Command::new("ngrok");- cmd.arg("version");- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- let version_output = String::from_utf8_lossy(&output.stdout).trim().to_string();- // ngrok version outputs like "ngrok version 3.x.x"- let version = version_output- .split_whitespace()- .last()- .map(String::from);-- // Check if ngrok is authenticated by trying to get the config- let authenticated = check_ngrok_authenticated().await;-- TunnelProviderStatus {- provider: TunnelProvider::Ngrok,- installed: true,- authenticated,- version,- error: None,- }- } else {- TunnelProviderStatus {- provider: TunnelProvider::Ngrok,- installed: false,- authenticated: false,- version: None,- error: Some("ngrok command failed".to_string()),- }- }- }- Err(_) => TunnelProviderStatus {- provider: TunnelProvider::Ngrok,- installed: false,- authenticated: false,- version: None,- error: None,- },- }-}--/// Check if ngrok is authenticated-async fn check_ngrok_authenticated() -> bool {- // Try to check ngrok config for authtoken- let mut cmd = Command::new("ngrok");- cmd.args(["config", "check"]);- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => output.status.success(),- Err(_) => false,- }-}--/// Check if cloudflared is installed and get its status-pub async fn detect_cloudflared() -> TunnelProviderStatus {- log::debug!("Detecting cloudflared installation");-- let mut cmd = Command::new("cloudflared");- cmd.arg("version");- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- let version_output = String::from_utf8_lossy(&output.stdout).trim().to_string();- // cloudflared version outputs like "cloudflared version 2024.x.x (built 2024-xx-xx)"- let version = version_output- .split_whitespace()- .nth(2)- .map(String::from);-- // Check if cloudflared has tunnels configured- let authenticated = check_cloudflared_authenticated().await;-- TunnelProviderStatus {- provider: TunnelProvider::Cloudflare,- installed: true,- authenticated,- version,- error: None,- }- } else {- TunnelProviderStatus {- provider: TunnelProvider::Cloudflare,- installed: false,- authenticated: false,- version: None,- error: Some("cloudflared command failed".to_string()),- }- }- }- Err(_) => TunnelProviderStatus {- provider: TunnelProvider::Cloudflare,- installed: false,- authenticated: false,- version: None,- error: None,- },- }-}--/// Check if cloudflared is authenticated (has tunnels)-async fn check_cloudflared_authenticated() -> bool {- // Try to list tunnels to see if authenticated- let mut cmd = Command::new("cloudflared");- cmd.args(["tunnel", "list"]);- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- // If the command succeeds and doesn't show an error about authentication- let stderr = String::from_utf8_lossy(&output.stderr);- output.status.success() && !stderr.contains("You did not provide credentials")- }- Err(_) => false,- }-}--/// Check if Tailscale is installed and get its status-pub async fn detect_tailscale() -> TunnelProviderStatus {- log::info!("Detecting Tailscale installation");-- let mut cmd = Command::new("tailscale");- cmd.arg("version");- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- let version_output = String::from_utf8_lossy(&output.stdout).trim().to_string();- // tailscale version outputs just the version number- let version = version_output.lines().next().map(String::from);-- // Check if Tailscale is running and logged in- let authenticated = check_tailscale_authenticated().await;-- TunnelProviderStatus {- provider: TunnelProvider::Tailscale,- installed: true,- authenticated,- version,- error: None,- }- } else {- TunnelProviderStatus {- provider: TunnelProvider::Tailscale,- installed: false,- authenticated: false,- version: None,- error: Some("tailscale command failed".to_string()),- }- }- }- Err(_) => TunnelProviderStatus {- provider: TunnelProvider::Tailscale,- installed: false,- authenticated: false,- version: None,- error: None,- },- }-}--/// Check if Tailscale is authenticated-async fn check_tailscale_authenticated() -> bool {- let mut cmd = Command::new("tailscale");- cmd.args(["status", "--json"]);- hide_window(&mut cmd);- let output = cmd.output().await;-- match output {- Ok(output) => {- if output.status.success() {- // Parse JSON to check BackendState- let json_str = String::from_utf8_lossy(&output.stdout);- if let Ok(json) = serde_json::from_str::<serde_json::Value>(&json_str) {- // BackendState should be "Running" when logged in- json.get("BackendState")- .and_then(|v| v.as_str())- .map(|s| s == "Running")- .unwrap_or(false)- } else {- false- }- } else {- false- }- }- Err(_) => false,- }-}--/// Get status of all tunnel providers-pub async fn get_tunnel_providers(tunnel_state: &TunnelState) -> TunnelProvidersStatus {- log::info!("Getting status of all tunnel providers");-- // Run all detections in parallel- let (tailscale, ngrok, cloudflare) = tokio::join!(- detect_tailscale(),- detect_ngrok(),- detect_cloudflared()- );-- // Get current config and active tunnel- let config = tunnel_state.config.lock().await;- let active_tunnel = tunnel_state.active_tunnel.lock().await.clone();-- TunnelProvidersStatus {- tailscale,- ngrok,- cloudflare,- active_provider: config.preferred_provider.clone(),- active_tunnel,- }-}--/// Start ngrok tunnel-pub async fn start_ngrok_tunnel(- tunnel_state: &TunnelState,- port: u16,- auth_token: Option<String>,-) -> Result<TunnelInfo, String> {- log::info!("Starting ngrok tunnel on port {}", port);-- // Check if already running- {- let handle = tunnel_state.process_handle.lock().await;- if handle.is_some() {- return Err("A tunnel is already running".to_string());- }- }-- // If auth token provided, configure ngrok- if let Some(token) = &auth_token {- let mut cmd = Command::new("ngrok");- cmd.args(["config", "add-authtoken", token]);- hide_window(&mut cmd);- let output = cmd.output()- .await- .map_err(|e| format!("Failed to configure ngrok auth token: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("Failed to set ngrok auth token: {}", stderr));- }- }-- // Start ngrok with JSON log format- let mut cmd = Command::new("ngrok");- cmd.args(["http", &port.to_string(), "--log=stdout", "--log-format=json"])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- let mut child = cmd.spawn()- .map_err(|e| format!("Failed to start ngrok: {}", e))?;-- // Read stdout to get the public URL- let stdout = child.stdout.take()- .ok_or("Failed to capture ngrok stdout")?;-- let mut reader = BufReader::new(stdout).lines();- let mut public_url: Option<String> = None;-- // Set a timeout for URL detection- let timeout = tokio::time::Duration::from_secs(30);- let start = tokio::time::Instant::now();-- while start.elapsed() < timeout {- match tokio::time::timeout(tokio::time::Duration::from_secs(1), reader.next_line()).await {- Ok(Ok(Some(line))) => {- // Parse JSON log line- if let Ok(json) = serde_json::from_str::<serde_json::Value>(&line) {- // Look for the URL in the log- if let Some(url) = json.get("url").and_then(|v| v.as_str()) {- if url.starts_with("https://") {- public_url = Some(url.to_string());- break;- }- }- // Also check msg field for URL assignment- if let Some(msg) = json.get("msg").and_then(|v| v.as_str()) {- if msg.contains("started tunnel") {- if let Some(url) = json.get("url").and_then(|v| v.as_str()) {- public_url = Some(url.to_string());- break;- }- }- }- }- }- Ok(Ok(None)) => break, // EOF- Ok(Err(e)) => {- log::warn!("Error reading ngrok output: {}", e);- break;- }- Err(_) => continue, // Timeout, try again- }- }-- // If we couldn't get the URL from logs, try the API- if public_url.is_none() {- tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;- public_url = get_ngrok_url_from_api().await;- }-- let url = public_url.ok_or("Failed to get ngrok public URL")?;-- let tunnel_info = TunnelInfo {- provider: TunnelProvider::Ngrok,- url,- started_at: Utc::now().to_rfc3339(),- port,- is_public: true,- };-- // Store the process handle and tunnel info- {- let mut handle = tunnel_state.process_handle.lock().await;- *handle = Some(child);- }- {- let mut active = tunnel_state.active_tunnel.lock().await;- *active = Some(tunnel_info.clone());- }-- log::info!("ngrok tunnel started: {}", tunnel_info.url);- Ok(tunnel_info)-}--/// Get ngrok URL from the local API-async fn get_ngrok_url_from_api() -> Option<String> {- // ngrok runs a local API on port 4040- let client = reqwest::Client::new();- let response = client- .get("http://127.0.0.1:4040/api/tunnels")- .send()- .await- .ok()?;-- if !response.status().is_success() {- return None;- }-- let json: serde_json::Value = response.json().await.ok()?;-- // Find the https tunnel- json.get("tunnels")?- .as_array()?- .iter()- .find_map(|tunnel| {- let url = tunnel.get("public_url")?.as_str()?;- if url.starts_with("https://") {- Some(url.to_string())- } else {- None- }- })-}--/// Stop ngrok tunnel-pub async fn stop_ngrok_tunnel(tunnel_state: &TunnelState) -> Result<(), String> {- log::info!("Stopping ngrok tunnel");-- let mut handle = tunnel_state.process_handle.lock().await;-- if let Some(mut child) = handle.take() {- child.kill().await- .map_err(|e| format!("Failed to kill ngrok process: {}", e))?;-- // Clear active tunnel- let mut active = tunnel_state.active_tunnel.lock().await;- *active = None;-- log::info!("ngrok tunnel stopped");- Ok(())- } else {- // Try to kill any orphaned ngrok processes- #[cfg(unix)]- {- let mut cmd = Command::new("pkill");- cmd.args(["-f", "ngrok"]);- hide_window(&mut cmd);- let _ = cmd.output().await;- }-- #[cfg(windows)]- {- let mut cmd = Command::new("taskkill");- cmd.args(["/F", "/IM", "ngrok.exe"]);- hide_window(&mut cmd);- let _ = cmd.output().await;- }-- Ok(())- }-}--/// Start cloudflared tunnel-pub async fn start_cloudflared_tunnel(- tunnel_state: &TunnelState,- port: u16,- tunnel_name: Option<String>,-) -> Result<TunnelInfo, String> {- log::info!("Starting cloudflared tunnel on port {}", port);-- // Check if already running- {- let handle = tunnel_state.process_handle.lock().await;- if handle.is_some() {- return Err("A tunnel is already running".to_string());- }- }-- let url = format!("http://localhost:{}", port);-- // Build command args based on whether we have a named tunnel or quick tunnel- let (child, public_url) = if let Some(name) = tunnel_name {- // Named tunnel (requires pre-configuration)- let mut cmd = Command::new("cloudflared");- cmd.args(["tunnel", "run", "--url", &url, &name])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- let child = cmd.spawn()- .map_err(|e| format!("Failed to start cloudflared: {}", e))?;-- // For named tunnels, the URL is typically <tunnel-name>.<domain>- // We need to get this from the tunnel configuration- let tunnel_url = get_cloudflared_tunnel_url(&name).await- .unwrap_or_else(|| format!("https://{}.trycloudflare.com", name));-- (child, tunnel_url)- } else {- // Quick tunnel (no account required)- let mut cmd = Command::new("cloudflared");- cmd.args(["tunnel", "--url", &url])- .stdout(Stdio::piped())- .stderr(Stdio::piped());- hide_window(&mut cmd);- let mut child = cmd.spawn()- .map_err(|e| format!("Failed to start cloudflared: {}", e))?;-- // Read stderr to get the public URL (cloudflared outputs to stderr)- let stderr = child.stderr.take()- .ok_or("Failed to capture cloudflared stderr")?;-- let mut reader = BufReader::new(stderr).lines();- let mut public_url: Option<String> = None;-- let timeout = tokio::time::Duration::from_secs(30);- let start = tokio::time::Instant::now();-- while start.elapsed() < timeout {- match tokio::time::timeout(tokio::time::Duration::from_secs(1), reader.next_line()).await {- Ok(Ok(Some(line))) => {- // Look for the URL in the output- // cloudflared outputs something like: "Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): https://xxx.trycloudflare.com"- if line.contains("trycloudflare.com") {- // Extract URL from the line- if let Some(start_idx) = line.find("https://") {- let url_part = &line[start_idx..];- let end_idx = url_part.find(|c: char| c.is_whitespace()).unwrap_or(url_part.len());- public_url = Some(url_part[..end_idx].to_string());- break;- }- }- }- Ok(Ok(None)) => break,- Ok(Err(e)) => {- log::warn!("Error reading cloudflared output: {}", e);- break;- }- Err(_) => continue,- }- }-- let url = public_url.ok_or("Failed to get cloudflared public URL")?;- (child, url)- };-- let tunnel_info = TunnelInfo {- provider: TunnelProvider::Cloudflare,- url: public_url,- started_at: Utc::now().to_rfc3339(),- port,- is_public: true,- };-- // Store the process handle and tunnel info- {- let mut handle = tunnel_state.process_handle.lock().await;- *handle = Some(child);- }- {- let mut active = tunnel_state.active_tunnel.lock().await;- *active = Some(tunnel_info.clone());- }-- log::info!("cloudflared tunnel started: {}", tunnel_info.url);- Ok(tunnel_info)-}--/// Get cloudflared tunnel URL for a named tunnel-async fn get_cloudflared_tunnel_url(tunnel_name: &str) -> Option<String> {- let mut cmd = Command::new("cloudflared");- cmd.args(["tunnel", "info", tunnel_name, "--output", "json"]);- hide_window(&mut cmd);- let output = cmd.output()- .await- .ok()?;-- if !output.status.success() {- return None;- }-- let json: serde_json::Value = serde_json::from_slice(&output.stdout).ok()?;-- // Extract the hostname from tunnel info- json.get("config")?- .get("ingress")?- .as_array()?- .first()?- .get("hostname")- .and_then(|h| h.as_str())- .map(|h| format!("https://{}", h))-}--/// Stop cloudflared tunnel-pub async fn stop_cloudflared_tunnel(tunnel_state: &TunnelState) -> Result<(), String> {- log::info!("Stopping cloudflared tunnel");-- let mut handle = tunnel_state.process_handle.lock().await;-- if let Some(mut child) = handle.take() {- child.kill().await- .map_err(|e| format!("Failed to kill cloudflared process: {}", e))?;-- // Clear active tunnel- let mut active = tunnel_state.active_tunnel.lock().await;- *active = None;-- log::info!("cloudflared tunnel stopped");- Ok(())- } else {- // Try to kill any orphaned cloudflared processes- #[cfg(unix)]- {- let mut cmd = Command::new("pkill");- cmd.args(["-f", "cloudflared tunnel"]);- hide_window(&mut cmd);- let _ = cmd.output().await;- }-- #[cfg(windows)]- {- let mut cmd = Command::new("taskkill");- cmd.args(["/F", "/IM", "cloudflared.exe"]);- hide_window(&mut cmd);- let _ = cmd.output().await;- }-- Ok(())- }-}--/// Start Tailscale Serve/Funnel-pub async fn start_tailscale_tunnel(- tunnel_state: &TunnelState,- port: u16,- use_funnel: bool,-) -> Result<TunnelInfo, String> {- log::info!("Starting Tailscale {} on port {}", if use_funnel { "Funnel" } else { "Serve" }, port);-- // Check if already running- {- let active = tunnel_state.active_tunnel.lock().await;- if active.is_some() {- return Err("A tunnel is already running".to_string());- }- }-- // First, get the Tailscale hostname- let mut cmd = Command::new("tailscale");- cmd.args(["status", "--json"]);- hide_window(&mut cmd);- let status_output = cmd.output()- .await- .map_err(|e| format!("Failed to get Tailscale status: {}", e))?;-- if !status_output.status.success() {- return Err("Tailscale is not running or not logged in".to_string());- }-- let status_json: serde_json::Value = serde_json::from_slice(&status_output.stdout)- .map_err(|e| format!("Failed to parse Tailscale status: {}", e))?;-- let dns_name = status_json.get("Self")- .and_then(|s| s.get("DNSName"))- .and_then(|d| d.as_str())- .map(|s| s.trim_end_matches('.').to_string())- .ok_or("Failed to get Tailscale DNS name")?;-- // Start Tailscale Serve- let _serve_url = format!("http://localhost:{}", port);-- // Use funnel if requested (publicly accessible), otherwise serve (tailnet only)- let command = if use_funnel { "funnel" } else { "serve" };-- let mut cmd = Command::new("tailscale");- cmd.args([command, &port.to_string()]);- hide_window(&mut cmd);- let output = cmd.output()- .await- .map_err(|e| format!("Failed to start Tailscale {}: {}", command, e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("Failed to start Tailscale {}: {}", command, stderr));- }-- let public_url = if use_funnel {- format!("https://{}", dns_name)- } else {- format!("https://{}:{}", dns_name, port)- };-- let tunnel_info = TunnelInfo {- provider: TunnelProvider::Tailscale,- url: public_url,- started_at: Utc::now().to_rfc3339(),- port,- is_public: use_funnel,- };-- // Store tunnel info (Tailscale serve/funnel runs as a daemon, not a child process)- {- let mut active = tunnel_state.active_tunnel.lock().await;- *active = Some(tunnel_info.clone());- }-- log::info!("Tailscale {} started: {}", command, tunnel_info.url);- Ok(tunnel_info)-}--/// Stop Tailscale Serve/Funnel-pub async fn stop_tailscale_tunnel(tunnel_state: &TunnelState) -> Result<(), String> {- log::info!("Stopping Tailscale Serve/Funnel");-- // Reset serve configuration- let mut cmd = Command::new("tailscale");- cmd.args(["serve", "reset"]);- hide_window(&mut cmd);- let output = cmd.output()- .await- .map_err(|e| format!("Failed to stop Tailscale serve: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("Failed to reset Tailscale serve: {}", stderr);- }-- // Also reset funnel- let mut cmd = Command::new("tailscale");- cmd.args(["funnel", "reset"]);- hide_window(&mut cmd);- let _ = cmd.output().await;-- // Clear active tunnel- let mut active = tunnel_state.active_tunnel.lock().await;- *active = None;-- log::info!("Tailscale tunnel stopped");- Ok(())-}--/// Get active tunnel info-pub async fn get_active_tunnel(tunnel_state: &TunnelState) -> Option<TunnelInfo> {- let active = tunnel_state.active_tunnel.lock().await;- active.clone()-}--/// Set preferred tunnel provider-pub async fn set_tunnel_provider(- tunnel_state: &TunnelState,- provider: TunnelProvider,-) -> Result<(), String> {- log::info!("Setting preferred tunnel provider to {:?}", provider);-- let mut config = tunnel_state.config.lock().await;- config.preferred_provider = provider;-- // Save to disk- save_tunnel_config(&config).await?;-- Ok(())-}--/// Start tunnel with preferred provider-pub async fn start_tunnel(- tunnel_state: &TunnelState,- port: u16,-) -> Result<TunnelInfo, String> {- let config = tunnel_state.config.lock().await.clone();-- match config.preferred_provider {- TunnelProvider::Ngrok => {- start_ngrok_tunnel(tunnel_state, port, config.ngrok_auth_token).await- }- TunnelProvider::Cloudflare => {- start_cloudflared_tunnel(tunnel_state, port, config.cloudflare_tunnel_id).await- }- TunnelProvider::Tailscale => {- start_tailscale_tunnel(tunnel_state, port, false).await- }- TunnelProvider::None | TunnelProvider::LocalOnly => {- Err("No tunnel provider configured. Please set a preferred provider first.".to_string())- }- }-}--/// Stop active tunnel-pub async fn stop_tunnel(tunnel_state: &TunnelState) -> Result<(), String> {- let active = tunnel_state.active_tunnel.lock().await.clone();-- match active.map(|t| t.provider) {- Some(TunnelProvider::Ngrok) => stop_ngrok_tunnel(tunnel_state).await,- Some(TunnelProvider::Cloudflare) => stop_cloudflared_tunnel(tunnel_state).await,- Some(TunnelProvider::Tailscale) => stop_tailscale_tunnel(tunnel_state).await,- _ => {- // No active tunnel, but try to clean up any orphaned processes- let _ = stop_ngrok_tunnel(tunnel_state).await;- let _ = stop_cloudflared_tunnel(tunnel_state).await;- Ok(())- }- }-}--/// Set ngrok auth token-pub async fn set_ngrok_token(- tunnel_state: &TunnelState,- token: String,-) -> Result<(), String> {- log::info!("Setting ngrok auth token");-- // Configure ngrok with the token- let mut cmd = Command::new("ngrok");- cmd.args(["config", "add-authtoken", &token]);- hide_window(&mut cmd);- let output = cmd.output()- .await- .map_err(|e| format!("Failed to configure ngrok: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("Failed to set ngrok auth token: {}", stderr));- }-- // Save to config- let mut config = tunnel_state.config.lock().await;- config.ngrok_auth_token = Some(token);- save_tunnel_config(&config).await?;-- Ok(())-}--/// Set cloudflare tunnel ID-pub async fn set_cloudflare_tunnel(- tunnel_state: &TunnelState,- tunnel_id: String,-) -> Result<(), String> {- log::info!("Setting Cloudflare tunnel ID: {}", tunnel_id);-- // Verify the tunnel exists- let mut cmd = Command::new("cloudflared");- cmd.args(["tunnel", "info", &tunnel_id]);- hide_window(&mut cmd);- let output = cmd.output()- .await- .map_err(|e| format!("Failed to verify Cloudflare tunnel: {}", e))?;-- if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr);- return Err(format!("Invalid tunnel ID or not authenticated: {}", stderr));- }-- // Save to config- let mut config = tunnel_state.config.lock().await;- config.cloudflare_tunnel_id = Some(tunnel_id);- save_tunnel_config(&config).await?;-- Ok(())-}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 786f3a6ab..c190e591b 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -1,6 +1,4 @@pub mod core;-pub mod openclaw_cli;-pub use core::openclaw::OpenClawState;#[cfg(not(feature = "cli"))]@@ -148,83 +146,6 @@ pub fn run() {// Custom updater commands (desktop only)core::updater::commands::check_for_app_updates,core::updater::commands::is_update_available,- // OpenClaw commands- core::openclaw::commands::openclaw_check_dependencies,- core::openclaw::commands::openclaw_check_port,- core::openclaw::commands::openclaw_install,- core::openclaw::commands::openclaw_configure,- core::openclaw::commands::openclaw_get_config,- core::openclaw::commands::openclaw_get_auth_token,- core::openclaw::commands::openclaw_ensure_http_api,- core::openclaw::commands::openclaw_sync_model,- core::openclaw::commands::openclaw_sync_all_models,- core::openclaw::commands::openclaw_get_model,- core::openclaw::commands::openclaw_list_channels,- core::openclaw::commands::openclaw_channel_status,- core::openclaw::commands::openclaw_enable,- core::openclaw::commands::openclaw_start,- core::openclaw::commands::openclaw_stop,- core::openclaw::commands::openclaw_status,- core::openclaw::commands::openclaw_check_gateway,- core::openclaw::commands::openclaw_restart,- core::openclaw::commands::openclaw_get_config_dir,- core::openclaw::commands::openclaw_ensure_jan_origin,- core::openclaw::commands::openclaw_setup_for_channels,- // Sandbox commands- core::openclaw::commands::sandbox_get_logs,- core::openclaw::commands::sandbox_restart,- // Telegram commands- core::openclaw::commands::telegram_validate_token,- core::openclaw::commands::telegram_configure,- core::openclaw::commands::telegram_get_config,- core::openclaw::commands::telegram_check_pairing,- core::openclaw::commands::telegram_clear_pending_pairing,- core::openclaw::commands::telegram_get_pending_pairing_codes,- core::openclaw::commands::telegram_approve_pairing,- core::openclaw::commands::telegram_disconnect,- // WhatsApp commands- core::openclaw::commands::whatsapp_validate_connection,- core::openclaw::commands::whatsapp_start_auth,- core::openclaw::commands::whatsapp_get_qr_code,- core::openclaw::commands::whatsapp_check_auth,- core::openclaw::commands::whatsapp_get_config,- core::openclaw::commands::whatsapp_get_contacts,- core::openclaw::commands::whatsapp_disconnect,- // Tailscale commands- core::openclaw::commands::tailscale_detect,- core::openclaw::commands::tailscale_get_status,- core::openclaw::commands::tailscale_configure_serve,- core::openclaw::commands::tailscale_remove_serve,- core::openclaw::commands::tailscale_enable_funnel,- core::openclaw::commands::tailscale_disable_funnel,- core::openclaw::commands::tailscale_get_url,- // Security commands- core::openclaw::commands::security_get_status,- core::openclaw::commands::security_set_auth_mode,- core::openclaw::commands::security_generate_token,- core::openclaw::commands::security_set_password,- core::openclaw::commands::security_verify_token,- core::openclaw::commands::security_set_require_pairing,- core::openclaw::commands::security_get_devices,- core::openclaw::commands::security_approve_device,- core::openclaw::commands::security_revoke_device,- core::openclaw::commands::security_get_logs,- core::openclaw::commands::security_clear_logs,- core::openclaw::commands::security_generate_pairing_code,- // Tunnel commands- core::openclaw::commands::tunnel_get_providers,- core::openclaw::commands::tunnel_detect_all,- core::openclaw::commands::tunnel_set_provider,- core::openclaw::commands::tunnel_start,- core::openclaw::commands::tunnel_stop,- core::openclaw::commands::tunnel_get_active,- core::openclaw::commands::tunnel_set_ngrok_token,- core::openclaw::commands::tunnel_set_cloudflare_tunnel,- core::openclaw::commands::tunnel_get_config,- core::openclaw::commands::tunnel_start_ngrok,- core::openclaw::commands::tunnel_stop_ngrok,- core::openclaw::commands::tunnel_start_cloudflared,- core::openclaw::commands::tunnel_stop_cloudflared,]);// Mobile: no updater commands@@ -323,7 +244,6 @@ pub fn run() {mcp_server_pids: Arc::new(Mutex::new(HashMap::new())),provider_configs: Arc::new(Mutex::new(HashMap::new())),})- .manage(OpenClawState::default()).setup(|app| {app.handle().plugin(tauri_plugin_log::Builder::default()@@ -462,6 +382,7 @@ pub fn run() {}}+#[cfg(feature = "foundation-models")]{use tauri_plugin_foundation_models::cleanup_processes;@@ -469,48 +390,6 @@ pub fn run() {log::info!("Foundation Models processes cleaned up successfully");}- // OpenClaw gateway cleanup- {- use crate::core::openclaw::sandbox::Sandbox;- use crate::core::openclaw::OpenClawState;- let openclaw_state = app_handle.state::<OpenClawState>();- let openclaw_future = async {- let sandbox_guard = openclaw_state.sandbox.lock().await;- match sandbox_guard.as_ref() {- Some(sandbox) => {- crate::core::openclaw::lifecycle::stop_openclaw(- sandbox.as_ref(),- &openclaw_state,- )- .await- }- None => {- let direct =- crate::core::openclaw::sandbox_direct::DirectProcessSandbox;- let mut handle =- crate::core::openclaw::sandbox::SandboxHandle::Named(- "exit-cleanup".to_string(),- );- direct.stop(&mut handle).await- }- }- };- match tokio::time::timeout(- tokio::time::Duration::from_secs(10),- openclaw_future,- )- .await- {- Ok(Ok(_)) => {- log::info!("OpenClaw cleanup completed successfully")- }- Ok(Err(e)) => log::warn!("OpenClaw cleanup failed: {}", e),- Err(_) => {- log::warn!("OpenClaw cleanup timed out after 10 seconds")- }- }- }-log::info!("App cleanup completed");});});diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex f1860e4e4..5193402df 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -1,220 +1,9 @@// Prevents additional console window on Windows in release, DO NOT REMOVE!!#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]-use app_lib::openclaw_cli::{get_openclaw_cli_args, OpenClawCli, OpenClawCommands};-use std::process::exit;-fn main() {let _ = fix_path_env::fix();- // Check if we're in CLI mode with openclaw subcommand- if let Some(cli) = get_openclaw_cli_args() {- // Run CLI command and exit- run_openclaw_cli(cli);- exit(0);- }-// Normal Tauri app startupapp_lib::run();}--/// Execute OpenClaw CLI commands-fn run_openclaw_cli(cli: OpenClawCli) {- use tokio::runtime::Runtime;-- let rt = Runtime::new().expect("Failed to create runtime");-- match cli.command {- OpenClawCommands::Status => {- // Use standalone status check that doesn't require Tauri State- let status = rt.block_on(async {- app_lib::core::openclaw::cli::get_status().await- });-- match status {- Ok(status) => {- println!("OpenClaw Status:");- println!(" Installed: {}", if status.installed { "Yes" } else { "No" });- println!(" Running: {}", if status.running { "Yes" } else { "No" });- println!(" OpenClaw Version: {}", status.openclaw_version.clone().unwrap_or_else(|| "N/A".to_string()));- println!(" Runtime Version: {}", status.runtime_version.clone().unwrap_or_else(|| "N/A".to_string()));- println!(" Port (18789): {}", if status.port_available { "Available" } else { "In Use" });-- if let Some(err) = status.error {- println!(" Error: {}", err);- }- }- Err(e) => {- eprintln!("Failed to get status: {}", e);- exit(1);- }- }- }-- OpenClawCommands::Start => {- let result = rt.block_on(async {- app_lib::core::openclaw::cli::start_gateway().await- });-- match result {- Ok(_) => println!("OpenClaw gateway started successfully on port 18789"),- Err(e) => {- eprintln!("Failed to start OpenClaw: {}", e);- exit(1);- }- }- }-- OpenClawCommands::Stop => {- let result = rt.block_on(async {- app_lib::core::openclaw::cli::stop_gateway().await- });-- match result {- Ok(_) => println!("OpenClaw gateway stopped successfully"),- Err(e) => {- eprintln!("Failed to stop OpenClaw: {}", e);- exit(1);- }- }- }-- OpenClawCommands::Logs { lines } => {- // Read logs from the OpenClaw config directory- if let Ok(config_dir) = app_lib::core::openclaw::get_openclaw_config_dir() {- let log_path = config_dir.join("logs");- if log_path.exists() {- if let Ok(entries) = std::fs::read_dir(&log_path) {- let mut log_files: Vec<_> = entries- .filter_map(|e| e.ok())- .filter(|e| e.path().extension().map_or(false, |ext| ext == "log"))- .collect();-- // Sort by modified time - get the most recent- log_files.sort_by(|a, b| {- let a_time = a.metadata().and_then(|m| m.modified()).ok();- let b_time = b.metadata().and_then(|m| m.modified()).ok();- b_time.cmp(&a_time)- });-- if let Some(latest_log) = log_files.first() {- if let Ok(content) = std::fs::read_to_string(latest_log.path()) {- let lines_vec: Vec<&str> = content.lines().collect();- let start = if lines_vec.len() > lines {- lines_vec.len() - lines- } else {- 0- };- for line in &lines_vec[start..] {- println!("{}", line);- }- return;- }- }- }- }- // Also try to find logs in data directory- let data_log_path = dirs::data_dir()- .map(|p| p.join("openclaw").join("logs"))- .unwrap_or_default();- if data_log_path.exists() {- if let Ok(entries) = std::fs::read_dir(&data_log_path) {- let mut log_files: Vec<_> = entries- .filter_map(|e| e.ok())- .filter(|e| e.path().extension().map_or(false, |ext| ext == "log"))- .collect();-- log_files.sort_by(|a, b| {- let a_time = a.metadata().and_then(|m| m.modified()).ok();- let b_time = b.metadata().and_then(|m| m.modified()).ok();- b_time.cmp(&a_time)- });-- if let Some(latest_log) = log_files.first() {- if let Ok(content) = std::fs::read_to_string(latest_log.path()) {- let lines_vec: Vec<&str> = content.lines().collect();- let start = if lines_vec.len() > lines {- lines_vec.len() - lines- } else {- 0- };- for line in &lines_vec[start..] {- println!("{}", line);- }- return;- }- }- }- }- }- println!("No logs found. Make sure OpenClaw has been started at least once.");- }-- OpenClawCommands::Install => {- println!("Installing OpenClaw...");-- let result = rt.block_on(async {- app_lib::core::openclaw::commands::openclaw_install().await- });-- match result {- Ok(install_result) => {- if install_result.success {- println!("OpenClaw installed successfully!");- if let Some(version) = install_result.version {- println!(" Version: {}", version);- }- } else {- eprintln!("Installation failed: {}", install_result.error.unwrap_or_else(|| "Unknown error".to_string()));- exit(1);- }- }- Err(e) => {- eprintln!("Installation error: {}", e);- exit(1);- }- }- }-- OpenClawCommands::Configure { port, bind, jan_base_url, model_id, jan_api_key } => {- let config_input = app_lib::core::openclaw::models::OpenClawConfigInput {- port,- bind,- jan_base_url,- model_id,- jan_api_key,- };-- let result = rt.block_on(async {- app_lib::core::openclaw::commands::openclaw_configure(Some(config_input)).await- });-- match result {- Ok(config) => {- println!("OpenClaw configured successfully!");- println!(" Gateway Port: {}", config.gateway.port);- println!(" Gateway Bind: {}", config.gateway.bind);- println!(" Jan Base URL: {}", config.models.providers.jan.base_url);- }- Err(e) => {- eprintln!("Configuration failed: {}", e);- exit(1);- }- }- }-- OpenClawCommands::Restart => {- let result = rt.block_on(async {- app_lib::core::openclaw::cli::restart_gateway().await- });-- match result {- Ok(_) => println!("OpenClaw gateway restarted successfully"),- Err(e) => {- eprintln!("Failed to restart OpenClaw: {}", e);- exit(1);- }- }- }- }-}diff --git a/src-tauri/src/openclaw_cli.rs b/src-tauri/src/openclaw_cli.rsdeleted file mode 100644index a7b36b16e..000000000--- a/src-tauri/src/openclaw_cli.rs+++ /dev/null@@ -1,68 +0,0 @@-use clap::{Parser, Subcommand};-use std::process::exit;--/// OpenClaw CLI commands-#[derive(Parser)]-#[command(name = "openclaw")]-#[command(about = "Manage OpenClaw gateway", long_about = None)]-pub struct OpenClawCli {- #[command(subcommand)]- pub command: OpenClawCommands,-}--#[derive(Subcommand)]-pub enum OpenClawCommands {- /// Show OpenClaw status (running/stopped, version, port)- Status,- /// Start the OpenClaw gateway- Start,- /// Stop the OpenClaw gateway- Stop,- /// View recent logs from OpenClaw- Logs {- /// Number of lines to show (default: 50)- #[arg(short, long, default_value = "50")]- lines: usize,- },- /// Install OpenClaw (if not installed)- Install,- /// Configure OpenClaw settings- Configure {- /// Port number for the gateway- #[arg(long)]- port: Option<u16>,- /// Bind address- #[arg(long)]- bind: Option<String>,- /// Jan base URL- #[arg(long)]- jan_base_url: Option<String>,- /// Model ID to use (sets agents.defaults.model.primary)- #[arg(long)]- model_id: Option<String>,- /// Jan API key for authentication- #[arg(long)]- jan_api_key: Option<String>,- },- /// Restart the OpenClaw gateway- Restart,-}--/// Check if we're in CLI mode with openclaw subcommand-pub fn get_openclaw_cli_args() -> Option<OpenClawCli> {- let args: Vec<String> = std::env::args().collect();-- // Check if we have at least 2 arguments and second is "openclaw"- if args.len() >= 2 && args[1] == "openclaw" {- // Parse just the openclaw subcommand- match OpenClawCli::try_parse_from(&args[1..]) {- Ok(cli) => Some(cli),- Err(e) => {- eprintln!("Error parsing CLI arguments: {}", e);- exit(1);- }- }- } else {- None- }-}\ No newline at end of filediff --git a/web-app/src/components/left-sidebar/NavMain.tsx b/web-app/src/components/left-sidebar/NavMain.tsxindex 40bf32ecb..7a8c554d7 100644--- a/web-app/src/components/left-sidebar/NavMain.tsx+++ b/web-app/src/components/left-sidebar/NavMain.tsx@@ -11,7 +11,7 @@ import { useTranslation } from '@/i18n/react-i18next-compat'import { Link, useNavigate } from '@tanstack/react-router'import { PlatformMetaKey } from '@/containers/PlatformMetaKey'-import React, { useEffect, useRef } from 'react'+import React, { useRef } from 'react'import {SearchIcon,type SearchIconHandle,@@ -40,8 +40,6 @@ import { useSearchDialog } from '@/hooks/useSearchDialog'import { useProjectDialog } from '@/hooks/useProjectDialog'import { useAgentMode } from '@/hooks/useAgentMode'import { TEMPORARY_CHAT_ID } from '@/constants/chat'-import { useAppState } from '@/hooks/useAppState'-import { isOpenClawRunning } from '@/utils/openclaw'import { PlatformShortcuts, ShortcutAction } from '@/lib/shortcuts'type AnimatedIconHandle =@@ -177,13 +175,6 @@ export function NavMain() {const { open: searchOpen, setOpen: setSearchOpen } = useSearchDialog()const { open: projectDialogOpen, setOpen: setProjectDialogOpen } =useProjectDialog()- const openClawAvailable = useAppState((state) => state.openClawRunning)- const setOpenClawRunning = useAppState((state) => state.setOpenClawRunning)-- useEffect(() => {- isOpenClawRunning().then(setOpenClawRunning)- }, [setOpenClawRunning])-const navMainItems = getNavMainItems(() => setProjectDialogOpen(true),() => setSearchOpen(true),@@ -195,7 +186,7 @@ export function NavMain() {useAgentMode.getState().setAgentMode(TEMPORARY_CHAT_ID, true)navigate({ to: route.home })}- ).filter((item) => item.title !== 'common:newAgentChat' || openClawAvailable)+ )const handleCreateProject = async (name: string, assistantId?: string) => {const newProject = await addFolder(name, assistantId)diff --git a/web-app/src/constants/routes.ts b/web-app/src/constants/routes.tsindex c9fa3ef9c..9d22cd381 100644--- a/web-app/src/constants/routes.ts+++ b/web-app/src/constants/routes.ts@@ -19,7 +19,6 @@ export const route = {https_proxy: '/settings/https-proxy',hardware: '/settings/hardware',assistant: '/settings/assistant',- remote_access: '/settings/remote-access',claude_code: '/settings/claude-code',},hub: {diff --git a/web-app/src/containers/AgentModeToggle.tsx b/web-app/src/containers/AgentModeToggle.tsxdeleted file mode 100644index 37ada7702..000000000--- a/web-app/src/containers/AgentModeToggle.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { memo, useEffect, useState, useCallback } from 'react'-import { Button } from '@/components/ui/button'-import {- Tooltip,- TooltipContent,- TooltipTrigger,-} from '@/components/ui/tooltip'-import { IconRobot } from '@tabler/icons-react'-import { cn } from '@/lib/utils'-import { useAgentMode } from '@/hooks/useAgentMode'-import { isOpenClawRunning } from '@/utils/openclaw'--type AgentModeToggleProps = {- threadId: string-}--const AgentModeToggle = memo(function AgentModeToggle({- threadId,-}: AgentModeToggleProps) {- const [openClawAvailable, setOpenClawAvailable] = useState(false)- const isAgent = useAgentMode((state) => state.isAgentMode(threadId))- const toggleAgentMode = useAgentMode((state) => state.toggleAgentMode)-- useEffect(() => {- isOpenClawRunning().then(setOpenClawAvailable)- }, [threadId])-- const handleToggle = useCallback(() => {- toggleAgentMode(threadId)- }, [threadId, toggleAgentMode])-- if (!openClawAvailable) return null-- return (- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="ghost"- size="sm"- className={cn(- 'gap-1.5 text-xs font-medium',- isAgent- ? 'text-primary bg-primary/10 hover:bg-primary/15'- : 'text-muted-foreground'- )}- onClick={handleToggle}- >- <IconRobot size={16} />- Agent- </Button>- </TooltipTrigger>- <TooltipContent>- <p>- {isAgent- ? 'Agent mode active — messages route through OpenClaw'- : 'Enable agent mode to use OpenClaw agent'}- </p>- </TooltipContent>- </Tooltip>- )-})--export default AgentModeTogglediff --git a/web-app/src/containers/ChannelCard.tsx b/web-app/src/containers/ChannelCard.tsxdeleted file mode 100644index b55b0697f..000000000--- a/web-app/src/containers/ChannelCard.tsx+++ /dev/null@@ -1,136 +0,0 @@-import { useTranslation } from '@/i18n/react-i18next-compat'-import { Button } from '@/components/ui/button'-import {- IconBrandTelegram,- IconBrandWhatsapp,- IconSettings,- IconTrash,- IconLoader2,-} from '@tabler/icons-react'-import { cn } from '@/lib/utils'-import type { ChannelType, ChannelConfig, TelegramConfig, WhatsAppConfig } from '@/types/openclaw'--export type { ChannelType, ChannelConfig, TelegramConfig, WhatsAppConfig }--interface ChannelCardProps {- type: ChannelType- config: ChannelConfig | null- onSettings: () => void- onDisconnect: () => void- OCIsInstalled: boolean- isDisconnecting?: boolean-}--export function ChannelCard({- type,- config,- onSettings,- onDisconnect,- OCIsInstalled,- isDisconnecting = false,-}: ChannelCardProps) {- const { t } = useTranslation()-- const isConnected = config?.connected ?? false-- const getChannelIcon = () => {- switch (type) {- case 'telegram':- return <IconBrandTelegram size={16} className="text-blue-500" />- case 'whatsapp':- return <IconBrandWhatsapp size={16} className="text-green-500" />- }- }-- const getChannelName = (): string => {- switch (type) {- case 'telegram':- return t('settings:remoteAccess.telegram')- case 'whatsapp':- return t('settings:remoteAccess.whatsapp')- }- }-- const getChannelDetails = (): string => {- if (!config || !isConnected) return ''-- switch (type) {- case 'telegram': {- const tg = config as TelegramConfig- return tg.bot_username ? `@${tg.bot_username}` : ''- }- case 'whatsapp': {- const wa = config as WhatsAppConfig- return wa.phone_number || ''- }- }- }-- return (- <div- className={cn("border rounded-lg overflow-hidden transition-all",- isConnected- ? 'border-green-500/30 bg-green-500/5'- : 'border-border bg-card'- )}- >- <div className="flex items-center justify-between p-2 px-3">- <div className="flex items-center gap-2">- <div className="shrink-0">{getChannelIcon()}</div>- <div>- <div className="flex items-center gap-2">- <span className="font-medium text-foreground">- {getChannelName()}- </span>- <div- className={cn("size-2 rounded-full", {- 'bg-green-500': isConnected,- 'bg-muted-foreground': !isConnected,- })}- />- <span- className={cn("text-xs", {- 'text-green-500': isConnected,- 'text-muted-foreground': !isConnected,- })}- >- {isConnected- ? t('settings:remoteAccess.connected')- : t('settings:remoteAccess.notConnected')}- </span>- </div>- {isConnected && getChannelDetails() && (- <p className="text-sm text-muted-foreground">- {getChannelDetails()}- </p>- )}- </div>- </div>-- <div className="flex items-center gap-2">- {!isConnected && (- <Button variant="outline" size="sm" onClick={onSettings}>- <IconSettings />- {t('settings:remoteAccess.settings')}- </Button>- )}- {isConnected && (- <Button variant="ghost" size="sm" onClick={onDisconnect} disabled={isDisconnecting}>- {isDisconnecting ? <IconLoader2 className="animate-spin" /> : <IconTrash />}- </Button>- )}- </div>- </div>-- {!isConnected && OCIsInstalled && (- <div className="border-t border-border/40 px-4 py-3 bg-muted/30">- <p className="text-xs text-muted-foreground">- {t('settings:remoteAccess.channelNotConnected', {- channel: getChannelName(),- })}- </p>- </div>- )}- </div>- )-}\ No newline at end of filediff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsxindex 993f47392..61f562e7e 100644--- a/web-app/src/containers/ChatInput.tsx+++ b/web-app/src/containers/ChatInput.tsx@@ -88,7 +88,6 @@ import JanBrowserExtensionDialog from '@/containers/dialogs/JanBrowserExtensionDimport { useJanBrowserExtension } from '@/hooks/useJanBrowserExtension'import { PromptVisionModel } from '@/containers/PromptVisionModel'import { useAgentMode } from '@/hooks/useAgentMode'-import { isOpenClawRunning } from '@/utils/openclaw'type ChatInputProps = {className?: string@@ -144,10 +143,9 @@ const ChatInput = memo(function ChatInput({const assistants = useAssistant((state) => state.assistants)const defaultAssistantId = useAssistant((state) => state.defaultAssistantId)- // Agent mode (OpenClaw)+ // Agent mode// Use TEMPORARY_CHAT_ID as fallback key on the home screen (same pattern as attachments)const agentModeKey = currentThreadId ?? TEMPORARY_CHAT_ID- const [openClawAvailable, setOpenClawAvailable] = useState(false)const isAgentMode = useAgentMode((state) =>state.agentThreads[agentModeKey] === true)@@ -155,10 +153,6 @@ const ChatInput = memo(function ChatInput({const effectiveAgentMode = isAgentMode && !projectIdconst toggleAgentMode = useAgentMode((state) => state.toggleAgentMode)- useEffect(() => {- isOpenClawRunning().then(setOpenClawAvailable)- }, [currentThreadId])-const handleAgentToggle = useCallback(() => {toggleAgentMode(agentModeKey)}, [agentModeKey, toggleAgentMode])@@ -1817,7 +1811,7 @@ const ChatInput = memo(function ChatInput({</Tooltip>))}- {openClawAvailable && !projectId && isAgentMode && (+ {!projectId && isAgentMode && (<Tooltip><TooltipTrigger asChild><Buttondiff --git a/web-app/src/containers/DropdownModelProvider.tsx b/web-app/src/containers/DropdownModelProvider.tsxindex e7f36068e..29757bfee 100644--- a/web-app/src/containers/DropdownModelProvider.tsx+++ b/web-app/src/containers/DropdownModelProvider.tsx@@ -23,7 +23,6 @@ import { useFavoriteModel } from '@/hooks/useFavoriteModel'import { predefinedProviders } from '@/constants/providers'import { useServiceHub } from '@/hooks/useServiceHub'import { getLastUsedModel } from '@/utils/getModelToStart'-import { syncModelToOpenClaw } from '@/utils/openclaw'import { ChevronsUpDown } from 'lucide-react'import { useAgentMode } from '@/hooks/useAgentMode'import { BotIcon } from 'lucide-react'@@ -426,18 +425,6 @@ const DropdownModelProvider = memo(function DropdownModelProvider({searchableModel.model.id)- // Sync model to OpenClaw (async, don't block UI)- syncModelToOpenClaw(- searchableModel.model.id,- searchableModel.provider.provider,- getModelDisplayName(searchableModel.model)- ).catch((error) => {- console.debug(- 'Error syncing model to OpenClaw:',- searchableModel.model.id,- error- )- })// Check mmproj existence for llamacpp models (async, don't block UI)if (searchableModel.provider.provider === 'llamacpp') {@@ -491,7 +478,7 @@ const DropdownModelProvider = memo(function DropdownModelProvider({<div className="border relative z-20 px-4 py-1.5 flex items-center gap-1.5 rounded-full text-muted-foreground"><BotIcon className="shrink-0 size-4" /><span className="text-sm font-medium leading-normal">- {t('common:openclawAgent')}+ {t('common:newAgentChat')}</span><span className="text-xs ml-1 font-medium px-2 py-0.5 rounded-full bg-blue-500/20 text-blue-600 dark:text-blue-400">{t('common:experimental')}diff --git a/web-app/src/containers/SettingsMenu.tsx b/web-app/src/containers/SettingsMenu.tsxindex 63bd95533..3f9d96c45 100644--- a/web-app/src/containers/SettingsMenu.tsx+++ b/web-app/src/containers/SettingsMenu.tsx@@ -259,12 +259,6 @@ const SettingsMenu = () => {><span>{t('common:claude_code')}</span></Link>- <Link- to={route.settings.remote_access}- className="flex items-center gap-2 px-2 py-1 cursor-pointer hover:dark:bg-secondary/60 hover:bg-secondary rounded-sm [&.active]:dark:bg-secondary/80 [&.active]:bg-secondary"- >- <span>{t('common:openclaw')}</span>- </Link></div></div>diff --git a/web-app/src/containers/dialogs/AddChannelDialog.tsx b/web-app/src/containers/dialogs/AddChannelDialog.tsxdeleted file mode 100644index abdc951f5..000000000--- a/web-app/src/containers/dialogs/AddChannelDialog.tsx+++ /dev/null@@ -1,162 +0,0 @@-import { useState, useEffect } from 'react'-import { useTranslation } from '@/i18n/react-i18next-compat'-import {- Dialog,- DialogContent,- DialogDescription,- DialogHeader,- DialogTitle,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import {- IconBrandTelegram,- IconBrandWhatsapp,- IconArrowRight,-} from '@tabler/icons-react'-import type { ChannelType } from '@/types/openclaw'--export type { ChannelType }--interface AddChannelDialogProps {- isOpen: boolean- onOpenChange: (open: boolean) => void- onSelectChannel: (channel: ChannelType) => void- connectedChannels: ChannelType[]-}--interface ChannelOption {- id: ChannelType- name: string- icon: React.ReactNode- description: string-}--export function AddChannelDialog({- isOpen,- onOpenChange,- onSelectChannel,- connectedChannels,-}: AddChannelDialogProps) {- const { t } = useTranslation()- const [selectedChannel, setSelectedChannel] = useState<ChannelType | null>(null)-- useEffect(() => {- if (!isOpen) {- setSelectedChannel(null)- }- }, [isOpen])-- const channelOptions: ChannelOption[] = [- {- id: 'telegram',- name: t('settings:remoteAccess.telegram'),- icon: <IconBrandTelegram size={32} className="text-blue-500" />,- description: t('settings:remoteAccess.channelDescriptions.telegram'),- },- {- id: 'whatsapp',- name: t('settings:remoteAccess.whatsapp'),- icon: <IconBrandWhatsapp size={32} className="text-green-500" />,- description: t('settings:remoteAccess.channelDescriptions.whatsapp'),- },- ]-- const handleChannelSelect = (channel: ChannelType) => {- setSelectedChannel(channel)- }-- const handleContinue = () => {- if (selectedChannel) {- onSelectChannel(selectedChannel)- onOpenChange(false)- }- }-- const handleOpenWizard = (channel: ChannelType) => {- onSelectChannel(channel)- onOpenChange(false)- }-- return (- <Dialog open={isOpen} onOpenChange={onOpenChange}>- <DialogContent className="sm:max-w-[480px] max-w-[90vw]">- <DialogHeader>- <DialogTitle>{t('settings:remoteAccess.addChannel.title')}</DialogTitle>- <DialogDescription>- {t('settings:remoteAccess.addChannel.description')}- </DialogDescription>- </DialogHeader>-- <div className="space-y-3 py-4">- {channelOptions.map((channel) => {- const isConnected = connectedChannels.includes(channel.id)- return (- <div- key={channel.id}- className={`relative flex items-center gap-4 p-4 rounded-lg border transition-all cursor-pointer ${- selectedChannel === channel.id- ? 'border-primary bg-primary/5'- : 'border-border hover:border-border hover:bg-secondary/50'- }`}- onClick={() => handleChannelSelect(channel.id)}- >- <div className="flex-shrink-0">{channel.icon}</div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-2">- <span className="font-medium text-foreground">{channel.name}</span>- {isConnected && (- <span className="text-xs px-2 py-0.5 rounded-full bg-green-500/20 text-green-500">- {t('settings:remoteAccess.connected')}- </span>- )}- </div>- <p className="text-sm text-muted-foreground truncate">- {channel.description}- </p>- </div>- {isConnected ? (- <Button- variant="outline"- size="sm"- onClick={(e) => {- e.stopPropagation()- handleOpenWizard(channel.id)- }}- >- {t('settings:remoteAccess.manage')}- </Button>- ) : (- <div- className={`w-5 h-5 rounded-full border-2 flex items-center justify-center ${- selectedChannel === channel.id- ? 'border-primary bg-primary'- : 'border-muted-foreground'- }`}- >- {selectedChannel === channel.id && (- <div className="w-2 h-2 rounded-full bg-primary-foreground" />- )}- </div>- )}- </div>- )- })}- </div>-- <div className="flex justify-end gap-2 pt-2">- <Button variant="outline" onClick={() => onOpenChange(false)}>- {t('settings:remoteAccess.addChannel.cancel')}- </Button>- <Button- onClick={handleContinue}- disabled={!selectedChannel}- className="gap-2"- >- {t('settings:remoteAccess.addChannel.continue')}- <IconArrowRight size={16} />- </Button>- </div>- </DialogContent>- </Dialog>- )-}\ No newline at end of filediff --git a/web-app/src/containers/dialogs/EnableProgressDialog.tsx b/web-app/src/containers/dialogs/EnableProgressDialog.tsxdeleted file mode 100644index 7be2c1ca9..000000000--- a/web-app/src/containers/dialogs/EnableProgressDialog.tsx+++ /dev/null@@ -1,400 +0,0 @@-import { useState, useEffect, useCallback } from 'react'-import { invoke } from '@tauri-apps/api/core'-import { listen } from '@tauri-apps/api/event'-import { toast } from 'sonner'-import {- Dialog,- DialogContent,- DialogTitle,- DialogDescription,- DialogHeader,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import { Progress } from '@/components/ui/progress'-import {- IconCheck,- IconLoader2,- IconAlertTriangle,- IconRefresh,-} from '@tabler/icons-react'-import { setOpenClawRunningState, syncAllModelsToOpenClaw } from '@/utils/openclaw'-import { ensureModelForServer } from '@/utils/ensureModelForServer'-import { getServiceHub } from '@/hooks/useServiceHub'-import { useModelProvider } from '@/hooks/useModelProvider'-import { useLocalApiServer } from '@/hooks/useLocalApiServer'-import { useAppState } from '@/hooks/useAppState'--interface EnableProgressEvent {- step: string- progress: number- message: string- sandbox_info?: string-}--interface EnableResult {- success: boolean- already_installed: boolean- steps_completed: string[]- status: {- installed: boolean- running: boolean- runtime_version: string | null- openclaw_version: string | null- port_available: boolean- error: string | null- }-}--interface EnableError {- code: string- message: string- recovery: {- label: string- action: RecoveryAction- description: string- }[]-}--type RecoveryAction =- | 'Retry'- | { UseDifferentPort: { port: number } }--interface EnableProgressDialogProps {- isOpen: boolean- onOpenChange: (open: boolean) => void- onSuccess?: () => void-}--const STEP_LABELS: Record<string, string> = {- checking_dependencies: 'Checking runtime',- checking_installation: 'Checking OpenClaw',- installing: 'Installing OpenClaw',- already_installed: 'OpenClaw installed',- configuring: 'Configuring',- starting: 'Starting gateway',- validating: 'Validating configuration',- complete: 'Complete',-}--function parseEnableError(errorStr: string): EnableError | null {- try {- return JSON.parse(errorStr) as EnableError- } catch {- return null- }-}--export function EnableProgressDialog({- isOpen,- onOpenChange,- onSuccess,-}: EnableProgressDialogProps) {- const [progress, setProgress] = useState(0)- const [message, setMessage] = useState('')- const [completedSteps, setCompletedSteps] = useState<string[]>([])- const [currentStep, setCurrentStep] = useState('')- const [sandboxInfo, setSandboxInfo] = useState<string | null>(null)- const [error, setError] = useState<EnableError | null>(null)- const [isRunning, setIsRunning] = useState(false)- const [isDone, setIsDone] = useState(false)-- const resetState = useCallback(() => {- setProgress(0)- setMessage('')- setCompletedSteps([])- setCurrentStep('')- setSandboxInfo(null)- setError(null)- setIsRunning(false)- setIsDone(false)- }, [])-- const runEnable = useCallback(async () => {- resetState()- setIsRunning(true)-- try {- const { apiKey, serverPort, apiPrefix } = useLocalApiServer.getState()- const janBaseUrl = `http://localhost:${serverPort}${apiPrefix}`- const result = await invoke<EnableResult>('openclaw_enable', {- configInput: { janApiKey: apiKey || undefined, janBaseUrl },- })-- if (result.success) {- setOpenClawRunningState(true)-- setProgress(90)- setMessage('Loading model...')- try {- await ensureModelForServer({- modelsService: getServiceHub().models(),- })- } catch {- // Non-fatal — remote models can still work via OpenClaw- }-- setMessage('Syncing models...')- try {- const { providers, selectedModel } = useModelProvider.getState()- await syncAllModelsToOpenClaw(providers, selectedModel?.id)- } catch {- // Non-fatal — models can be synced later- }-- // Auto-start local API server on 0.0.0.0 if not already running- const { serverStatus, setServerStatus } = useAppState.getState()- if (serverStatus === 'stopped') {- const { serverPort, apiPrefix, apiKey, trustedHosts, corsEnabled, verboseLogs, proxyTimeout, setServerHost } =- useLocalApiServer.getState()- setServerHost('0.0.0.0')- try {- setServerStatus('pending')- // eslint-disable-next-line @typescript-eslint/no-explicit-any- const actualPort = await (window as any).core?.api?.startServer({- host: '0.0.0.0',- port: serverPort,- prefix: apiPrefix,- apiKey,- trustedHosts,- isCorsEnabled: corsEnabled,- isVerboseEnabled: verboseLogs,- proxyTimeout,- })- if (actualPort && actualPort !== serverPort) {- useLocalApiServer.getState().setServerPort(actualPort)- // Update OpenClaw's baseUrl to point at the actual port- await invoke('openclaw_configure', {- configInput: { janBaseUrl: `http://localhost:${actualPort}${apiPrefix}` },- }).catch(() => {})- }- setServerStatus('running')- } catch {- setServerStatus('stopped')- // Non-fatal — user can start manually- }- }-- setProgress(100)- setMessage('OpenClaw is ready!')- setCurrentStep('complete')- setIsDone(true)- toast.success('Remote access enabled successfully')- onSuccess?.()- }- } catch (err) {- const errorStr = err instanceof Error ? err.message : String(err)- const parsed = parseEnableError(errorStr)- if (parsed) {- setError(parsed)- } else {- setError({- code: 'Unknown',- message: errorStr,- recovery: [- {- label: 'Retry',- action: 'Retry',- description: 'Try again.',- },- ],- })- }- } finally {- setIsRunning(false)- }- }, [resetState, onSuccess])-- // Listen for progress events- useEffect(() => {- if (!isOpen) return-- const unlisten = listen<EnableProgressEvent>(- 'openclaw-enable-progress',- (event) => {- const { step, progress: p, message: msg, sandbox_info } = event.payload- setProgress(p)- setMessage(msg)- setCurrentStep(step)- if (sandbox_info) {- setSandboxInfo(sandbox_info)- }- setCompletedSteps((prev) => {- if (step !== prev[prev.length - 1]) {- return [...prev, step]- }- return prev- })- }- )-- return () => {- unlisten.then((f) => f())- }- }, [isOpen])-- // Start the enable flow when dialog opens- useEffect(() => {- if (isOpen && !isRunning && !isDone && !error) {- runEnable()- }- }, [isOpen, isRunning, isDone, error, runEnable])-- // Reset when dialog closes- useEffect(() => {- if (!isOpen) {- resetState()- }- }, [isOpen, resetState])-- const handleRecoveryAction = (action: RecoveryAction) => {- if (action === 'Retry') {- setError(null)- // runEnable will be triggered by the useEffect- } else if (- typeof action === 'object' &&- 'UseDifferentPort' in action- ) {- // For now, retry is the main action - port config can be extended later- setError(null)- }- }-- const allSteps = [- 'checking_dependencies',- 'checking_installation',- 'installing',- 'configuring',- 'starting',- 'validating',- 'complete',- ]-- return (- <Dialog open={isOpen} onOpenChange={onOpenChange}>- <DialogContent className="sm:max-w-lg" onInteractOutside={(e) => e.preventDefault()}>- <DialogHeader>- <DialogTitle>- {error- ? 'Setup Failed'- : isDone- ? 'Setup Complete'- : 'Setting Up Remote Access'}- </DialogTitle>- <DialogDescription>- {error- ? 'An error occurred during setup.'- : isDone- ? 'OpenClaw is running and ready to use.'- : 'Installing and configuring OpenClaw...'}- </DialogDescription>- </DialogHeader>-- <div className="space-y-4 py-2">- {/* Progress bar */}- {!error && (- <div className="space-y-2">- <Progress value={progress} />- <p className="text-sm text-muted-foreground text-center">- {message}- </p>- </div>- )}-- {/* Step list */}- {!error && (- <div className="space-y-2">- {allSteps.map((step) => {- const isCompleted = completedSteps.includes(step)- const isCurrent = currentStep === step && !isDone- const label = STEP_LABELS[step] || step-- // Show sandbox info next to specific steps- const showSandboxInfo = sandboxInfo && (- step === 'checking_dependencies' ||- step === 'starting' ||- step === 'complete'- )-- // Skip install step if it didn't happen- if (- step === 'installing' &&- !completedSteps.includes('installing') &&- completedSteps.includes('configuring')- ) {- return null- }-- return (- <div- key={step}- className="flex items-center gap-2 text-sm"- >- {isCompleted && !isCurrent ? (- <IconCheck className="h-4 w-4 text-green-500 shrink-0" />- ) : isCurrent ? (- <IconLoader2 className="h-4 w-4 animate-spin text-primary shrink-0" />- ) : (- <div className="h-4 w-4 rounded-full border border-muted-foreground/30 shrink-0" />- )}- <span- className={- isCurrent- ? 'text-foreground font-medium'- : isCompleted- ? 'text-muted-foreground'- : 'text-muted-foreground/50'- }- >- {label}- </span>- {showSandboxInfo && (- <span className="ml-auto text-xs text-muted-foreground">- {sandboxInfo}- </span>- )}- </div>- )- })}- </div>- )}-- {/* Error state */}- {error && (- <div className="space-y-3">- <div className="flex items-start gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3">- <IconAlertTriangle className="h-5 w-5 text-destructive shrink-0 mt-0.5" />- <p className="text-sm text-destructive wrap-break-word min-w-0">{error.message}</p>- </div>- <div className="flex flex-col gap-2">- {error.recovery.map((option, i) => (- <Button- key={i}- variant="outline"- size="sm"- className="w-full justify-start h-auto py-2"- onClick={() => handleRecoveryAction(option.action)}- >- <IconRefresh className="mr-2 h-4 w-4" />- {option.label}- <span className="ml-auto text-xs text-muted-foreground">- {option.description}- </span>- </Button>- ))}- </div>- </div>- )}-- {/* Done state - close button */}- {isDone && (- <div className="flex justify-end">- <Button size="sm" onClick={() => onOpenChange(false)}>- Done- </Button>- </div>- )}- </div>- </DialogContent>- </Dialog>- )-}diff --git a/web-app/src/containers/dialogs/SandboxLogsDialog.tsx b/web-app/src/containers/dialogs/SandboxLogsDialog.tsxdeleted file mode 100644index f72aa1335..000000000--- a/web-app/src/containers/dialogs/SandboxLogsDialog.tsx+++ /dev/null@@ -1,206 +0,0 @@-import { useState, useEffect, useCallback, useRef } from 'react'-import { invoke } from '@tauri-apps/api/core'-import { listen } from '@tauri-apps/api/event'-import { useTranslation } from '@/i18n/react-i18next-compat'-import {- Dialog,- DialogContent,- DialogHeader,- DialogTitle,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'-import { toast } from 'sonner'-import {- IconSearch,- IconCopy,- IconDownload,- IconRefresh,- IconLoader2,- IconFileText,-} from '@tabler/icons-react'--interface SandboxLogsDialogProps {- isOpen: boolean- onOpenChange: (open: boolean) => void-}--export function SandboxLogsDialog({- isOpen,- onOpenChange,-}: SandboxLogsDialogProps) {- const { t } = useTranslation()- const [logs, setLogs] = useState<string[]>([])- const [filteredLogs, setFilteredLogs] = useState<string[]>([])- const [searchQuery, setSearchQuery] = useState('')- const [isLoading, setIsLoading] = useState(false)- const [isRestarting, setIsRestarting] = useState(false)- const logsEndRef = useRef<HTMLDivElement>(null)-- const fetchLogs = useCallback(async () => {- setIsLoading(true)- try {- const logLines = await invoke<string[]>('sandbox_get_logs', { lines: 200 })- setLogs(logLines)- setFilteredLogs(logLines)- } catch (err) {- const errorMsg = err instanceof Error ? err.message : String(err)- toast.error(`Failed to load logs: ${errorMsg}`)- setLogs([])- setFilteredLogs([])- } finally {- setIsLoading(false)- }- }, [])-- const handleRestart = useCallback(async () => {- setIsRestarting(true)- try {- await invoke('sandbox_restart')- toast.success(t('settings:remoteAccess.restarting'))- onOpenChange(false)- } catch (err) {- const errorMsg = err instanceof Error ? err.message : String(err)- toast.error(`Failed to restart: ${errorMsg}`)- } finally {- setIsRestarting(false)- }- }, [onOpenChange, t])-- const handleCopy = useCallback(() => {- const text = filteredLogs.join('\n')- navigator.clipboard.writeText(text)- toast.success(t('settings:remoteAccess.copiedToClipboard'))- }, [filteredLogs, t])-- const handleDownload = useCallback(() => {- const text = filteredLogs.join('\n')- const blob = new Blob([text], { type: 'text/plain' })- const url = URL.createObjectURL(blob)- const a = document.createElement('a')- a.href = url- a.download = `openclaw-logs-${new Date().toISOString().slice(0, 10)}.txt`- document.body.appendChild(a)- a.click()- document.body.removeChild(a)- URL.revokeObjectURL(url)- }, [filteredLogs])-- // Filter logs when search query changes- useEffect(() => {- if (!searchQuery.trim()) {- setFilteredLogs(logs)- return- }- const query = searchQuery.toLowerCase()- const filtered = logs.filter((log) => log.toLowerCase().includes(query))- setFilteredLogs(filtered)- }, [searchQuery, logs])-- // Scroll to bottom when logs change- useEffect(() => {- logsEndRef.current?.scrollIntoView({ behavior: 'smooth' })- }, [filteredLogs])-- // Subscribe to live log events- useEffect(() => {- if (!isOpen) return-- const unlisten = listen<string>('openclaw-log-line', (event) => {- const line = event.payload- setLogs((prev) => {- const updated = [...prev, line]- // Keep only last 500 lines- return updated.slice(-500)- })- })-- return () => {- unlisten.then((f) => f())- }- }, [isOpen])-- // Fetch logs when dialog opens- useEffect(() => {- if (isOpen) {- fetchLogs()- }- }, [isOpen, fetchLogs])-- return (- <Dialog open={isOpen} onOpenChange={onOpenChange}>- <DialogContent className="sm:max-w-5xl max-h-[80vh]">- <DialogHeader>- <DialogTitle>{t('settings:remoteAccess.logViewer')}</DialogTitle>- </DialogHeader>-- <div className="flex flex-col gap-3 h-[500px]">- {/* Toolbar */}- <div className="flex items-center gap-2">- <div className="relative flex-1">- <IconSearch className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />- <Input- placeholder="Search logs..."- value={searchQuery}- onChange={(e) => setSearchQuery(e.target.value)}- className="pl-9"- />- </div>- <Button- variant="outline"- size="sm"- onClick={fetchLogs}- disabled={isLoading}- >- {isLoading ? (- <IconLoader2 className="h-4 w-4 animate-spin" />- ) : (- <IconRefresh className="h-4 w-4" />- )}- </Button>- <Button variant="outline" size="sm" onClick={handleCopy}>- <IconCopy className="h-4 w-4 mr-1" />- {t('settings:remoteAccess.copyLogs')}- </Button>- <Button variant="outline" size="sm" onClick={handleDownload}>- <IconDownload className="h-4 w-4 mr-1" />- {t('settings:remoteAccess.downloadLogs')}- </Button>- <Button- variant="outline"- size="sm"- onClick={handleRestart}- disabled={isRestarting}- >- {isRestarting ? (- <IconLoader2 className="h-4 w-4 animate-spin mr-1" />- ) : (- <IconRefresh className="h-4 w-4 mr-1" />- )}- {t('settings:remoteAccess.restartSandbox')}- </Button>- </div>-- {/* Log content */}- <div className="flex-1 overflow-y-auto overflow-x-hidden rounded-md border bg-muted/50 p-3 font-mono text-xs">- {filteredLogs.length === 0 ? (- <div className="flex flex-col items-center justify-center h-full text-muted-foreground">- <IconFileText className="h-8 w-8 mb-2" />- <p>{t('settings:remoteAccess.noLogs')}</p>- </div>- ) : (- <div className="space-y-0.5">- {filteredLogs.map((log, index) => (- <div key={index} className="whitespace-pre-wrap break-all overflow-hidden">- {log}- </div>- ))}- <div ref={logsEndRef} />- </div>- )}- </div>- </div>- </DialogContent>- </Dialog>- )-}\ No newline at end of filediff --git a/web-app/src/containers/dialogs/TailscaleSetupDialog.tsx b/web-app/src/containers/dialogs/TailscaleSetupDialog.tsxdeleted file mode 100644index 92ce04d78..000000000--- a/web-app/src/containers/dialogs/TailscaleSetupDialog.tsx+++ /dev/null@@ -1,747 +0,0 @@-import { useState, useCallback, useEffect } from 'react'-import { invoke } from '@tauri-apps/api/core'-import { toast } from 'sonner'-import { useTranslation } from '@/i18n/react-i18next-compat'-import {- IconNetwork,- IconCheck,- IconX,- IconArrowRight,- IconArrowLeft,- IconLoader2,- IconAlertCircle,- IconExternalLink,- IconWorld,- IconCopy,- IconShieldLock,-} from '@tabler/icons-react'-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import { Switch } from '@/components/ui/switch'--// Types mirroring Rust backend-interface TailscaleStatus {- installed: boolean- running: boolean- logged_in: boolean- version: string | null- error: string | null-}--interface TailscaleInfo {- hostname: string | null- tailnet: string | null- ip_addresses: string[]- dns_name: string | null- serve_enabled: boolean- funnel_enabled: boolean- serve_url: string | null-}--interface TailscaleSetupDialogProps {- isOpen: boolean- onClose: () => void- onSuccess?: () => void-}--type WizardStep = 'detection' | 'configuration' | 'funnel' | 'success'--const TOTAL_STEPS = 4--export function TailscaleSetupDialog({- isOpen,- onClose,- onSuccess,-}: TailscaleSetupDialogProps) {- const { t } = useTranslation()- const [step, setStep] = useState<WizardStep>('detection')- const [isLoading, setIsLoading] = useState(false)- const [status, setStatus] = useState<TailscaleStatus | null>(null)- const [info, setInfo] = useState<TailscaleInfo | null>(null)- const [errorMessage, setErrorMessage] = useState<string | null>(null)- const [isConfiguringServe, setIsConfiguringServe] = useState(false)- const [isConfiguringFunnel, setIsConfiguringFunnel] = useState(false)-- const getStepNumber = (): number => {- const stepMap: Record<WizardStep, number> = {- detection: 1,- configuration: 2,- funnel: 3,- success: 4,- }- return stepMap[step]- }-- const fetchTailscaleInfo = useCallback(async () => {- try {- const result = await invoke<TailscaleInfo>('tailscale_get_status')- setInfo(result)- } catch {- // Info fetch may fail if Tailscale is not configured- }- }, [])-- const detectTailscale = useCallback(async () => {- setIsLoading(true)- setErrorMessage(null)- try {- const result = await invoke<TailscaleStatus>('tailscale_detect')- setStatus(result)-- if (result.error) {- setErrorMessage(result.error)- } else if (result.installed && result.running && result.logged_in) {- // Tailscale is ready, fetch detailed info- await fetchTailscaleInfo()- }- } catch (error) {- setErrorMessage(- error instanceof Error ? error.message : 'Failed to detect Tailscale'- )- } finally {- setIsLoading(false)- }- }, [fetchTailscaleInfo])-- // Reset state when dialog opens- useEffect(() => {- if (isOpen) {- setStep('detection')- setIsLoading(false)- setStatus(null)- setInfo(null)- setErrorMessage(null)- setIsConfiguringServe(false)- setIsConfiguringFunnel(false)- }- }, [isOpen])-- // Start detection when dialog opens- useEffect(() => {- if (isOpen) {- detectTailscale()- }- }, [isOpen, detectTailscale])-- const handleConfigureServe = useCallback(- async (enable: boolean) => {- setIsConfiguringServe(true)- try {- if (enable) {- await invoke('tailscale_configure_serve')- toast.success(t('settings:remoteAccess.tailscaleSettings.serveEnabled'))- } else {- await invoke('tailscale_remove_serve')- toast.success(t('settings:remoteAccess.tailscaleSettings.serveDisabled'))- }- await fetchTailscaleInfo()- } catch (error) {- toast.error(- error instanceof Error- ? error.message- : t('settings:remoteAccess.tailscaleSettings.serveError')- )- } finally {- setIsConfiguringServe(false)- }- },- [fetchTailscaleInfo, t]- )-- const handleConfigureFunnel = useCallback(- async (enable: boolean) => {- setIsConfiguringFunnel(true)- try {- if (enable) {- await invoke('tailscale_enable_funnel')- toast.success(t('settings:remoteAccess.tailscaleSettings.funnelEnabled'))- } else {- await invoke('tailscale_disable_funnel')- toast.success(t('settings:remoteAccess.tailscaleSettings.funnelDisabled'))- }- await fetchTailscaleInfo()- } catch (error) {- toast.error(- error instanceof Error- ? error.message- : t('settings:remoteAccess.tailscaleSettings.funnelError')- )- } finally {- setIsConfiguringFunnel(false)- }- },- [fetchTailscaleInfo, t]- )-- const handleCopyUrl = useCallback((url: string) => {- navigator.clipboard.writeText(url)- toast.success(t('settings:remoteAccess.tailscaleSettings.urlCopied'))- }, [t])-- const handleOpenUrl = useCallback((url: string) => {- window.open(url, '_blank')- }, [])-- const handleClose = useCallback(() => {- onClose()- }, [onClose])-- const handleSuccess = useCallback(() => {- if (onSuccess) {- onSuccess()- }- onClose()- }, [onSuccess, onClose])-- const renderStepIndicator = () => {- const currentStep = getStepNumber()- return (- <div className="flex items-center justify-center gap-2 mb-6">- {Array.from({ length: TOTAL_STEPS }, (_, i) => (- <div- key={i}- className={`flex items-center justify-center w-8 h-8 rounded-full text-sm font-medium ${- i + 1 < currentStep- ? 'bg-green-500 text-white'- : i + 1 === currentStep- ? 'bg-primary text-primary-foreground'- : 'bg-secondary text-muted-foreground'- }`}- >- {i + 1 < currentStep ? <IconCheck size={16} /> : i + 1}- </div>- ))}- </div>- )- }-- const renderDetectionStep = () => {- return (- <div className="space-y-4">- <DialogDescription className="text-center">- Checking Tailscale status on your system- </DialogDescription>-- {isLoading ? (- <div className="flex flex-col items-center justify-center py-8">- <IconLoader2 className="animate-spin h-12 w-12 text-primary mb-4" />- <p className="text-muted-foreground">Detecting Tailscale...</p>- </div>- ) : errorMessage ? (- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-4">- <IconX size={32} className="text-red-500" />- </div>- <p className="text-red-500 text-center mb-4">{errorMessage}</p>- <Button variant="outline" onClick={detectTailscale}>- Try Again- </Button>- </div>- ) : !status?.installed ? (- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-4">- <IconAlertCircle size={32} className="text-yellow-500" />- </div>- <h3 className="text-lg font-semibold mb-2">- Tailscale Not Installed- </h3>- <p className="text-muted-foreground text-center mb-4 max-w-xs">- Tailscale is required to securely share your OpenClaw endpoint- across your network.- </p>- <div className="bg-secondary/50 rounded-lg p-4 w-full mb-4">- <h4 className="font-medium text-sm mb-2">Installation Steps:</h4>- <ol className="text-muted-foreground text-sm space-y-2">- <li className="flex items-start gap-2">- <span className="font-medium text-foreground">1.</span>- Download Tailscale from the official website- </li>- <li className="flex items-start gap-2">- <span className="font-medium text-foreground">2.</span>- Install and launch Tailscale- </li>- <li className="flex items-start gap-2">- <span className="font-medium text-foreground">3.</span>- Sign in with your account- </li>- </ol>- </div>- <Button- variant="outline"- onClick={() =>- window.open('https://tailscale.com/download', '_blank')- }- className="gap-2"- >- <IconExternalLink size={16} />- Download Tailscale- </Button>- </div>- ) : !status?.running ? (- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-4">- <IconAlertCircle size={32} className="text-yellow-500" />- </div>- <h3 className="text-lg font-semibold mb-2">Tailscale Not Running</h3>- <p className="text-muted-foreground text-center mb-4 max-w-xs">- Tailscale is installed but not currently running. Please start- Tailscale and try again.- </p>- <Button variant="outline" onClick={detectTailscale} className="gap-2">- <IconLoader2 size={16} />- Check Again- </Button>- </div>- ) : !status?.logged_in ? (- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-yellow-500/10 flex items-center justify-center mb-4">- <IconAlertCircle size={32} className="text-yellow-500" />- </div>- <h3 className="text-lg font-semibold mb-2">Not Logged In</h3>- <p className="text-muted-foreground text-center mb-4 max-w-xs">- You need to log in to Tailscale to use this feature.- </p>- <div className="bg-secondary/50 rounded-lg p-4 w-full mb-4">- <p className="text-sm text-muted-foreground mb-2">- Run this command in your terminal:- </p>- <code className="text-sm font-mono bg-background px-3 py-2 rounded block">- tailscale login- </code>- </div>- <Button variant="outline" onClick={detectTailscale} className="gap-2">- <IconLoader2 size={16} />- Check Again- </Button>- </div>- ) : (- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4">- <IconCheck size={32} className="text-green-500" />- </div>- <h3 className="text-lg font-semibold mb-2">Tailscale Ready</h3>- <p className="text-muted-foreground text-center mb-4">- {status.version && `Version ${status.version}`}- </p>- {info && (- <div className="bg-secondary/50 rounded-lg p-4 w-full space-y-2 text-sm">- {info.hostname && (- <div className="flex justify-between">- <span className="text-muted-foreground">Hostname:</span>- <span className="text-foreground font-medium">- {info.hostname}- </span>- </div>- )}- {info.tailnet && (- <div className="flex justify-between">- <span className="text-muted-foreground">Tailnet:</span>- <span className="text-foreground font-medium">- {info.tailnet}- </span>- </div>- )}- {info.dns_name && (- <div className="flex justify-between">- <span className="text-muted-foreground">DNS Name:</span>- <span className="text-foreground font-medium text-xs">- {info.dns_name}- </span>- </div>- )}- {info.ip_addresses.length > 0 && (- <div className="flex justify-between">- <span className="text-muted-foreground">IP Address:</span>- <span className="text-foreground font-medium">- {info.ip_addresses[0]}- </span>- </div>- )}- </div>- )}- </div>- )}- </div>- )- }-- const renderConfigurationStep = () => {- return (- <div className="space-y-4">- <DialogDescription className="text-center">- Configure Tailscale Serve to expose OpenClaw on your tailnet- </DialogDescription>-- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-blue-500/10 flex items-center justify-center mb-4">- <IconNetwork size={32} className="text-blue-500" />- </div>-- <div className="bg-secondary/50 rounded-lg p-4 w-full mb-4">- <h4 className="font-medium text-sm mb-2">What is Tailscale Serve?</h4>- <p className="text-muted-foreground text-sm">- Tailscale Serve allows you to share your local OpenClaw gateway- with other devices on your tailnet. Only devices connected to your- tailnet can access it.- </p>- </div>-- <div className="w-full border border-border rounded-lg p-4">- <div className="flex items-center justify-between">- <div className="space-y-1">- <h4 className="font-medium text-foreground">- Enable Tailscale Serve- </h4>- <p className="text-muted-foreground text-sm">- Share OpenClaw on your tailnet- </p>- </div>- <Switch- checked={info?.serve_enabled ?? false}- onCheckedChange={handleConfigureServe}- disabled={isConfiguringServe}- loading={isConfiguringServe}- />- </div>-- {info?.serve_enabled && info?.serve_url && (- <div className="mt-4 pt-4 border-t border-border">- <p className="text-sm text-muted-foreground mb-2">- Your tailnet URL:- </p>- <div className="flex items-center gap-2">- <code className="flex-1 text-sm font-mono bg-background px-3 py-2 rounded truncate">- {info.serve_url}- </code>- <Button- variant="ghost"- size="icon"- onClick={() => handleCopyUrl(info.serve_url!)}- title="Copy URL"- >- <IconCopy size={16} />- </Button>- <Button- variant="ghost"- size="icon"- onClick={() => handleOpenUrl(info.serve_url!)}- title="Open URL"- >- <IconExternalLink size={16} />- </Button>- </div>- </div>- )}- </div>-- {info && (- <div className="bg-secondary/50 rounded-lg p-4 w-full mt-4 space-y-2 text-sm">- {info.hostname && (- <div className="flex justify-between">- <span className="text-muted-foreground">Hostname:</span>- <span className="text-foreground font-medium">- {info.hostname}- </span>- </div>- )}- {info.tailnet && (- <div className="flex justify-between">- <span className="text-muted-foreground">Tailnet:</span>- <span className="text-foreground font-medium">- {info.tailnet}- </span>- </div>- )}- {info.ip_addresses.length > 0 && (- <div className="flex justify-between">- <span className="text-muted-foreground">IP Addresses:</span>- <span className="text-foreground font-medium">- {info.ip_addresses.join(', ')}- </span>- </div>- )}- </div>- )}- </div>- </div>- )- }-- const renderFunnelStep = () => {- return (- <div className="space-y-4">- <DialogDescription className="text-center">- Optionally enable Tailscale Funnel for public internet access- </DialogDescription>-- <div className="flex flex-col items-center py-4">- <div className="w-16 h-16 rounded-full bg-orange-500/10 flex items-center justify-center mb-4">- <IconWorld size={32} className="text-orange-500" />- </div>-- <div className="bg-secondary/50 rounded-lg p-4 w-full mb-4">- <h4 className="font-medium text-sm mb-2">What is Tailscale Funnel?</h4>- <p className="text-muted-foreground text-sm">- Funnel exposes your OpenClaw gateway to the public internet. Anyone- with the URL can access it, not just devices on your tailnet.- </p>- </div>-- {/* Warning banner */}- <div className="w-full bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4 mb-4">- <div className="flex items-start gap-3">- <IconShieldLock size={20} className="text-yellow-500 shrink-0 mt-0.5" />- <div>- <h4 className="font-medium text-yellow-600 dark:text-yellow-400 text-sm">- Security Warning- </h4>- <p className="text-yellow-600/80 dark:text-yellow-400/80 text-sm mt-1">- Enabling Funnel makes your endpoint publicly accessible on the- internet. Make sure you have appropriate authentication and- access controls in place.- </p>- </div>- </div>- </div>-- <div className="w-full border border-border rounded-lg p-4">- <div className="flex items-center justify-between">- <div className="space-y-1">- <h4 className="font-medium text-foreground">- Enable Tailscale Funnel- </h4>- <p className="text-muted-foreground text-sm">- Public internet access- </p>- </div>- <Switch- checked={info?.funnel_enabled ?? false}- onCheckedChange={handleConfigureFunnel}- disabled={isConfiguringFunnel || !info?.serve_enabled}- loading={isConfiguringFunnel}- />- </div>-- {!info?.serve_enabled && (- <p className="text-sm text-muted-foreground mt-2">- Enable Tailscale Serve first to use Funnel- </p>- )}-- {info?.funnel_enabled && info?.serve_url && (- <div className="mt-4 pt-4 border-t border-border">- <p className="text-sm text-muted-foreground mb-2">- Your public URL:- </p>- <div className="flex items-center gap-2">- <code className="flex-1 text-sm font-mono bg-background px-3 py-2 rounded truncate">- {info.serve_url}- </code>- <Button- variant="ghost"- size="icon"- onClick={() => handleCopyUrl(info.serve_url!)}- title="Copy URL"- >- <IconCopy size={16} />- </Button>- <Button- variant="ghost"- size="icon"- onClick={() => handleOpenUrl(info.serve_url!)}- title="Open URL"- >- <IconExternalLink size={16} />- </Button>- </div>- </div>- )}- </div>- </div>- </div>- )- }-- const renderSuccessStep = () => {- return (- <div className="space-y-4">- <div className="flex flex-col items-center justify-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center mb-4">- <IconCheck size={32} className="text-green-500" />- </div>- <DialogTitle className="text-center">- Tailscale Setup Complete- </DialogTitle>- </div>-- <DialogDescription className="text-center">- Your OpenClaw gateway is now accessible via Tailscale- </DialogDescription>-- <div className="bg-secondary/50 rounded-lg p-4 space-y-3">- <div className="flex justify-between items-center">- <span className="text-muted-foreground">Tailscale Serve:</span>- <span- className={`font-medium ${info?.serve_enabled ? 'text-green-500' : 'text-muted-foreground'}`}- >- {info?.serve_enabled ? 'Enabled' : 'Disabled'}- </span>- </div>- <div className="flex justify-between items-center">- <span className="text-muted-foreground">Tailscale Funnel:</span>- <span- className={`font-medium ${info?.funnel_enabled ? 'text-orange-500' : 'text-muted-foreground'}`}- >- {info?.funnel_enabled ? 'Enabled (Public)' : 'Disabled'}- </span>- </div>- {info?.serve_url && (- <div className="pt-2 border-t border-border">- <p className="text-sm text-muted-foreground mb-2">Access URL:</p>- <div className="flex items-center gap-2">- <code className="flex-1 text-sm font-mono bg-background px-3 py-2 rounded truncate">- {info.serve_url}- </code>- <Button- variant="ghost"- size="icon"- onClick={() => handleCopyUrl(info.serve_url!)}- title="Copy URL"- >- <IconCopy size={16} />- </Button>- </div>- </div>- )}- </div>- </div>- )- }-- const renderStepContent = () => {- switch (step) {- case 'detection':- return renderDetectionStep()- case 'configuration':- return renderConfigurationStep()- case 'funnel':- return renderFunnelStep()- case 'success':- return renderSuccessStep()- default:- return null- }- }-- const canGoNext = (): boolean => {- switch (step) {- case 'detection':- return (- status?.installed === true &&- status?.running === true &&- status?.logged_in === true- )- case 'configuration':- return true // Can always proceed (Serve is optional)- case 'funnel':- return true // Can always proceed (Funnel is optional)- case 'success':- return true- default:- return false- }- }-- const canGoBack = (): boolean => {- return step !== 'detection' && step !== 'success'- }-- const handleNext = () => {- switch (step) {- case 'detection':- setStep('configuration')- break- case 'configuration':- setStep('funnel')- break- case 'funnel':- setStep('success')- break- case 'success':- handleSuccess()- break- }- }-- const handleBack = () => {- switch (step) {- case 'configuration':- setStep('detection')- break- case 'funnel':- setStep('configuration')- break- default:- break- }- }-- const getNextButtonText = (): string => {- switch (step) {- case 'detection':- return 'Continue'- case 'configuration':- return 'Next'- case 'funnel':- return 'Finish'- case 'success':- return 'Done'- default:- return 'Next'- }- }-- return (- <Dialog open={isOpen} onOpenChange={handleClose}>- <DialogContent className="sm:max-w-[480px] max-w-[90vw]">- <DialogHeader>- <div className="flex items-center justify-center gap-2 mb-2">- <IconNetwork size={24} className="text-blue-500" />- <DialogTitle>Tailscale Setup</DialogTitle>- </div>- </DialogHeader>-- {renderStepIndicator()}-- {renderStepContent()}-- <DialogFooter className="gap-2 sm:gap-0">- {canGoBack() && (- <Button variant="outline" onClick={handleBack} className="gap-1">- <IconArrowLeft size={16} />- Back- </Button>- )}- {step === 'detection' && !canGoNext() && !isLoading && (- <Button variant="outline" onClick={handleClose}>- Cancel- </Button>- )}- {(canGoNext() || step === 'success') && (- <Button onClick={handleNext} disabled={!canGoNext()} className="gap-1">- {getNextButtonText()}- {step !== 'success' && <IconArrowRight size={16} />}- </Button>- )}- </DialogFooter>- </DialogContent>- </Dialog>- )-}diff --git a/web-app/src/containers/dialogs/TelegramWizardDialog.tsx b/web-app/src/containers/dialogs/TelegramWizardDialog.tsxdeleted file mode 100644index b716560c3..000000000--- a/web-app/src/containers/dialogs/TelegramWizardDialog.tsx+++ /dev/null@@ -1,577 +0,0 @@-import { useState, useEffect } from 'react'-import { useTranslation } from '@/i18n/react-i18next-compat'-import { invoke } from '@tauri-apps/api/core'-import { openUrl } from '@tauri-apps/plugin-opener'-import { toast } from 'sonner'-import {- Dialog,- DialogContent,- DialogTitle,- DialogDescription,- DialogHeader,- DialogFooter,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'-import {- IconBrandTelegram,- IconCheck,- IconLoader2,- IconAlertCircle,- IconExternalLink,- IconRefresh,-} from '@tabler/icons-react'-import type { TelegramConfig } from '@/types/openclaw'--interface TelegramTokenValidation {- valid: boolean- bot_username: string | null- bot_name: string | null- error: string | null-}--interface TelegramWizardProps {- isOpen: boolean- onOpenChange: (open: boolean) => void- onConnected?: (config: TelegramConfig) => void-}--type WizardStep = 'instructions' | 'token' | 'configure' | 'pairing' | 'success'--const TOTAL_STEPS = 5--export function TelegramWizard({- isOpen,- onOpenChange,- onConnected,-}: TelegramWizardProps) {- const { t } = useTranslation()- const [step, setStep] = useState<WizardStep>('instructions')- const [token, setToken] = useState('')- const [validation, setValidation] = useState<TelegramTokenValidation | null>(null)- const [isValidating, setIsValidating] = useState(false)- const [isConfiguring, setIsConfiguring] = useState(false)- const [config, setConfig] = useState<TelegramConfig | null>(null)- const [pairingCode, setPairingCode] = useState('')- const [isApproving, setIsApproving] = useState(false)- const [isResettingPairing, setIsResettingPairing] = useState(false)-- useEffect(() => {- if (!isOpen) {- setStep('instructions')- setToken('')- setPairingCode('')- setValidation(null)- setConfig(null)- }- }, [isOpen])-- // Poll for pending pairing codes to auto-fill the input- useEffect(() => {- if (step !== 'pairing' || !isOpen) return-- const pollCodes = async () => {- try {- const codes = await invoke<string[]>('telegram_get_pending_pairing_codes')- if (codes.length > 0 && !pairingCode) {- setPairingCode(codes[codes.length - 1])- }- } catch { /* retry next interval */ }- }-- pollCodes()- const interval = setInterval(pollCodes, 3000)- return () => clearInterval(interval)- }, [step, isOpen, pairingCode])-- const getStepNumber = (): number => {- const stepMap: Record<WizardStep, number> = {- instructions: 1,- token: 2,- configure: 3,- pairing: 4,- success: 5,- }- return stepMap[step]- }-- const handleValidateToken = async () => {- if (!token.trim()) {- toast.error(t('settings:remoteAccess.telegramWizard.errors.tokenRequired'))- return- }-- setIsValidating(true)- try {- const result = await invoke<TelegramTokenValidation>('telegram_validate_token', {- token: token.trim(),- })- setValidation(result)- if (result.valid) {- toast.success(- t('settings:remoteAccess.telegramWizard.step2.validToken', {- username: result.bot_username,- })- )- } else {- toast.error(- result.error || t('settings:remoteAccess.telegramWizard.step2.invalidToken')- )- }- } catch {- toast.error(t('settings:remoteAccess.telegramWizard.errors.networkError'))- } finally {- setIsValidating(false)- }- }-- const handleConfigure = async () => {- if (!validation?.valid) return-- setIsConfiguring(true)- try {- const result = await invoke<TelegramConfig>('telegram_configure', {- token: token.trim(),- })- setConfig(result)- setStep('pairing')- toast.success(t('settings:remoteAccess.telegramWizard.step3.success'))- } catch (error) {- toast.error(- t('settings:remoteAccess.telegramWizard.step3.error', {- error: error instanceof Error ? error.message : String(error),- })- )- } finally {- setIsConfiguring(false)- }- }-- const handleApprovePairing = async () => {- if (!pairingCode.trim()) {- toast.error(t('settings:remoteAccess.telegramWizard.step4.codeRequired'))- return- }-- setIsApproving(true)- try {- await invoke('telegram_approve_pairing', { code: pairingCode.trim() })- toast.success(t('settings:remoteAccess.telegramWizard.step4.approved'))-- const updatedConfig = await invoke<TelegramConfig>('telegram_get_config')- setConfig(updatedConfig)- setStep('success')- if (onConnected) {- onConnected(updatedConfig)- }- } catch (error) {- const errorMsg = error instanceof Error ? error.message : String(error)- toast.error(- t('settings:remoteAccess.telegramWizard.step4.approveError', { error: errorMsg })- )- } finally {- setIsApproving(false)- }- }-- const handleSkipPairing = () => {- setStep('success')- if (config && onConnected) {- onConnected(config)- }- }-- const handleResetPairing = async () => {- setIsResettingPairing(true)- try {- await invoke('telegram_clear_pending_pairing')- setPairingCode('')- toast.success(t('settings:remoteAccess.telegramWizard.step4.resetSuccess'))- } catch {- toast.error(t('settings:remoteAccess.telegramWizard.step4.resetError'))- } finally {- setIsResettingPairing(false)- }- }-- const handleDisconnect = async () => {- try {- await invoke('telegram_disconnect')- setConfig(null)- setToken('')- setValidation(null)- setStep('instructions')- toast.success(t('settings:remoteAccess.telegramWizard.status.notConnected'))- } catch { /* already disconnected */ }- }-- const renderStepIndicator = () => {- const currentStep = getStepNumber()- return (- <div className="flex items-center justify-center gap-2 mb-6">- {Array.from({ length: TOTAL_STEPS }, (_, i) => (- <div- key={i}- className={`flex items-center justify-center w-8 h-8 rounded-full text-sm font-medium ${- i + 1 < currentStep- ? 'bg-green-500 dark:bg-green-700 text-white'- : i + 1 === currentStep- ? 'bg-secondary border border-primary/60 text-primary'- : 'bg-secondary text-muted-foreground'- }`}- >- {i + 1 < currentStep ? (- <IconCheck size={16} />- ) : (- i + 1- )}- </div>- ))}- </div>- )- }-- const renderInstructionsStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.telegramWizard.description')}- </DialogDescription>-- <div className="bg-secondary/50 rounded-lg p-4 space-y-3">- <h4 className="font-medium text-foreground">- {t('settings:remoteAccess.telegramWizard.step1.title')}- </h4>- <ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground">- <li>{t('settings:remoteAccess.telegramWizard.step1.instruction1')}</li>- <li>{t('settings:remoteAccess.telegramWizard.step1.instruction2')}</li>- <li>{t('settings:remoteAccess.telegramWizard.step1.instruction3')}</li>- <li>{t('settings:remoteAccess.telegramWizard.step1.instruction4')}</li>- </ol>- </div>-- <div className="flex justify-center">- <Button- variant="outline"- onClick={() => openUrl('https://t.me/BotFather')}- className="gap-2"- >- <IconBrandTelegram size={18} />- Open BotFather- </Button>- </div>- </div>- )-- const renderTokenStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.telegramWizard.step2.title')}- </DialogDescription>-- <div className="space-y-2">- <Input- type="password"- value={token}- onChange={(e) => {- setToken(e.target.value)- setValidation(null)- }}- placeholder={t('settings:remoteAccess.telegramWizard.step2.placeholder')}- onKeyDown={(e) => {- if (e.key === 'Enter' && !isValidating) {- handleValidateToken()- }- }}- />- </div>-- {validation?.valid && (- <div className="flex items-center gap-1 text-green-500 text-sm">- <IconCheck size={16} />- <span>- {t('settings:remoteAccess.telegramWizard.step2.validToken', {- username: validation.bot_username,- })}- </span>- </div>- )}-- {validation && !validation.valid && (- <div className="flex items-center gap-1 text-red-500 text-sm">- <IconAlertCircle size={16} />- <span>{validation.error}</span>- </div>- )}-- <Button- onClick={handleValidateToken}- disabled={isValidating || !token.trim()}- className="w-full"- variant="outline"- >- {isValidating ? (- <>- <IconLoader2 className="animate-spin size-3" />- {t('settings:remoteAccess.telegramWizard.step2.validating')}- </>- ) : (- t('settings:remoteAccess.telegramWizard.step2.validate')- )}- </Button>- </div>- )-- const renderConfigureStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.telegramWizard.step3.title')}- </DialogDescription>-- <div className="flex flex-col items-center justify-center py-8">- <IconBrandTelegram size={48} className="text-blue-500 mb-4" />- <p className="text-muted-foreground">- {isConfiguring- ? t('settings:remoteAccess.telegramWizard.step3.connecting')- : validation?.bot_username- ? `@${validation.bot_username}`- : ''}- </p>- </div>-- {isConfiguring && (- <div className="flex justify-center">- <IconLoader2 className="animate-spin h-8 w-8 text-primary" />- </div>- )}- </div>- )-- const botUsername = config?.bot_username || validation?.bot_username-- const renderPairingStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.telegramWizard.step4.title')}- </DialogDescription>-- <div className="bg-secondary/50 rounded-lg p-4 space-y-3">- <p className="text-muted-foreground text-sm text-center">- {t('settings:remoteAccess.telegramWizard.step4.instruction')}- </p>-- {botUsername && (- <a- href={`https://t.me/${botUsername}`}- target="_blank"- rel="noopener noreferrer"- className="flex items-center justify-center gap-2 text-primary hover:underline font-medium"- >- <IconBrandTelegram size={18} />- {t('settings:remoteAccess.telegramWizard.step4.openBot', { username: botUsername })}- <IconExternalLink size={14} />- </a>- )}-- <ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground">- <li>{t('settings:remoteAccess.telegramWizard.step4.instruction1')}</li>- <li>{t('settings:remoteAccess.telegramWizard.step4.instruction2')}</li>- <li>{t('settings:remoteAccess.telegramWizard.step4.instruction3')}</li>- </ol>- </div>-- <div className="space-y-2">- <label className="text-sm font-medium text-foreground block">- {t('settings:remoteAccess.telegramWizard.step4.codeLabel')}- </label>- <Input- value={pairingCode}- onChange={(e) => setPairingCode(e.target.value.toUpperCase())}- placeholder={t('settings:remoteAccess.telegramWizard.step4.codePlaceholder')}- className="font-mono text-center text-lg tracking-wider"- />- <button- type="button"- onClick={handleResetPairing}- disabled={isResettingPairing}- className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mx-auto"- >- <IconRefresh size={12} className={isResettingPairing ? 'animate-spin' : ''} />- {t('settings:remoteAccess.telegramWizard.step4.resetPairing')}- </button>- </div>-- <div className="flex gap-2">- <Button- variant="outline"- onClick={handleSkipPairing}- className="flex-1"- >- {t('settings:remoteAccess.telegramWizard.step4.skipForNow')}- </Button>- <Button- onClick={handleApprovePairing}- disabled={isApproving || !pairingCode.trim()}- className="flex-1"- >- {isApproving ? (- <>- <IconLoader2 className="animate-spin h-4 w-4 mr-2" />- {t('settings:remoteAccess.telegramWizard.step4.approving')}- </>- ) : (- t('settings:remoteAccess.telegramWizard.step4.approve')- )}- </Button>- </div>- </div>- )-- const renderSuccessStep = () => (- <div className="space-y-4">- <div className="flex flex-col items-center justify-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center mb-4">- <IconCheck size={32} className="text-green-500" />- </div>- <DialogTitle className="text-center">- {t('settings:remoteAccess.telegramWizard.step5.success')}- </DialogTitle>- </div>-- <DialogDescription className="text-center">- {t('settings:remoteAccess.telegramWizard.step5.instruction')}- </DialogDescription>-- <div className="bg-secondary/50 rounded-lg p-4 text-center space-y-2">- {config?.bot_username && (- <p className="text-foreground">- {t('settings:remoteAccess.telegramWizard.step5.botUsername', {- username: config.bot_username,- })}- </p>- )}- <p className="text-muted-foreground text-sm">- {t('settings:remoteAccess.telegramWizard.step5.pairedUsers', {- count: config?.paired_users || 0,- })}- </p>- </div>-- <Button variant="outline" onClick={handleDisconnect} className="w-full">- {t('settings:remoteAccess.telegramWizard.buttons.disconnect')}- </Button>- </div>- )-- const renderStep = () => {- switch (step) {- case 'instructions':- return renderInstructionsStep()- case 'token':- return renderTokenStep()- case 'configure':- return renderConfigureStep()- case 'pairing':- return renderPairingStep()- case 'success':- return renderSuccessStep()- default:- return null- }- }-- const handleNext = () => {- switch (step) {- case 'instructions':- setStep('token')- break- case 'token':- if (validation?.valid) {- setStep('configure')- handleConfigure()- }- break- case 'configure':- break- case 'pairing':- handleApprovePairing()- break- case 'success':- onOpenChange(false)- break- }- }-- const handleBack = () => {- switch (step) {- case 'token':- setStep('instructions')- break- case 'configure':- setStep('token')- setValidation(null)- break- case 'pairing':- setStep('configure')- break- case 'success':- break- }- }-- const canGoNext = (): boolean => {- switch (step) {- case 'instructions':- return true- case 'token':- return validation?.valid ?? false- case 'configure':- return false- case 'pairing':- return false- case 'success':- return true- default:- return false- }- }-- const canGoBack = (): boolean => {- return step !== 'instructions' && step !== 'success' && step !== 'configure'- }-- return (- <Dialog open={isOpen} onOpenChange={onOpenChange}>- <DialogContent className="sm:max-w-[480px] max-w-[90vw]" onInteractOutside={(e) => e.preventDefault()}>- <DialogHeader>- <div className="flex items-center justify-center gap-2 mb-2">- <IconBrandTelegram size={24} className="text-blue-500" />- <DialogTitle>{t('settings:remoteAccess.telegramWizard.title')}</DialogTitle>- </div>- </DialogHeader>-- {renderStepIndicator()}-- {renderStep()}-- {step !== 'configure' && step !== 'success' && (- <DialogFooter className="gap-2">- {canGoBack() && (- <Button variant="ghost" onClick={handleBack} className="gap-1">- {t('settings:remoteAccess.telegramWizard.buttons.back')}- </Button>- )}- {step !== 'pairing' && (- <Button- onClick={handleNext}- disabled={!canGoNext()}- className="gap-1"- >- {t('settings:remoteAccess.telegramWizard.buttons.next')}- </Button>- )}- </DialogFooter>- )}- </DialogContent>- </Dialog>- )-}\ No newline at end of filediff --git a/web-app/src/containers/dialogs/TunnelSelectionDialog.tsx b/web-app/src/containers/dialogs/TunnelSelectionDialog.tsxdeleted file mode 100644index 291ef8e10..000000000--- a/web-app/src/containers/dialogs/TunnelSelectionDialog.tsx+++ /dev/null@@ -1,708 +0,0 @@-import { useState, useCallback, useEffect } from 'react'-import { useTranslation } from '@/i18n/react-i18next-compat'-import { invoke } from '@tauri-apps/api/core'-import { toast } from 'sonner'-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'-import { Switch } from '@/components/ui/switch'-import {- Collapsible,- CollapsibleContent,- CollapsibleTrigger,-} from '@/components/ui/collapsible'-import { cn } from '@/lib/utils'-import {- IconLoader2,- IconCheck,- IconChevronDown,- IconExternalLink,- IconCopy,- IconRefresh,- IconPlayerPlay,- IconPlayerStop,- IconAlertCircle,-} from '@tabler/icons-react'--import type { TunnelProvider } from '@/types/openclaw'--interface TunnelProviderStatus {- provider: TunnelProvider- installed: boolean- authenticated: boolean- version: string | null- error: string | null-}--interface TunnelProvidersStatus {- tailscale: TunnelProviderStatus- ngrok: TunnelProviderStatus- cloudflare: TunnelProviderStatus- active_provider: TunnelProvider- active_tunnel: TunnelInfo | null-}--interface TunnelInfo {- provider: TunnelProvider- url: string- started_at: string- port: number- is_public: boolean-}--interface TunnelConfig {- preferred_provider: TunnelProvider- ngrok_auth_token: string | null- cloudflare_tunnel_id: string | null- auto_start: boolean-}--interface TunnelSelectionDialogProps {- isOpen: boolean- onClose: () => void- onTailscaleSetup?: () => void- onSave?: () => void-}--interface ProviderCardProps {- provider: TunnelProvider- name: string- description: string- features: string[]- status: TunnelProviderStatus | null- selected: boolean- onSelect: () => void- installUrl?: string- isLoading?: boolean- children?: React.ReactNode-}--function ProviderCard({- provider,- name,- description,- features,- status,- selected,- onSelect,- installUrl,- isLoading,- children,-}: ProviderCardProps) {- const { t } = useTranslation()- const [isExpanded, setIsExpanded] = useState(selected)-- useEffect(() => {- if (selected) {- setIsExpanded(true)- }- }, [selected])-- const isInstalled = status?.installed ?? false-- return (- <div- className={cn(- 'rounded-lg border p-4 transition-all cursor-pointer',- selected- ? 'border-primary bg-primary/5'- : 'border-border hover:border-primary/50'- )}- onClick={onSelect}- >- <div className="flex items-start justify-between gap-3">- <div className="flex items-start gap-3 flex-1">- <div- className={cn(- 'w-4 h-4 rounded-full border-2 mt-0.5 shrink-0 flex items-center justify-center',- selected ? 'border-primary bg-primary' : 'border-muted-foreground'- )}- >- {selected && <IconCheck size={10} className="text-white" />}- </div>- <div className="flex-1 min-w-0">- <div className="flex items-center gap-2 mb-1">- <h3 className="font-medium text-foreground">{name}</h3>- {provider !== 'none' && provider !== 'localonly' && (- <div className="flex items-center gap-1.5">- {isLoading ? (- <IconLoader2 size={14} className="animate-spin text-muted-foreground" />- ) : isInstalled ? (- <div className="flex items-center gap-1">- <div className="w-2 h-2 rounded-full bg-green-500" />- <span className="text-xs text-muted-foreground">- {status?.version || t('settings:tunnel.installed')}- </span>- </div>- ) : (- <div className="flex items-center gap-1">- <div className="w-2 h-2 rounded-full bg-red-500" />- <span className="text-xs text-muted-foreground">- {t('settings:tunnel.notInstalled')}- </span>- </div>- )}- </div>- )}- </div>- <p className="text-sm text-muted-foreground">{description}</p>- {features.length > 0 && (- <ul className="mt-2 space-y-1">- {features.map((feature, index) => (- <li- key={index}- className="text-xs text-muted-foreground flex items-center gap-1.5"- >- <span className="text-primary">-</span>- {feature}- </li>- ))}- </ul>- )}- </div>- </div>- </div>-- {/* Expandable configuration section */}- {selected && children && (- <Collapsible open={isExpanded} onOpenChange={setIsExpanded}>- <CollapsibleTrigger- className="flex items-center gap-1 text-sm text-muted-foreground mt-3 hover:text-foreground transition-colors"- onClick={(e) => e.stopPropagation()}- >- <IconChevronDown- size={16}- className={cn(- 'transition-transform',- isExpanded && 'rotate-180'- )}- />- {t('settings:tunnel.configuration')}- </CollapsibleTrigger>- <CollapsibleContent className="mt-3">- <div- className="border-t border-border pt-3"- onClick={(e) => e.stopPropagation()}- >- {!isInstalled && installUrl && (- <div className="mb-3 p-3 bg-muted/50 rounded-md">- <p className="text-sm text-muted-foreground mb-2">- {t('settings:tunnel.installRequired')}- </p>- <Button- variant="outline"- size="sm"- onClick={() => window.open(installUrl, '_blank')}- >- <IconExternalLink size={14} className="mr-1.5" />- {t('settings:tunnel.installInstructions')}- </Button>- </div>- )}- {children}- </div>- </CollapsibleContent>- </Collapsible>- )}- </div>- )-}--export function TunnelSelectionDialog({- isOpen,- onClose,- onTailscaleSetup,- onSave,-}: TunnelSelectionDialogProps) {- const { t } = useTranslation()-- // State- const [providersStatus, setProvidersStatus] = useState<TunnelProvidersStatus | null>(null)- // Config is used for initial state hydration- const [, setConfig] = useState<TunnelConfig | null>(null)- const [selectedProvider, setSelectedProvider] = useState<TunnelProvider>('none')- const [isDetecting, setIsDetecting] = useState(false)- const [isStarting, setIsStarting] = useState(false)- const [isStopping, setIsStopping] = useState(false)- const [isSaving, setIsSaving] = useState(false)- const [showStopConfirm, setShowStopConfirm] = useState(false)-- // Configuration inputs- const [ngrokToken, setNgrokToken] = useState('')- const [cloudflareTunnelId, setCloudflareTunnelId] = useState('')- const [autoStart, setAutoStart] = useState(false)-- const fetchProvidersStatus = useCallback(async () => {- try {- setIsDetecting(true)- const status = await invoke<TunnelProvidersStatus>('tunnel_get_providers')- setProvidersStatus(status)- if (status.active_provider) {- setSelectedProvider(status.active_provider)- }- } catch {- toast.error(t('settings:tunnel.fetchStatusError'))- } finally {- setIsDetecting(false)- }- }, [t])-- const fetchConfig = useCallback(async () => {- try {- const tunnelConfig = await invoke<TunnelConfig>('tunnel_get_config')- setConfig(tunnelConfig)- setSelectedProvider(tunnelConfig.preferred_provider || 'none')- setNgrokToken(tunnelConfig.ngrok_auth_token || '')- setCloudflareTunnelId(tunnelConfig.cloudflare_tunnel_id || '')- setAutoStart(tunnelConfig.auto_start)- } catch {- // Config may not exist yet- }- }, [])-- // Fetch providers status and config on open- useEffect(() => {- if (isOpen) {- fetchProvidersStatus()- fetchConfig()- }- }, [isOpen, fetchProvidersStatus, fetchConfig])-- // Reset state when dialog closes- useEffect(() => {- if (!isOpen) {- setShowStopConfirm(false)- }- }, [isOpen])-- const handleDetectAll = useCallback(async () => {- try {- setIsDetecting(true)- const status = await invoke<TunnelProvidersStatus>('tunnel_detect_all')- setProvidersStatus(status)- toast.success(t('settings:tunnel.detectionComplete'))- } catch {- toast.error(t('settings:tunnel.detectionError'))- } finally {- setIsDetecting(false)- }- }, [t])-- const handleSelectProvider = useCallback(async (provider: TunnelProvider) => {- setSelectedProvider(provider)- }, [])-- const handleSaveNgrokToken = useCallback(async () => {- if (!ngrokToken.trim()) {- toast.error(t('settings:tunnel.ngrok.tokenRequired'))- return- }- try {- await invoke('tunnel_set_ngrok_token', { token: ngrokToken.trim() })- toast.success(t('settings:tunnel.ngrok.tokenSaved'))- await fetchProvidersStatus()- } catch {- toast.error(t('settings:tunnel.ngrok.tokenSaveError'))- }- }, [ngrokToken, t, fetchProvidersStatus])-- const handleSaveCloudflareTunnel = useCallback(async () => {- if (!cloudflareTunnelId.trim()) {- toast.error(t('settings:tunnel.cloudflare.tunnelIdRequired'))- return- }- try {- await invoke('tunnel_set_cloudflare_tunnel', { tunnelId: cloudflareTunnelId.trim() })- toast.success(t('settings:tunnel.cloudflare.tunnelIdSaved'))- await fetchProvidersStatus()- } catch {- toast.error(t('settings:tunnel.cloudflare.tunnelIdSaveError'))- }- }, [cloudflareTunnelId, t, fetchProvidersStatus])-- const handleStartTunnel = useCallback(async () => {- try {- setIsStarting(true)- await invoke('tunnel_set_provider', { provider: selectedProvider })- await invoke('tunnel_start')- toast.success(t('settings:tunnel.startSuccess'))- await fetchProvidersStatus()- } catch (error) {- const errorMsg = error instanceof Error ? error.message : String(error)- toast.error(t('settings:tunnel.startError', { error: errorMsg }))- } finally {- setIsStarting(false)- }- }, [selectedProvider, t, fetchProvidersStatus])-- const handleStopTunnel = useCallback(async () => {- try {- setIsStopping(true)- await invoke('tunnel_stop')- toast.success(t('settings:tunnel.stopSuccess'))- setShowStopConfirm(false)- await fetchProvidersStatus()- } catch {- toast.error(t('settings:tunnel.stopError'))- } finally {- setIsStopping(false)- }- }, [t, fetchProvidersStatus])-- const handleSave = useCallback(async () => {- try {- setIsSaving(true)- await invoke('tunnel_set_provider', { provider: selectedProvider })- toast.success(t('settings:tunnel.saved'))- onSave?.()- onClose()- } catch {- toast.error(t('settings:tunnel.saveError'))- } finally {- setIsSaving(false)- }- }, [selectedProvider, t, onSave, onClose])-- const handleCopyUrl = useCallback(() => {- if (providersStatus?.active_tunnel?.url) {- navigator.clipboard.writeText(providersStatus.active_tunnel.url)- toast.success(t('settings:tunnel.urlCopied'))- }- }, [providersStatus?.active_tunnel?.url, t])-- const activeTunnel = providersStatus?.active_tunnel- const hasTunnelRunning = !!activeTunnel-- // Get provider status helper- const getProviderStatus = (provider: TunnelProvider): TunnelProviderStatus | null => {- if (!providersStatus) return null- switch (provider) {- case 'tailscale':- return providersStatus.tailscale- case 'ngrok':- return providersStatus.ngrok- case 'cloudflare':- return providersStatus.cloudflare- default:- return null- }- }-- return (- <Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>- <DialogContent className="sm:max-w-[600px] max-w-[90vw]">- <DialogHeader>- <DialogTitle>{t('settings:tunnel.title')}</DialogTitle>- <DialogDescription>- {t('settings:tunnel.description')}- </DialogDescription>- </DialogHeader>-- {/* Active Tunnel Status */}- {hasTunnelRunning && (- <div className="bg-green-500/10 border border-green-500/30 rounded-lg p-4">- <div className="flex items-center justify-between">- <div className="flex items-center gap-3">- <div className="w-3 h-3 rounded-full bg-green-500 animate-pulse" />- <div>- <p className="font-medium text-foreground">- {t('settings:tunnel.activeStatus')}- </p>- <p className="text-sm text-muted-foreground">- {t('settings:tunnel.provider')}: {activeTunnel.provider}- </p>- </div>- </div>- <Button- variant="destructive"- size="sm"- onClick={() => setShowStopConfirm(true)}- disabled={isStopping}- >- {isStopping ? (- <IconLoader2 className="animate-spin mr-1.5 h-4 w-4" />- ) : (- <IconPlayerStop className="mr-1.5 h-4 w-4" />- )}- {t('settings:tunnel.stop')}- </Button>- </div>- <div className="mt-3 flex items-center gap-2">- <Input- value={activeTunnel.url}- readOnly- className="font-mono text-sm bg-background"- />- <Button variant="outline" size="icon" onClick={handleCopyUrl}>- <IconCopy size={16} />- </Button>- </div>- <div className="mt-2 flex items-center gap-4 text-xs text-muted-foreground">- <span>- {t('settings:tunnel.port')}: {activeTunnel.port}- </span>- <span>- {activeTunnel.is_public- ? t('settings:tunnel.publicAccess')- : t('settings:tunnel.privateAccess')}- </span>- </div>- </div>- )}-- {/* Stop Confirmation */}- {showStopConfirm && (- <div className="bg-destructive/10 border border-destructive/30 rounded-lg p-4">- <div className="flex items-start gap-3">- <IconAlertCircle className="text-destructive shrink-0 mt-0.5" size={20} />- <div className="flex-1">- <p className="font-medium text-foreground">- {t('settings:tunnel.stopConfirmTitle')}- </p>- <p className="text-sm text-muted-foreground mt-1">- {t('settings:tunnel.stopConfirmDescription')}- </p>- <div className="flex items-center gap-2 mt-3">- <Button- variant="destructive"- size="sm"- onClick={handleStopTunnel}- disabled={isStopping}- >- {isStopping && (- <IconLoader2 className="animate-spin mr-1.5 h-4 w-4" />- )}- {t('settings:tunnel.confirmStop')}- </Button>- <Button- variant="outline"- size="sm"- onClick={() => setShowStopConfirm(false)}- >- {t('common:cancel')}- </Button>- </div>- </div>- </div>- </div>- )}-- {/* Detect Providers Button */}- <div className="flex items-center justify-between">- <span className="text-sm text-muted-foreground">- {t('settings:tunnel.selectProvider')}- </span>- <Button- variant="outline"- size="sm"- onClick={handleDetectAll}- disabled={isDetecting}- >- {isDetecting ? (- <IconLoader2 className="animate-spin mr-1.5 h-4 w-4" />- ) : (- <IconRefresh className="mr-1.5 h-4 w-4" />- )}- {t('settings:tunnel.detectProviders')}- </Button>- </div>-- {/* Provider Selection */}- <div className="space-y-3 max-h-[40vh] overflow-y-auto pr-1">- {/* None / Local Only */}- <ProviderCard- provider="none"- name={t('settings:tunnel.providers.none.name')}- description={t('settings:tunnel.providers.none.description')}- features={[]}- status={null}- selected={selectedProvider === 'none' || selectedProvider === 'localonly'}- onSelect={() => handleSelectProvider('none')}- />-- {/* Tailscale */}- <ProviderCard- provider="tailscale"- name={t('settings:tunnel.providers.tailscale.name')}- description={t('settings:tunnel.providers.tailscale.description')}- features={[- t('settings:tunnel.providers.tailscale.feature1'),- t('settings:tunnel.providers.tailscale.feature2'),- t('settings:tunnel.providers.tailscale.feature3'),- ]}- status={getProviderStatus('tailscale')}- selected={selectedProvider === 'tailscale'}- onSelect={() => handleSelectProvider('tailscale')}- installUrl="https://tailscale.com/download"- isLoading={isDetecting}- >- <div className="space-y-3">- <p className="text-sm text-muted-foreground">- {t('settings:tunnel.providers.tailscale.configInfo')}- </p>- {onTailscaleSetup && (- <Button variant="outline" size="sm" onClick={onTailscaleSetup}>- <IconExternalLink size={14} className="mr-1.5" />- {t('settings:tunnel.providers.tailscale.openSetup')}- </Button>- )}- </div>- </ProviderCard>-- {/* ngrok */}- <ProviderCard- provider="ngrok"- name={t('settings:tunnel.providers.ngrok.name')}- description={t('settings:tunnel.providers.ngrok.description')}- features={[- t('settings:tunnel.providers.ngrok.feature1'),- t('settings:tunnel.providers.ngrok.feature2'),- t('settings:tunnel.providers.ngrok.feature3'),- ]}- status={getProviderStatus('ngrok')}- selected={selectedProvider === 'ngrok'}- onSelect={() => handleSelectProvider('ngrok')}- installUrl="https://ngrok.com/download"- isLoading={isDetecting}- >- <div className="space-y-3">- <div>- <label className="text-sm font-medium text-foreground mb-1.5 block">- {t('settings:tunnel.providers.ngrok.authToken')}- </label>- <div className="flex items-center gap-2">- <Input- type="password"- value={ngrokToken}- onChange={(e) => setNgrokToken(e.target.value)}- placeholder={t('settings:tunnel.providers.ngrok.tokenPlaceholder')}- className="font-mono"- />- <Button- variant="outline"- size="sm"- onClick={handleSaveNgrokToken}- disabled={!ngrokToken.trim()}- >- {t('common:save')}- </Button>- </div>- </div>- <Button- variant="link"- size="sm"- className="p-0 h-auto"- onClick={() =>- window.open('https://dashboard.ngrok.com/get-started/your-authtoken', '_blank')- }- >- <IconExternalLink size={14} className="mr-1" />- {t('settings:tunnel.providers.ngrok.getToken')}- </Button>- </div>- </ProviderCard>-- {/* Cloudflare */}- <ProviderCard- provider="cloudflare"- name={t('settings:tunnel.providers.cloudflare.name')}- description={t('settings:tunnel.providers.cloudflare.description')}- features={[- t('settings:tunnel.providers.cloudflare.feature1'),- t('settings:tunnel.providers.cloudflare.feature2'),- t('settings:tunnel.providers.cloudflare.feature3'),- ]}- status={getProviderStatus('cloudflare')}- selected={selectedProvider === 'cloudflare'}- onSelect={() => handleSelectProvider('cloudflare')}- installUrl="https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/"- isLoading={isDetecting}- >- <div className="space-y-3">- <div>- <label className="text-sm font-medium text-foreground mb-1.5 block">- {t('settings:tunnel.providers.cloudflare.tunnelId')}- </label>- <div className="flex items-center gap-2">- <Input- value={cloudflareTunnelId}- onChange={(e) => setCloudflareTunnelId(e.target.value)}- placeholder={t('settings:tunnel.providers.cloudflare.tunnelIdPlaceholder')}- className="font-mono"- />- <Button- variant="outline"- size="sm"- onClick={handleSaveCloudflareTunnel}- disabled={!cloudflareTunnelId.trim()}- >- {t('common:save')}- </Button>- </div>- </div>- <Button- variant="link"- size="sm"- className="p-0 h-auto"- onClick={() =>- window.open('https://one.dash.cloudflare.com/', '_blank')- }- >- <IconExternalLink size={14} className="mr-1" />- {t('settings:tunnel.providers.cloudflare.openDashboard')}- </Button>- </div>- </ProviderCard>- </div>-- {/* Auto-start Toggle */}- <div className="flex items-center justify-between py-2 border-t border-border">- <div>- <p className="font-medium text-foreground">- {t('settings:tunnel.autoStart')}- </p>- <p className="text-sm text-muted-foreground">- {t('settings:tunnel.autoStartDescription')}- </p>- </div>- <Switch- checked={autoStart}- onCheckedChange={setAutoStart}- disabled={selectedProvider === 'none'}- />- </div>-- <DialogFooter className="gap-2 sm:gap-0">- <Button variant="outline" onClick={onClose}>- {t('common:cancel')}- </Button>- {!hasTunnelRunning && selectedProvider !== 'none' && (- <Button- variant="secondary"- onClick={handleStartTunnel}- disabled={isStarting || !getProviderStatus(selectedProvider)?.installed}- >- {isStarting ? (- <IconLoader2 className="animate-spin mr-1.5 h-4 w-4" />- ) : (- <IconPlayerPlay className="mr-1.5 h-4 w-4" />- )}- {t('settings:tunnel.startTunnel')}- </Button>- )}- <Button onClick={handleSave} disabled={isSaving}>- {isSaving && <IconLoader2 className="animate-spin mr-1.5 h-4 w-4" />}- {t('common:save')}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>- )-}diff --git a/web-app/src/containers/dialogs/WhatsAppWizardDialog.tsx b/web-app/src/containers/dialogs/WhatsAppWizardDialog.tsxdeleted file mode 100644index e0bc0d1dd..000000000--- a/web-app/src/containers/dialogs/WhatsAppWizardDialog.tsx+++ /dev/null@@ -1,453 +0,0 @@-import { useState, useCallback, useEffect } from 'react'-import { useTranslation } from '@/i18n/react-i18next-compat'-import { invoke } from '@tauri-apps/api/core'-import { toast } from 'sonner'-import {- IconBrandWhatsapp,- IconQrcode,- IconCheck,- IconX,- IconRefresh,- IconArrowLeft,-} from '@tabler/icons-react'-import {- Dialog,- DialogContent,- DialogFooter,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import type { WhatsAppConfig } from '@/types/openclaw'--export type { WhatsAppConfig }--interface WhatsAppAuthStatus {- in_progress: boolean- qr_code_ready: boolean- qr_code: string | null- authenticated: boolean- error: string | null-}--interface WhatsAppWizardDialogProps {- isOpen: boolean- onOpenChange: (open: boolean) => void- onConnected: (config: WhatsAppConfig) => void-}--type WizardStep = 'welcome' | 'setting_up' | 'scanning' | 'verifying' | 'success' | 'error'--export function WhatsAppWizardDialog({- isOpen,- onOpenChange,- onConnected,-}: WhatsAppWizardDialogProps) {- const { t } = useTranslation()- const [step, setStep] = useState<WizardStep>('welcome')- const [isLoading, setIsLoading] = useState(false)- const [isPolling, setIsPolling] = useState(false)- const [pollingInterval, setPollingInterval] = useState<NodeJS.Timeout | null>(null)- const [, setAuthStatus] = useState<WhatsAppAuthStatus | null>(null)- const [qrCodeImage, setQrCodeImage] = useState<string | null>(null)- const [errorMessage, setErrorMessage] = useState<string | null>(null)- const [config, setConfig] = useState<WhatsAppConfig | null>(null)-- useEffect(() => {- return () => {- if (pollingInterval) {- clearInterval(pollingInterval)- }- }- }, [pollingInterval])-- useEffect(() => {- if (!isOpen && pollingInterval) {- clearInterval(pollingInterval)- setPollingInterval(null)- }- }, [isOpen, pollingInterval])-- useEffect(() => {- if (isOpen) {- setStep('welcome')- setIsLoading(false)- setIsPolling(false)- setAuthStatus(null)- setQrCodeImage(null)- setErrorMessage(null)- setConfig(null)- setPollingInterval((prev) => {- if (prev) {- clearInterval(prev)- }- return null- })- }- }, [isOpen])-- const startPolling = useCallback(() => {- const interval = setInterval(async () => {- try {- const status = await invoke<WhatsAppAuthStatus>('whatsapp_check_auth')- setAuthStatus(status)-- if (status.qr_code) {- setQrCodeImage(status.qr_code)- }-- if (status.authenticated) {- clearInterval(interval)- setPollingInterval(null)- setIsPolling(false)-- const whatsappConfig = await invoke<WhatsAppConfig>('whatsapp_get_config')- setConfig(whatsappConfig)- setStep('success')- onConnected(whatsappConfig)- }-- if (status.error && !status.in_progress) {- const transientPatterns = [- '515',- 'restart required',- 'Stream Errored',- 'not linked',- 'not configured',- 'timed out',- 'Request timed out',- 'Connection closed',- 'Gateway is not running',- ]- const isTransient = transientPatterns.some((p) =>- status.error!.includes(p)- )-- if (!isTransient) {- clearInterval(interval)- setPollingInterval(null)- setIsPolling(false)- setErrorMessage(status.error)- setStep('error')- }- }- } catch { /* retry next interval */ }- }, 5000)-- setPollingInterval(interval)- setIsPolling(true)- }, [onConnected])-- const startAuthentication = useCallback(async () => {- try {- setIsLoading(true)- setErrorMessage(null)-- setStep('setting_up')- const status = await invoke<WhatsAppAuthStatus>('whatsapp_start_auth')- setAuthStatus(status)-- if (status.error) {- setErrorMessage(status.error)- setStep('error')- return- }-- if (status.authenticated) {- const whatsappConfig = await invoke<WhatsAppConfig>('whatsapp_get_config')- setConfig(whatsappConfig)- setStep('success')- onConnected(whatsappConfig)- return- }-- if (status.qr_code) {- setQrCodeImage(status.qr_code)- }-- setStep('scanning')- startPolling()- } catch (error) {- setErrorMessage(- error instanceof Error ? error.message : String(error)- )- setStep('error')- } finally {- setIsLoading(false)- }- }, [onConnected, startPolling])-- const handleDisconnect = useCallback(async () => {- try {- setIsLoading(true)- await invoke('whatsapp_disconnect')- setStep('welcome')- setConfig(null)- setQrCodeImage(null)- if (pollingInterval) {- clearInterval(pollingInterval)- setPollingInterval(null)- }- setIsPolling(false)- } catch {- toast.error(t('settings:remoteAccess.disconnectError'))- } finally {- setIsLoading(false)- }- }, [pollingInterval, t])-- const handleClose = useCallback(() => {- if (pollingInterval) {- clearInterval(pollingInterval)- setPollingInterval(null)- }- onOpenChange(false)- }, [pollingInterval, onOpenChange])-- const renderStepContent = () => {- switch (step) {- case 'welcome':- return (- <div className="flex flex-col items-center text-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4">- <IconBrandWhatsapp size={32} className="text-green-500" />- </div>- <h3 className="text-lg font-semibold mb-2">- {t('settings:remoteAccess.whatsappWizard.setupTitle')}- </h3>- <p className="text-muted-foreground text-sm mb-6 max-w-xs">- {t('settings:remoteAccess.whatsappWizard.setupDescription')}- </p>- <div className="bg-muted/50 rounded-lg p-4 w-full text-left">- <h4 className="font-medium text-sm mb-2">- {t('settings:remoteAccess.whatsappWizard.howItWorks')}- </h4>- <ol className="text-muted-foreground text-sm space-y-2">- <li className="flex items-start gap-2">- <span className="font-medium text-foreground">1.</span>- {t('settings:remoteAccess.whatsappWizard.whatsappStep1')}- </li>- <li className="flex items-start gap-2">- <span className="font-medium text-foreground">2.</span>- {t('settings:remoteAccess.whatsappWizard.whatsappStep2')}- </li>- <li className="flex items-start gap-2">- <span className="font-medium text-foreground">3.</span>- {t('settings:remoteAccess.whatsappWizard.whatsappStep3')}- </li>- </ol>- </div>- </div>- )-- case 'setting_up':- return (- <div className="flex flex-col items-center text-center py-4">- <div className="w-16 h-16 rounded-full bg-blue-500/10 flex items-center justify-center mb-4">- <IconRefresh size={32} className="text-blue-500 animate-spin" />- </div>- <h3 className="text-lg font-semibold mb-2">- {t('settings:remoteAccess.whatsappWizard.settingUp') || 'Setting up...'}- </h3>- <p className="text-muted-foreground text-sm mb-4">- {t('settings:remoteAccess.whatsappWizard.settingUpDescription') || 'Configuring OpenClaw and preparing WhatsApp connection. This may take a moment...'}- </p>- <div className="bg-muted/50 rounded-lg p-4 w-full text-left">- <ol className="text-muted-foreground text-sm space-y-2">- <li className="flex items-center gap-2">- <IconCheck size={16} className="text-green-500" />- <span>{t('settings:remoteAccess.whatsappWizard.checkingOpenClaw') || 'Checking OpenClaw installation'}</span>- </li>- <li className="flex items-center gap-2">- <IconRefresh size={16} className="animate-spin" />- <span>{t('settings:remoteAccess.whatsappWizard.configuringGateway') || 'Configuring Gateway connection'}</span>- </li>- <li className="flex items-center gap-2 text-muted-foreground/50">- <span className="w-4 h-4" />- <span>{t('settings:remoteAccess.whatsappWizard.enablingWhatsApp') || 'Enabling WhatsApp channel'}</span>- </li>- </ol>- </div>- </div>- )-- case 'scanning':- return (- <div className="flex flex-col items-center text-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4">- <IconQrcode size={32} className="text-green-500" />- </div>- <h3 className="text-lg font-semibold mb-2">- {t('settings:remoteAccess.whatsappWizard.scanQrCode')}- </h3>- <p className="text-muted-foreground text-sm mb-4">- {t('settings:remoteAccess.whatsappWizard.qrCodeInstructions')}- </p>-- <div className="bg-white p-4 rounded-lg mb-4 min-h-[200px] min-w-[200px] flex items-center justify-center">- {qrCodeImage ? (- <img- src={qrCodeImage}- alt="WhatsApp QR Code"- className="w-48 h-48"- />- ) : (- <div className="flex flex-col items-center text-muted-foreground">- <IconQrcode size={48} className="mb-2" />- <span className="text-sm">- {t('settings:remoteAccess.whatsappWizard.generatingQrCode')}- </span>- </div>- )}- </div>-- {isPolling && (- <p className="text-muted-foreground text-xs">- {t('settings:remoteAccess.whatsappWizard.waitingForScan')}- </p>- )}- </div>- )-- case 'verifying':- return (- <div className="flex flex-col items-center text-center py-4">- <div className="w-16 h-16 rounded-full bg-blue-500/10 flex items-center justify-center mb-4">- <IconRefresh size={32} className="text-blue-500 animate-spin" />- </div>- <h3 className="text-lg font-semibold mb-2">- {t('settings:remoteAccess.whatsappWizard.verifyingConnection')}- </h3>- <p className="text-muted-foreground text-sm">- {t('settings:remoteAccess.whatsappWizard.pleaseWait')}- </p>- </div>- )-- case 'success':- return (- <div className="flex flex-col items-center text-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4">- <IconCheck size={32} className="text-green-500" />- </div>- <h3 className="text-lg font-semibold mb-2">- {t('settings:remoteAccess.whatsappWizard.whatsappConnected')}- </h3>- <p className="text-muted-foreground text-sm mb-4">- {t('settings:remoteAccess.whatsappWizard.whatsappConnectedDescription')}- </p>- {config?.phone_number && (- <div className="bg-muted/50 rounded-lg px-4 py-2">- <span className="text-sm font-medium">{config.phone_number}</span>- </div>- )}- </div>- )-- case 'error':- return (- <div className="flex flex-col items-center text-center py-4">- <div className="w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-4">- <IconX size={32} className="text-red-500" />- </div>- <h3 className="text-lg font-semibold mb-2">- {t('settings:remoteAccess.whatsappWizard.connectionFailed')}- </h3>- <p className="text-muted-foreground text-sm mb-4">- {errorMessage || t('settings:remoteAccess.whatsappWizard.unknownError')}- </p>- </div>- )-- default:- return null- }- }-- const renderFooter = () => {- switch (step) {- case 'welcome':- return (- <>- <Button variant="outline" onClick={handleClose}>- {t('common:cancel')}- </Button>- <Button onClick={startAuthentication} disabled={isLoading}>- {isLoading ? t('settings:remoteAccess.whatsappWizard.connecting') : t('settings:remoteAccess.whatsappWizard.startSetup')}- </Button>- </>- )-- case 'scanning':- return (- <>- <Button- variant="outline"- onClick={() => {- if (pollingInterval) {- clearInterval(pollingInterval)- setPollingInterval(null)- }- setIsPolling(false)- setStep('welcome')- }}- disabled={isLoading}- >- <IconArrowLeft className="mr-2 h-4 w-4" />- {t('settings:remoteAccess.whatsappWizard.back')}- </Button>- <Button onClick={startAuthentication} disabled={isLoading}>- <IconRefresh className="mr-2 h-4 w-4" />- {t('settings:remoteAccess.whatsappWizard.refreshQrCode')}- </Button>- </>- )-- case 'verifying':- return null-- case 'success':- return (- <>- <Button variant="outline" onClick={handleDisconnect} disabled={isLoading}>- {t('settings:remoteAccess.disconnect')}- </Button>- <Button onClick={handleClose}>- {t('common:done')}- </Button>- </>- )-- case 'error':- return (- <>- <Button- variant="outline"- onClick={() => {- setStep('welcome')- setErrorMessage(null)- }}- >- <IconArrowLeft className="mr-2 h-4 w-4" />- {t('settings:remoteAccess.whatsappWizard.tryAgain')}- </Button>- <Button onClick={handleClose}>- {t('common:close')}- </Button>- </>- )-- default:- return null- }- }-- return (- <Dialog open={isOpen} onOpenChange={handleClose}>- <DialogContent className="sm:max-w-md" onInteractOutside={(e) => e.preventDefault()}>- <div className="py-2">{renderStepContent()}</div>- <DialogFooter className="sm:justify-between">- {renderFooter()}- </DialogFooter>- </DialogContent>- </Dialog>- )-}\ No newline at end of filediff --git a/web-app/src/hooks/useAgentMode.ts b/web-app/src/hooks/useAgentMode.tsindex 50cbcd31d..de677ce05 100644--- a/web-app/src/hooks/useAgentMode.ts+++ b/web-app/src/hooks/useAgentMode.ts@@ -10,7 +10,7 @@ type AgentModeState = {toggleAgentMode: (threadId: string) => voidsetAgentMode: (threadId: string, enabled: boolean) => voidremoveThread: (threadId: string) => void- /** Clear agent mode for all threads (e.g. when OpenClaw is stopped). */+ /** Clear agent mode for all threads. */clearAll: () => void}diff --git a/web-app/src/hooks/useAppState.ts b/web-app/src/hooks/useAppState.tsindex d39d21831..bf9d758f4 100644--- a/web-app/src/hooks/useAppState.ts+++ b/web-app/src/hooks/useAppState.ts@@ -22,7 +22,6 @@ type AppState = {ragToolNames: Set<string>mcpToolNames: Set<string>serverStatus: 'running' | 'stopped' | 'pending'- openClawRunning: booleanabortControllers: Record<string, AbortController>tokenSpeed?: TokenSpeedshowOutOfContextDialog?: boolean@@ -31,7 +30,6 @@ type AppState = {activeModels: string[]cancelToolCall?: () => voidsetServerStatus: (value: 'running' | 'stopped' | 'pending') => void- setOpenClawRunning: (running: boolean) => voidupdateStreamingContent: (content: ThreadMessage | undefined) => voidupdateLoadingModel: (loading: boolean) => voidupdateTools: (tools: MCPTool[]) => void@@ -60,7 +58,6 @@ export const useAppState = create<AppState>()((set) => ({ragToolNames: new Set<string>(),mcpToolNames: new Set<string>(),serverStatus: 'stopped',- openClawRunning: false,abortControllers: {},tokenSpeed: undefined,currentToolCall: undefined,@@ -90,7 +87,6 @@ export const useAppState = create<AppState>()((set) => ({set({ mcpToolNames: new Set(names) })},setServerStatus: (value) => set({ serverStatus: value }),- setOpenClawRunning: (running) => set({ openClawRunning: running }),setAbortController: (threadId, controller) => {set((state) => ({abortControllers: {diff --git a/web-app/src/lib/custom-chat-transport.ts b/web-app/src/lib/custom-chat-transport.tsindex 9f2384610..e3c554271 100644--- a/web-app/src/lib/custom-chat-transport.ts+++ b/web-app/src/lib/custom-chat-transport.ts@@ -15,8 +15,6 @@ import { useToolAvailable } from '@/hooks/useToolAvailable'import { ModelFactory } from './model-factory'import { useModelProvider } from '@/hooks/useModelProvider'import { useAssistant } from '@/hooks/useAssistant'-import { useAgentMode } from '@/hooks/useAgentMode'-import { getOpenClawAuthToken, ensureOpenClawHttpApi, checkOpenClawGateway, OPENCLAW_GATEWAY_URL } from '@/utils/openclaw'import { useThreads } from '@/hooks/useThreads'import { useAttachments } from '@/hooks/useAttachments'import { ExtensionManager } from '@/lib/extension'@@ -273,83 +271,38 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {// Ensure tools updated before sending messagesawait this.refreshTools()- // Check if agent mode is active for this thread- const isAgentMode = this.threadId- ? useAgentMode.getState().isAgentMode(this.threadId)- : false-// Capture the effective provider name early so the Anthropic serial// tool-use repair later uses the same value that was used to create the// model, even if the user switches provider mid-request.- let effectiveProviderName: string | undefined-- if (isAgentMode) {- // Agent mode: route to OpenClaw gateway- effectiveProviderName = 'openclaw'- await ensureOpenClawHttpApi()-- const gatewayReachable = await checkOpenClawGateway()- if (!gatewayReachable) {- throw new Error('Cannot reach the OpenClaw gateway. Please check that Remote Access is running in Settings.')- }-- const authToken = await getOpenClawAuthToken()- if (!authToken) {- throw new Error('OpenClaw is not available. Please check that it is running in Settings > Remote Access.')- }-- const openclawProvider: ProviderObject = {- active: true,- provider: 'openclaw',- api_key: authToken,- base_url: OPENCLAW_GATEWAY_URL,- settings: [],- models: [],- custom_header: this.threadId- ? [{ header: 'x-openclaw-session-key', value: this.threadId }]- : [],- }-+ const modelId = useModelProvider.getState().selectedModel?.id+ const providerId = useModelProvider.getState().selectedProvider+ const effectiveProviderName = providerId+ const provider = useModelProvider.getState().getProviderByName(providerId)+ if (this.serviceHub && modelId && provider) {try {- this.model = await ModelFactory.createModel('openclaw', openclawProvider)+ const updatedProvider = useModelProvider+ .getState()+ .getProviderByName(providerId)++ // Get assistant parameters from current assistant+ const currentAssistant = useAssistant.getState().currentAssistant+ const inferenceParams = currentAssistant?.parameters++ // Create the model using the factory+ // For llamacpp provider, startModel is called internally in ModelFactory.createLlamaCppModel+ this.model = await ModelFactory.createModel(+ modelId,+ updatedProvider ?? provider,+ inferenceParams ?? {}+ )} catch (error) {- console.error('Failed to create OpenClaw model:', error)+ console.error('Failed to create model:', error)throw new Error(- `Failed to connect to OpenClaw: ${error instanceof Error ? error.message : JSON.stringify(error)}`+ `Failed to create model: ${error instanceof Error ? error.message : JSON.stringify(error)}`)}} else {- // Normal mode: use selected provider- const modelId = useModelProvider.getState().selectedModel?.id- const providerId = useModelProvider.getState().selectedProvider- effectiveProviderName = providerId- const provider = useModelProvider.getState().getProviderByName(providerId)- if (this.serviceHub && modelId && provider) {- try {- const updatedProvider = useModelProvider- .getState()- .getProviderByName(providerId)-- // Get assistant parameters from current assistant- const currentAssistant = useAssistant.getState().currentAssistant- const inferenceParams = currentAssistant?.parameters-- // Create the model using the factory- // For llamacpp provider, startModel is called internally in ModelFactory.createLlamaCppModel- this.model = await ModelFactory.createModel(- modelId,- updatedProvider ?? provider,- inferenceParams ?? {}- )- } catch (error) {- console.error('Failed to create model:', error)- throw new Error(- `Failed to create model: ${error instanceof Error ? error.message : JSON.stringify(error)}`- )- }- } else {- throw new Error('ServiceHub not initialized or model/provider missing.')- }+ throw new Error('ServiceHub not initialized or model/provider missing.')}// Fix for Anthropic serial tool-use (error 400): when an assistant message@@ -358,7 +311,7 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {// tool_use / tool_result pairing that the Claude API requires.// See: https://platform.claude.com/docs/en/agents-and-tools/tool-use/implement-tool-use#parallel-tool-useconst messagesToConvert = (() => {- if (isAgentMode || effectiveProviderName !== 'anthropic') {+ if (effectiveProviderName !== 'anthropic') {return options.messages}return options.messages.flatMap((message) => {@@ -415,11 +368,10 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {: baseMessages// Include tools only if we have tools loaded AND model supports them- // In agent mode, OpenClaw manages its own toolsconst hasTools = Object.keys(this.tools).length > 0const selectedModel = useModelProvider.getState().selectedModelconst modelSupportsTools = selectedModel?.capabilities?.includes('tools') ?? this.modelSupportsTools- const shouldEnableTools = !isAgentMode && hasTools && modelSupportsTools+ const shouldEnableTools = hasTools && modelSupportsTools// Track stream timing and token count for token speed calculationlet streamStartTime: number | undefined@@ -499,40 +451,6 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {? error.message: JSON.stringify(error)- if (isAgentMode) {- const lower = errorMessage.toLowerCase()-- if (- lower.includes('connection refused') ||- lower.includes('econnrefused') ||- lower.includes('failed to fetch') ||- lower.includes('network error') ||- lower.includes('connect error')- ) {- return `Cannot connect to the local server. Please check that the API server is running.\n\nOriginal error: ${errorMessage}`- }-- if (- lower.includes('model not found') ||- lower.includes('model_not_found') ||- lower.includes('no model loaded') ||- lower.includes('no running session') ||- lower.includes('no slot available')- ) {- return `No model is currently loaded. Please start a model first in the model settings.\n\nOriginal error: ${errorMessage}`- }-- if (- (lower.includes('context') && (lower.includes('size') || lower.includes('length') || lower.includes('limit') || lower.includes('exceed'))) ||- lower.includes('prompt is too long') ||- lower.includes('maximum context') ||- lower.includes('token limit') ||- lower.includes('too many tokens')- ) {- return `The prompt exceeds the model's context size. Try increasing the context size in model settings or using a shorter prompt.\n\nOriginal error: ${errorMessage}`- }- }-return errorMessage},onFinish: ({ responseMessage }) => {@@ -556,35 +474,7 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {? prependTextDeltaToUIStream(uiStream, continueContent): uiStream- // In agent mode, detect empty responses (HTTP 200 but no text content)- // and inject an error chunk so the UI shows a message instead of an empty bubble.- if (!isAgentMode) return finalStream-- let hasTextContent = false- let hasError = false- return finalStream.pipeThrough(- new TransformStream<UIMessageChunk, UIMessageChunk>({- transform(chunk, controller) {- if ((chunk as { type: string }).type === 'text-delta') {- hasTextContent = true- }- if ((chunk as { type: string }).type === 'error') {- hasError = true- }- controller.enqueue(chunk)- },- flush(controller) {- if (!hasTextContent && !hasError) {- controller.enqueue({- type: 'error',- errorText:- 'The agent returned an empty response. This usually means ' +- 'the local model server is not running or the model failed to process the request.',- } as UIMessageChunk)- }- },- })- )+ return finalStream}async reconnectToStream(diff --git a/web-app/src/lib/model-factory.ts b/web-app/src/lib/model-factory.tsindex 57705fc72..7a03ce356 100644--- a/web-app/src/lib/model-factory.ts+++ b/web-app/src/lib/model-factory.ts@@ -188,9 +188,6 @@ export class ModelFactory {case 'xai':return this.createXaiModel(modelId, provider)- case 'openclaw':- return this.createOpenAICompatibleModel(modelId, provider)-default:return this.createOpenAICompatibleModel(modelId, provider, parameters)}diff --git a/web-app/src/locales/cs/common.json b/web-app/src/locales/cs/common.jsonindex 9bcf5016c..347c10cb3 100644--- a/web-app/src/locales/cs/common.json+++ b/web-app/src/locales/cs/common.json@@ -18,7 +18,6 @@"newChat": "Nový chat","newAgentChat": "Nový chat agenta","chats": "Chaty",- "openclawAgent": "OpenClaw Agent","favorites": "Oblíbené","recents": "Nedávné","hub": "Centrum",diff --git a/web-app/src/locales/cs/settings.json b/web-app/src/locales/cs/settings.jsonindex f4fb8761c..8a289b04f 100644--- a/web-app/src/locales/cs/settings.json+++ b/web-app/src/locales/cs/settings.json@@ -102,10 +102,8 @@"threadScrollDesc": "Vyberte, jak má viewport chatu reagovat při příchodu nových zpráv.","threadScrollFlowTitle": "Plynulé rolování","threadScrollFlowHint": "Ukotvuje viewport k poslední zprávě, kterou odešlete.",-"threadScrollStickyTitle": "Lepkavé rolování","threadScrollStickyHint": "Automaticky sleduje příchozí odpovědi v reálném čase.",-"tokenCounterCompact": "Kompaktní počítadlo tokenů","tokenCounterCompactDesc": "Zobrazit počítadlo tokenů uvnitř chatového vstupu. Pokud je zakázáno, počítadlo tokenů se zobrazí pod vstupem.","codeBlockTitle": "Blok kódu",@@ -306,175 +304,5 @@"updateError": "Nepodařilo se aktualizovat Llamacpp"},"backendInstallSuccess": "Backend úspěšně nainstalován",- "backendInstallError": "Nepodařilo se nainstalovat backend",- "remoteAccess": {- "title": "Vzdálený přístup",- "running": "Vzdálený přístup je nyní spuštěn",- "stopped": "Vzdálený přístup byl zastaven",- "urlCopied": "Odkaz zkopírován do schránky",- "port": "Port",- "runtimeVersion": "Verze runtime",- "openclawVersion": "Verze OpenClaw",- "openclawIntegration": "Integrace OpenClaw",- "enableRemoteAccess": "Povolit OpenClaw",- "disableRemoteAccess": "Zakázat OpenClaw",- "settings": "Nastavení",- "install": "Nainstalovat",- "start": "Spustit",- "stop": "Zastavit",- "startError": "Nepodařilo se spustit vzdálený přístup. Zkuste to prosím znovu.",- "stopError": "Nepodařilo se zastavit vzdálený přístup. Zkuste to prosím znovu.",- "nodeRequired": "Je vyžadován Node.js 22+. Nainstalujte jej nejprve.",- "portInUse": "Port 18789 je používán. Zavřete ostatní aplikace, které jej používají.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Kanály",- "runtimeMode": "Režim běhu",- "dockerSandbox": "Docker kontejner",- "directProcess": "Přímý proces",- "securityAdvisory": "OpenClaw běží bez izolace sandboxu. Pro lepší bezpečnost nainstalujte a otevřete Docker Desktop, poté restartujte OpenClaw pro spuštění v kontejneru.",- "logViewer": "Logy pískoviště",- "noLogs": "Žádné logy",- "copyLogs": "Kopírovat vše",- "downloadLogs": "Stáhnout",- "restartSandbox": "Restartovat pískoviště",- "restarting": "Restartuji pískoviště...",- "localNetworkOnly": "Pouze místní síť",- "notConfigured": "Není nakonfigurováno",- "publicAccess": "Veřejný přístup",- "tunnelUrl": "URL tunelu",- "copyUrl": "Kopírovat URL",- "openUrl": "Otevřít URL",- "activeTunnel": "Aktivní tunel",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Upravte Soul.md, User.md a další konfigurační soubory",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Otevřete webový dashboard",- "addChannel": {- "title": "Přidat kanál",- "description": "Vyberte messaging platformu k připojení",- "cancel": "Zrušit",- "continue": "Pokračovat"- },- "channelDescriptions": {- "telegram": "Připojit přes Telegram bot pro bezpečné zasílání zpráv",- "whatsapp": "Připojit přes WhatsApp pro business zasílání zpráv"- },- "connected": "Připojeno",- "notConnected": "Není připojeno",- "manage": "Spravovat",- "disconnect": "Odpojit",- "channelDisconnected": "{{channel}} odpojen",- "disconnectError": "Nepodařilo se odpojit. Zkuste to prosím znovu.",- "channelNotConnected": "Kliknutím na nastavení připojíte {{channel}}",- "copiedToClipboard": "Zkopírováno do schránky",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve povolen",- "serveDisabled": "Tailscale Serve zakázán",- "funnelEnabled": "Tailscale Funnel povolen - Váš koncový bod je nyní veřejně přístupný",- "funnelDisabled": "Tailscale Funnel zakázán",- "serveError": "Nepodařilo se nakonfigurovat Tailscale Serve",- "funnelError": "Nepodařilo se nakonfigurovat Tailscale Funnel",- "urlCopied": "URL zkopírována do schránky"- },- "telegramWizard": {- "title": "Připojit Telegram",- "description": "Nastavte Telegram pro vzdálený chat s Jan",- "step1": {- "title": "Vytvořit bota",- "instruction1": "Otevřete Telegram a vyhledejte @BotFather",- "instruction2": "Odešlete /newbot pro vytvoření nového bota",- "instruction3": "Postupujte podle pokynů a pojmenujte bota",- "instruction4": "Zkopírujte token bota (vypadá jako: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Zadejte token",- "placeholder": "Vložte token bota sem",- "validate": "Ověřit token",- "validating": "Ověřování...",- "invalidToken": "Neplatný token. Zkontrolujte a zkuste znovu.",- "validToken": "Token ověřen! Bot: @{{username}}"- },- "step3": {- "title": "Konfigurovat a spustit",- "connecting": "Konfigurace Telegram kanálu...",- "success": "Telegram kanál úspěšně nakonfigurován!",- "error": "Nepodařilo se nakonfigurovat Telegram: {{error}}"- },- "step4": {- "title": "Spárovat zařízení",- "instruction": "Otevřete bota na Telegramu a odešlete zprávu. Bot odpoví párovacím kódem — vložte jej níže pro připojení.",- "openBot": "Otevřít @{{username}} na Telegramu",- "instruction1": "Otevřete bota na Telegramu pomocí odkazu výše",- "instruction2": "Stiskněte \"Start\" nebo odešlete jakoukoli zprávu botovi",- "instruction3": "Zkopírujte párovací kód z odpovědi bota a vložte jej níže",- "codeLabel": "Párovací kód",- "codePlaceholder": "např. ZNAV9KZ3",- "approve": "Schválit a připojit",- "approving": "Schvalování...",- "approved": "Zařízení úspěšně spárováno!",- "approveError": "Nepodařilo se schválit párování: {{error}}",- "codeRequired": "Zadejte prosím párovací kód ze zprávy bota",- "notConnected": "Kanál ještě není připojen. Ujistěte se, že brána OpenClaw běží.",- "skipForNow": "Přeskočit prozatím",- "resetPairing": "Nemáte kód? Klikněte pro reset a znovu odešlete /start",- "resetSuccess": "Párovací kódy vymazány — odešlete /start botovi znovu",- "resetError": "Nepodařilo se resetovat párovací kódy"- },- "step5": {- "title": "Připojeno!",- "success": "Telegram je nyní připojen!",- "instruction": "Nyní můžete chatovat s Jan odesíláním zpráv botovi.",- "botUsername": "Váš bot: @{{username}}",- "pairedUsers": "{{count}} spárovaných zařízení"- },- "buttons": {- "next": "Další",- "back": "Zpět",- "connect": "Připojit",- "cancel": "Zrušit",- "done": "Hotovo",- "retry": "Opakovat",- "disconnect": "Odpojit"- },- "status": {- "notConnected": "Není připojeno",- "connected": "Připojeno",- "connecting": "Připojování..."- },- "errors": {- "networkError": "Chyba sítě. Zkontrolujte připojení.",- "tokenRequired": "Zadejte prosím token bota",- "configError": "Nepodařilo se uložit konfiguraci"- }- },- "whatsappWizard": {- "setupTitle": "Nastavení WhatsApp",- "setupDescription": "Připojte svůj účet WhatsApp pro vzdálené zasílání zpráv",- "howItWorks": "Jak to funguje",- "whatsappStep1": "Klikněte na \"Zahájit nastavení\" — vše nakonfigurujeme automaticky",- "whatsappStep2": "Naskenujte QR kód aplikací WhatsApp",- "whatsappStep3": "Začněte chatovat s Jan z telefonu!",- "settingUp": "Nastavování...",- "settingUpDescription": "Konfigurace OpenClaw a příprava připojení WhatsApp. Může to chvíli trvat...",- "checkingOpenClaw": "Kontrola instalace OpenClaw",- "configuringGateway": "Konfigurace připojení brány",- "enablingWhatsApp": "Povolování kanálu WhatsApp",- "scanQrCode": "Naskenujte QR kód",- "qrCodeInstructions": "Otevřete WhatsApp na telefonu a naskenujte tento QR kód",- "generatingQrCode": "Generování QR kódu...",- "waitingForScan": "Čekání na sken...",- "verifyingConnection": "Ověřování připojení",- "pleaseWait": "Počkejte prosím, ověřujeme vaše připojení",- "whatsappConnected": "WhatsApp připojen!",- "whatsappConnectedDescription": "Váš WhatsApp je nyní připojen. Můžete chatovat s Jan odesíláním zpráv.",- "connectionFailed": "Připojení selhalo",- "unknownError": "Došlo k neznámé chybě",- "back": "Zpět",- "refreshQrCode": "Obnovit QR kód",- "tryAgain": "Zkusit znovu",- "startSetup": "Zahájit nastavení",- "connecting": "Připojování..."- }- }+ "backendInstallError": "Nepodařilo se nainstalovat backend"}diff --git a/web-app/src/locales/de-DE/common.json b/web-app/src/locales/de-DE/common.jsonindex 0e9113118..1e0ff2dd2 100644--- a/web-app/src/locales/de-DE/common.json+++ b/web-app/src/locales/de-DE/common.json@@ -18,7 +18,6 @@"newChat": "Neuer Chat","newAgentChat": "Neuer Agent-Chat","chats": "Chats",- "openclawAgent": "OpenClaw Agent","favorites": "Favoriten","recents": "Kürzlich","hub": "Hub",diff --git a/web-app/src/locales/de-DE/settings.json b/web-app/src/locales/de-DE/settings.jsonindex e26e6fce0..c16bfc89f 100644--- a/web-app/src/locales/de-DE/settings.json+++ b/web-app/src/locales/de-DE/settings.json@@ -274,175 +274,5 @@"updateError": "Fehler beim Aktualisieren von Llamacpp"},"backendInstallSuccess": "Backend erfolgreich installiert",- "backendInstallError": "Backend-Installation fehlgeschlagen",- "remoteAccess": {- "title": "Fernzugriff",- "running": "Fernzugriff läuft",- "stopped": "Fernzugriff wurde gestoppt",- "urlCopied": "Link in die Zwischenablage kopiert",- "port": "Port",- "runtimeVersion": "Runtime-Version",- "openclawVersion": "OpenClaw-Version",- "openclawIntegration": "OpenClaw-Integration",- "enableRemoteAccess": "OpenClaw aktivieren",- "disableRemoteAccess": "OpenClaw deaktivieren",- "settings": "Einstellungen",- "install": "Installieren",- "start": "Starten",- "stop": "Stoppen",- "startError": "Fernzugriff konnte nicht gestartet werden. Bitte versuchen Sie es erneut.",- "stopError": "Fernzugriff konnte nicht gestoppt werden. Bitte versuchen Sie es erneut.",- "nodeRequired": "Node.js 22+ ist erforderlich. Bitte installieren Sie es zuerst.",- "portInUse": "Port 18789 wird bereits verwendet. Bitte schließen Sie andere Apps, die ihn verwenden.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Kanäle",- "runtimeMode": "Laufzeitmodus",- "dockerSandbox": "Docker-Container",- "directProcess": "Direkter Prozess",- "securityAdvisory": "OpenClaw läuft ohne Sandbox-Isolation. Für bessere Sicherheit installieren und öffnen Sie Docker Desktop, dann starten Sie OpenClaw neu, um es in einem Container auszuführen.",- "logViewer": "Sandbox-Logs",- "noLogs": "Keine Logs verfügbar",- "copyLogs": "Alle kopieren",- "downloadLogs": "Herunterladen",- "restartSandbox": "Sandbox neu starten",- "restarting": "Sandbox wird neu gestartet...",- "localNetworkOnly": "Nur lokales Netzwerk",- "notConfigured": "Nicht konfiguriert",- "publicAccess": "Öffentlicher Zugriff",- "tunnelUrl": "Tunnel-URL",- "copyUrl": "URL kopieren",- "openUrl": "URL öffnen",- "activeTunnel": "Aktiver Tunnel",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Soul.md, User.md und andere Konfigurationsdateien bearbeiten",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Das Web-Dashboard öffnen",- "addChannel": {- "title": "Kanal hinzufügen",- "description": "Wählen Sie eine Messaging-Plattform zum Verbinden",- "cancel": "Abbrechen",- "continue": "Weiter"- },- "channelDescriptions": {- "telegram": "Verbindung über Telegram-Bot für sichere Nachrichten",- "whatsapp": "Verbindung über WhatsApp für geschäftliche Nachrichten"- },- "connected": "Verbunden",- "notConnected": "Nicht verbunden",- "manage": "Verwalten",- "disconnect": "Trennen",- "channelDisconnected": "{{channel}} getrennt",- "disconnectError": "Trennung fehlgeschlagen. Bitte versuchen Sie es erneut.",- "channelNotConnected": "Klicken Sie auf Einstellungen, um {{channel}} zu verbinden",- "copiedToClipboard": "In die Zwischenablage kopiert",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve aktiviert",- "serveDisabled": "Tailscale Serve deaktiviert",- "funnelEnabled": "Tailscale Funnel aktiviert - Ihr Endpunkt ist jetzt öffentlich zugänglich",- "funnelDisabled": "Tailscale Funnel deaktiviert",- "serveError": "Tailscale Serve konnte nicht konfiguriert werden",- "funnelError": "Tailscale Funnel konnte nicht konfiguriert werden",- "urlCopied": "URL in die Zwischenablage kopiert"- },- "telegramWizard": {- "title": "Telegram verbinden",- "description": "Telegram einrichten, um remote mit Jan zu chatten",- "step1": {- "title": "Bot erstellen",- "instruction1": "Öffnen Sie Telegram und suchen Sie nach @BotFather",- "instruction2": "Senden Sie /newbot, um einen neuen Bot zu erstellen",- "instruction3": "Folgen Sie den Anweisungen, um Ihren Bot zu benennen",- "instruction4": "Kopieren Sie das Bot-Token (sieht aus wie: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Token eingeben",- "placeholder": "Bot-Token hier einfügen",- "validate": "Token validieren",- "validating": "Wird validiert...",- "invalidToken": "Ungültiges Token. Bitte überprüfen und erneut versuchen.",- "validToken": "Token validiert! Bot: @{{username}}"- },- "step3": {- "title": "Konfigurieren & Starten",- "connecting": "Telegram-Kanal wird konfiguriert...",- "success": "Telegram-Kanal erfolgreich konfiguriert!",- "error": "Telegram-Konfiguration fehlgeschlagen: {{error}}"- },- "step4": {- "title": "Gerät koppeln",- "instruction": "Öffnen Sie Ihren Bot auf Telegram und senden Sie eine Nachricht. Der Bot antwortet mit einem Kopplungscode — fügen Sie ihn unten ein, um sich zu verbinden.",- "openBot": "@{{username}} auf Telegram öffnen",- "instruction1": "Öffnen Sie Ihren Bot auf Telegram über den Link oben",- "instruction2": "Drücken Sie \"Start\" oder senden Sie eine beliebige Nachricht an den Bot",- "instruction3": "Kopieren Sie den Kopplungscode aus der Antwort des Bots und fügen Sie ihn unten ein",- "codeLabel": "Kopplungscode",- "codePlaceholder": "z.B. ZNAV9KZ3",- "approve": "Genehmigen & Verbinden",- "approving": "Wird genehmigt...",- "approved": "Gerät erfolgreich gekoppelt!",- "approveError": "Kopplung fehlgeschlagen: {{error}}",- "codeRequired": "Bitte geben Sie den Kopplungscode aus der Bot-Nachricht ein",- "notConnected": "Kanal noch nicht verbunden. Stellen Sie sicher, dass das OpenClaw-Gateway läuft.",- "skipForNow": "Vorerst überspringen",- "resetPairing": "Kein Code? Klicken Sie zum Zurücksetzen & versuchen Sie /start erneut",- "resetSuccess": "Kopplungscodes gelöscht — senden Sie /start erneut an Ihren Bot",- "resetError": "Kopplungscodes konnten nicht zurückgesetzt werden"- },- "step5": {- "title": "Verbunden!",- "success": "Telegram ist jetzt verbunden!",- "instruction": "Sie können jetzt mit Jan chatten, indem Sie Nachrichten an Ihren Bot senden.",- "botUsername": "Ihr Bot: @{{username}}",- "pairedUsers": "{{count}} Gerät(e) gekoppelt"- },- "buttons": {- "next": "Weiter",- "back": "Zurück",- "connect": "Verbinden",- "cancel": "Abbrechen",- "done": "Fertig",- "retry": "Erneut versuchen",- "disconnect": "Trennen"- },- "status": {- "notConnected": "Nicht verbunden",- "connected": "Verbunden",- "connecting": "Verbindung wird hergestellt..."- },- "errors": {- "networkError": "Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",- "tokenRequired": "Bitte geben Sie ein Bot-Token ein",- "configError": "Konfiguration konnte nicht gespeichert werden"- }- },- "whatsappWizard": {- "setupTitle": "WhatsApp-Einrichtung",- "setupDescription": "Verbinden Sie Ihr WhatsApp-Konto, um Remote-Nachrichten zu aktivieren",- "howItWorks": "So funktioniert es",- "whatsappStep1": "Klicken Sie auf \"Einrichtung starten\" — wir konfigurieren alles automatisch",- "whatsappStep2": "Scannen Sie den QR-Code mit Ihrer WhatsApp-App",- "whatsappStep3": "Beginnen Sie, von Ihrem Telefon aus mit Jan zu chatten!",- "settingUp": "Wird eingerichtet...",- "settingUpDescription": "OpenClaw wird konfiguriert und die WhatsApp-Verbindung vorbereitet. Dies kann einen Moment dauern...",- "checkingOpenClaw": "OpenClaw-Installation wird überprüft",- "configuringGateway": "Gateway-Verbindung wird konfiguriert",- "enablingWhatsApp": "WhatsApp-Kanal wird aktiviert",- "scanQrCode": "QR-Code scannen",- "qrCodeInstructions": "Öffnen Sie WhatsApp auf Ihrem Telefon und scannen Sie diesen QR-Code",- "generatingQrCode": "QR-Code wird generiert...",- "waitingForScan": "Warten auf Scan...",- "verifyingConnection": "Verbindung wird überprüft",- "pleaseWait": "Bitte warten Sie, während wir Ihre Verbindung überprüfen",- "whatsappConnected": "WhatsApp verbunden!",- "whatsappConnectedDescription": "Ihr WhatsApp ist jetzt verbunden. Sie können mit Jan chatten, indem Sie Nachrichten senden.",- "connectionFailed": "Verbindung fehlgeschlagen",- "unknownError": "Ein unbekannter Fehler ist aufgetreten",- "back": "Zurück",- "refreshQrCode": "QR-Code aktualisieren",- "tryAgain": "Erneut versuchen",- "startSetup": "Einrichtung starten",- "connecting": "Verbindung wird hergestellt..."- }- }+ "backendInstallError": "Backend-Installation fehlgeschlagen"}diff --git a/web-app/src/locales/en/common.json b/web-app/src/locales/en/common.jsonindex c055e0c30..82c1fc0ae 100644--- a/web-app/src/locales/en/common.json+++ b/web-app/src/locales/en/common.json@@ -5,7 +5,6 @@"local_api_server": "Local API Server","remote_access": "Remote Access","integrations": "Integrations",- "openclaw": "OpenClaw","experimental": "Experimental","claude_code": "Claude Code","https_proxy": "HTTPS Proxy",@@ -24,7 +23,6 @@"newChat": "New Chat","newAgentChat": "New Agent Chat","chats": "Chats",- "openclawAgent": "OpenClaw Agent","favorites": "Favorites","recents": "Recents","hub": "Hub",diff --git a/web-app/src/locales/en/settings.json b/web-app/src/locales/en/settings.jsonindex 2c75aeed5..523cae89b 100644--- a/web-app/src/locales/en/settings.json+++ b/web-app/src/locales/en/settings.json@@ -106,10 +106,8 @@"threadScrollDesc": "Choose how the chat viewport should react when new messages arrive.","threadScrollFlowTitle": "Flow scroll","threadScrollFlowHint": "Keeps the viewport anchored to the latest message you send.",-"threadScrollStickyTitle": "Sticky scroll","threadScrollStickyHint": "Automatically follows along as replies stream in real time.",-"tokenCounterCompact": "Compact Token Counter","tokenCounterCompactDesc": "Show token counter inside chat input. When disabled, token counter appears below the input.","codeBlockTitle": "Code Block",@@ -320,179 +318,6 @@"updateSuccess": "Llamacpp updated successfully","updateError": "Failed to update Llamacpp"},- "backendInstallSuccess": "OpenClaw installed successfully!",- "backendInstallError": "Failed to install backend",- "remoteAccess": {- "title": "Remote Access",- "running": "Remote Access is now running",- "stopped": "Remote Access has been stopped",- "urlCopied": "Link copied to clipboard",- "port": "Port",- "runtimeVersion": "Runtime Version",- "openclawVersion": "OpenClaw Version",- "openclawIntegration": "OpenClaw Integration",- "enableRemoteAccess": "Enable OpenClaw",- "disableRemoteAccess": "Disable OpenClaw",- "settings": "Settings",- "install": "Install",- "start": "Start",- "noLocalModelAvailable": "A local model is required to enable OpenClaw. Download a model first.",- "noModelAvailable": "A model is required to enable OpenClaw. Download a local model or configure a remote provider with an API key.",- "nodejsPrerequisite": "Node.js (v22 or later) is required to run OpenClaw. Please ensure it is installed before enabling.",- "stop": "Stop",- "startError": "Couldn't start Remote Access. Please try again.",- "stopError": "Couldn't stop Remote Access. Please try again.",- "nodeRequired": "Node.js 22+ is required. Please install it first.",- "portInUse": "Port 18789 is in use. Please close other apps using it.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Channels",- "runtimeMode": "Runtime Mode",- "dockerSandbox": "Docker Container",- "directProcess": "Direct Process",- "securityAdvisory": "OpenClaw is running without sandbox isolation. For better security, install and open Docker Desktop, then restart OpenClaw to run it in a container.",- "logViewer": "Sandbox Logs",- "noLogs": "No logs available",- "copyLogs": "Copy All",- "downloadLogs": "Download",- "restartSandbox": "Restart Sandbox",- "restarting": "Restarting sandbox...",- "localNetworkOnly": "Local Network Only",- "notConfigured": "Not Configured",- "publicAccess": "Public Access",- "tunnelUrl": "Tunnel URL",- "copyUrl": "Copy URL",- "openUrl": "Open URL",- "activeTunnel": "Active Tunnel",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Open the folder to edit Soul.md, User.md and other config files",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Open the web dashboard",- "addChannel": {- "title": "Add Channel",- "description": "Select a messaging platform to connect",- "cancel": "Cancel",- "continue": "Continue"- },- "channelDescriptions": {- "telegram": "Connect via Telegram bot for secure messaging",- "whatsapp": "Connect via WhatsApp for business messaging"- },- "connected": "Connected",- "notConnected": "Not Connected",- "manage": "Manage",- "disconnect": "Disconnect",- "channelDisconnected": "{{channel}} disconnected",- "disconnectError": "Couldn't disconnect. Please try again.",- "channelNotConnected": "Click settings to connect {{channel}}",- "copiedToClipboard": "Copied to clipboard",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve enabled",- "serveDisabled": "Tailscale Serve disabled",- "funnelEnabled": "Tailscale Funnel enabled - Your endpoint is now publicly accessible",- "funnelDisabled": "Tailscale Funnel disabled",- "serveError": "Failed to configure Tailscale Serve",- "funnelError": "Failed to configure Tailscale Funnel",- "urlCopied": "URL copied to clipboard"- },- "telegramWizard": {- "title": "Connect Telegram",- "description": "Set up Telegram to chat with Jan remotely",- "step1": {- "title": "Create a Bot",- "instruction1": "Open Telegram and search for @BotFather",- "instruction2": "Send /newbot to create a new bot",- "instruction3": "Follow the prompts to name your bot",- "instruction4": "Copy the bot token (it looks like: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Enter Token",- "placeholder": "Paste your bot token here",- "validate": "Validate Token",- "validating": "Validating...",- "invalidToken": "Invalid token. Please check and try again.",- "validToken": "Token validated! Bot: @{{username}}"- },- "step3": {- "title": "Configure & Start",- "connecting": "Configuring Telegram channel...",- "success": "Telegram channel configured successfully!",- "error": "Failed to configure Telegram: {{error}}"- },- "step4": {- "title": "Pair Your Device",- "instruction": "Open your bot on Telegram and send a message. The bot will reply with a pairing code — paste it below to connect.",- "openBot": "Open @{{username}} on Telegram",- "instruction1": "Open your bot on Telegram using the link above",- "instruction2": "Press \"Start\" or send any message to the bot",- "instruction3": "Copy the pairing code from the bot's reply and paste it below",- "codeLabel": "Pairing Code",- "codePlaceholder": "e.g. ZNAV9KZ3",- "approve": "Approve & Connect",- "approving": "Approving...",- "approved": "Device paired successfully!",- "approveError": "Failed to approve pairing: {{error}}",- "codeRequired": "Please enter the pairing code from the bot's message",- "notConnected": "Channel not connected yet. Make sure the OpenClaw gateway is running.",- "skipForNow": "Skip for Now",- "resetPairing": "No code? Click to reset & try /start again",- "resetSuccess": "Pairing codes cleared — send /start to your bot again",- "resetError": "Failed to reset pairing codes"- },- "step5": {- "title": "Connected!",- "success": "Telegram is now connected!",- "instruction": "You can now chat with Jan by sending messages to your bot.",- "botUsername": "Your bot: @{{username}}",- "pairedUsers": "{{count}} device(s) paired"- },- "buttons": {- "next": "Next",- "back": "Back",- "connect": "Connect",- "cancel": "Cancel",- "done": "Done",- "retry": "Retry",- "disconnect": "Disconnect"- },- "status": {- "notConnected": "Not Connected",- "connected": "Connected",- "connecting": "Connecting..."- },- "errors": {- "networkError": "Network error. Please check your connection.",- "tokenRequired": "Please enter a bot token",- "configError": "Failed to save configuration"- }- },- "whatsappWizard": {- "setupTitle": "WhatsApp Setup",- "setupDescription": "Connect your WhatsApp account to enable remote messaging",- "howItWorks": "How it works",- "whatsappStep1": "Click 'Start Setup' - we'll configure everything automatically",- "whatsappStep2": "Scan the QR code with your WhatsApp app",- "whatsappStep3": "Start chatting with Jan from your phone!",- "settingUp": "Setting up...",- "settingUpDescription": "Configuring OpenClaw and preparing WhatsApp connection. This may take a moment...",- "checkingOpenClaw": "Checking OpenClaw installation",- "configuringGateway": "Configuring Gateway connection",- "enablingWhatsApp": "Enabling WhatsApp channel",- "scanQrCode": "Scan QR Code",- "qrCodeInstructions": "Open WhatsApp on your phone and scan this QR code",- "generatingQrCode": "Generating QR code...",- "waitingForScan": "Waiting for scan...",- "verifyingConnection": "Verifying Connection",- "pleaseWait": "Please wait while we verify your connection",- "whatsappConnected": "WhatsApp Connected!",- "whatsappConnectedDescription": "Your WhatsApp is now connected. You can chat with Jan by sending messages.",- "connectionFailed": "Connection Failed",- "unknownError": "An unknown error occurred",- "back": "Back",- "refreshQrCode": "Refresh QR Code",- "tryAgain": "Try Again",- "startSetup": "Start Setup",- "connecting": "Connecting..."- }- }+ "backendInstallSuccess": "Backend installed successfully!",+ "backendInstallError": "Failed to install backend"}diff --git a/web-app/src/locales/fr/common.json b/web-app/src/locales/fr/common.jsonindex 7b63f0b30..00e195280 100644--- a/web-app/src/locales/fr/common.json+++ b/web-app/src/locales/fr/common.json@@ -18,7 +18,6 @@"newChat": "Nouvelle discussion","newAgentChat": "Nouvelle discussion Agent","chats": "Discussions",- "openclawAgent": "OpenClaw Agent","favorites": "Favoris","recents": "Récents","hub": "Concentrateur Hub",diff --git a/web-app/src/locales/fr/settings.json b/web-app/src/locales/fr/settings.jsonindex 4fd899bf9..b4689638b 100644--- a/web-app/src/locales/fr/settings.json+++ b/web-app/src/locales/fr/settings.json@@ -312,175 +312,5 @@"updateError": "Échec de la mise à jour de Llamacpp"},"backendInstallSuccess": "Backend installé avec succès",- "backendInstallError": "Échec de l'installation du backend",- "remoteAccess": {- "title": "Accès à distance",- "running": "L'accès à distance est maintenant actif",- "stopped": "L'accès à distance a été arrêté",- "urlCopied": "Lien copié dans le presse-papiers",- "port": "Port",- "runtimeVersion": "Version du runtime",- "openclawVersion": "Version OpenClaw",- "openclawIntegration": "Intégration OpenClaw",- "enableRemoteAccess": "Activer OpenClaw",- "disableRemoteAccess": "Désactiver OpenClaw",- "settings": "Paramètres",- "install": "Installer",- "start": "Démarrer",- "stop": "Arrêter",- "startError": "Impossible de démarrer l'accès à distance. Veuillez réessayer.",- "stopError": "Impossible d'arrêter l'accès à distance. Veuillez réessayer.",- "nodeRequired": "Node.js 22+ est requis. Veuillez l'installer d'abord.",- "portInUse": "Le port 18789 est utilisé. Veuillez fermer les autres applications qui l'utilisent.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Canaux",- "runtimeMode": "Mode d'exécution",- "dockerSandbox": "Conteneur Docker",- "directProcess": "Processus direct",- "securityAdvisory": "OpenClaw s'exécute sans isolation sandbox. Pour une meilleure sécurité, installez et ouvrez Docker Desktop, puis redémarrez OpenClaw pour l'exécuter dans un conteneur.",- "logViewer": "Logs du bac à sable",- "noLogs": "Aucun log disponible",- "copyLogs": "Tout copier",- "downloadLogs": "Télécharger",- "restartSandbox": "Redémarrer le bac à sable",- "restarting": "Redémarrage du bac à sable...",- "localNetworkOnly": "Réseau local uniquement",- "notConfigured": "Non configuré",- "publicAccess": "Accès public",- "tunnelUrl": "URL du tunnel",- "copyUrl": "Copier l'URL",- "openUrl": "Ouvrir l'URL",- "activeTunnel": "Tunnel actif",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Modifier Soul.md, User.md et d'autres fichiers de configuration",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Ouvrir le tableau de bord web",- "addChannel": {- "title": "Ajouter un canal",- "description": "Sélectionnez une plateforme de messagerie à connecter",- "cancel": "Annuler",- "continue": "Continuer"- },- "channelDescriptions": {- "telegram": "Connecter via le bot Telegram pour la messagerie sécurisée",- "whatsapp": "Connecter via WhatsApp pour la messagerie professionnelle"- },- "connected": "Connecté",- "notConnected": "Non connecté",- "manage": "Gérer",- "disconnect": "Déconnecter",- "channelDisconnected": "{{channel}} déconnecté",- "disconnectError": "Impossible de déconnecter. Veuillez réessayer.",- "channelNotConnected": "Cliquez sur Paramètres pour connecter {{channel}}",- "copiedToClipboard": "Copié dans le presse-papiers",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve activé",- "serveDisabled": "Tailscale Serve désactivé",- "funnelEnabled": "Tailscale Funnel activé - Votre point de terminaison est maintenant accessible au public",- "funnelDisabled": "Tailscale Funnel désactivé",- "serveError": "Échec de la configuration de Tailscale Serve",- "funnelError": "Échec de la configuration de Tailscale Funnel",- "urlCopied": "URL copiée dans le presse-papiers"- },- "telegramWizard": {- "title": "Connecter Telegram",- "description": "Configurez Telegram pour discuter avec Jan à distance",- "step1": {- "title": "Créer un bot",- "instruction1": "Ouvrez Telegram et recherchez @BotFather",- "instruction2": "Envoyez /newbot pour créer un nouveau bot",- "instruction3": "Suivez les instructions pour nommer votre bot",- "instruction4": "Copiez le token du bot (il ressemble à : 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Entrer le token",- "placeholder": "Collez votre token de bot ici",- "validate": "Valider le token",- "validating": "Validation...",- "invalidToken": "Token invalide. Veuillez vérifier et réessayer.",- "validToken": "Token validé ! Bot : @{{username}}"- },- "step3": {- "title": "Configurer et démarrer",- "connecting": "Configuration du canal Telegram...",- "success": "Canal Telegram configuré avec succès !",- "error": "Échec de la configuration de Telegram : {{error}}"- },- "step4": {- "title": "Associer votre appareil",- "instruction": "Ouvrez votre bot sur Telegram et envoyez un message. Le bot répondra avec un code d'association — collez-le ci-dessous pour vous connecter.",- "openBot": "Ouvrir @{{username}} sur Telegram",- "instruction1": "Ouvrez votre bot sur Telegram en utilisant le lien ci-dessus",- "instruction2": "Appuyez sur « Démarrer » ou envoyez un message au bot",- "instruction3": "Copiez le code d'association de la réponse du bot et collez-le ci-dessous",- "codeLabel": "Code d'association",- "codePlaceholder": "ex. ZNAV9KZ3",- "approve": "Approuver et connecter",- "approving": "Approbation...",- "approved": "Appareil associé avec succès !",- "approveError": "Échec de l'approbation : {{error}}",- "codeRequired": "Veuillez entrer le code d'association du message du bot",- "notConnected": "Canal non encore connecté. Assurez-vous que la passerelle OpenClaw est en cours d'exécution.",- "skipForNow": "Passer pour l'instant",- "resetPairing": "Pas de code ? Cliquez pour réinitialiser et réessayer /start",- "resetSuccess": "Codes d'association effacés — envoyez /start à votre bot à nouveau",- "resetError": "Échec de la réinitialisation des codes d'association"- },- "step5": {- "title": "Connecté !",- "success": "Telegram est maintenant connecté !",- "instruction": "Vous pouvez maintenant discuter avec Jan en envoyant des messages à votre bot.",- "botUsername": "Votre bot : @{{username}}",- "pairedUsers": "{{count}} appareil(s) associé(s)"- },- "buttons": {- "next": "Suivant",- "back": "Retour",- "connect": "Connecter",- "cancel": "Annuler",- "done": "Terminé",- "retry": "Réessayer",- "disconnect": "Déconnecter"- },- "status": {- "notConnected": "Non connecté",- "connected": "Connecté",- "connecting": "Connexion..."- },- "errors": {- "networkError": "Erreur réseau. Veuillez vérifier votre connexion.",- "tokenRequired": "Veuillez entrer un token de bot",- "configError": "Échec de l'enregistrement de la configuration"- }- },- "whatsappWizard": {- "setupTitle": "Configuration WhatsApp",- "setupDescription": "Connectez votre compte WhatsApp pour activer la messagerie à distance",- "howItWorks": "Comment ça fonctionne",- "whatsappStep1": "Cliquez sur « Démarrer la configuration » — nous configurerons tout automatiquement",- "whatsappStep2": "Scannez le code QR avec votre application WhatsApp",- "whatsappStep3": "Commencez à discuter avec Jan depuis votre téléphone !",- "settingUp": "Configuration en cours...",- "settingUpDescription": "Configuration d'OpenClaw et préparation de la connexion WhatsApp. Cela peut prendre un moment...",- "checkingOpenClaw": "Vérification de l'installation d'OpenClaw",- "configuringGateway": "Configuration de la connexion passerelle",- "enablingWhatsApp": "Activation du canal WhatsApp",- "scanQrCode": "Scanner le code QR",- "qrCodeInstructions": "Ouvrez WhatsApp sur votre téléphone et scannez ce code QR",- "generatingQrCode": "Génération du code QR...",- "waitingForScan": "En attente du scan...",- "verifyingConnection": "Vérification de la connexion",- "pleaseWait": "Veuillez patienter pendant que nous vérifions votre connexion",- "whatsappConnected": "WhatsApp connecté !",- "whatsappConnectedDescription": "Votre WhatsApp est maintenant connecté. Vous pouvez discuter avec Jan en envoyant des messages.",- "connectionFailed": "Échec de la connexion",- "unknownError": "Une erreur inconnue s'est produite",- "back": "Retour",- "refreshQrCode": "Actualiser le code QR",- "tryAgain": "Réessayer",- "startSetup": "Démarrer la configuration",- "connecting": "Connexion..."- }- }+ "backendInstallError": "Échec de l'installation du backend"}diff --git a/web-app/src/locales/id/common.json b/web-app/src/locales/id/common.jsonindex ea9811deb..92f73c356 100644--- a/web-app/src/locales/id/common.json+++ b/web-app/src/locales/id/common.json@@ -18,7 +18,6 @@"newChat": "Obrolan Baru","newAgentChat": "Obrolan Agent Baru","chats": "Obrolan",- "openclawAgent": "OpenClaw Agent","favorites": "Favorit","recents": "Terbaru","hub": "Hub",diff --git a/web-app/src/locales/id/settings.json b/web-app/src/locales/id/settings.jsonindex ed0f7f431..3f02b3fed 100644--- a/web-app/src/locales/id/settings.json+++ b/web-app/src/locales/id/settings.json@@ -274,175 +274,5 @@"updateError": "Gagal memperbarui Llamacpp"},"backendInstallSuccess": "Backend berhasil diinstal",- "backendInstallError": "Gagal menginstal backend",- "remoteAccess": {- "title": "Akses Jarak Jauh",- "running": "Akses jarak jauh sekarang berjalan",- "stopped": "Akses jarak jauh telah dihentikan",- "urlCopied": "Link disalin ke clipboard",- "port": "Port",- "runtimeVersion": "Versi Runtime",- "openclawVersion": "Versi OpenClaw",- "openclawIntegration": "Integrasi OpenClaw",- "enableRemoteAccess": "Aktifkan OpenClaw",- "disableRemoteAccess": "Nonaktifkan OpenClaw",- "settings": "Pengaturan",- "install": "Pasang",- "start": "Mulai",- "stop": "Berhenti",- "startError": "Gagal memulai akses jarak jauh. Silakan coba lagi.",- "stopError": "Gagal menghentikan akses jarak jauh. Silakan coba lagi.",- "nodeRequired": "Node.js 22+ diperlukan. Silakan instal terlebih dahulu.",- "portInUse": "Port 18789 sedang digunakan. Tutup aplikasi lain yang menggunakannya.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Channel",- "runtimeMode": "Mode Berjalan",- "dockerSandbox": "Kontainer Docker",- "directProcess": "Proses Langsung",- "securityAdvisory": "OpenClaw berjalan tanpa isolasi sandbox. Untuk keamanan lebih baik, instal dan buka Docker Desktop, lalu mulai ulang OpenClaw untuk menjalankannya dalam kontainer.",- "logViewer": "Log Sandbox",- "noLogs": "Tidak ada log",- "copyLogs": "Salin Semua",- "downloadLogs": "Unduh",- "restartSandbox": "Mulai Ulang Sandbox",- "restarting": "Menyalakan ulang sandbox...",- "localNetworkOnly": "Hanya Jaringan Lokal",- "notConfigured": "Belum Dikonfigurasi",- "publicAccess": "Akses Publik",- "tunnelUrl": "URL Terowongan",- "copyUrl": "Salin URL",- "openUrl": "Buka URL",- "activeTunnel": "Terowongan Aktif",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Edit Soul.md, User.md dan file konfigurasi lainnya",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Buka dasbor web",- "addChannel": {- "title": "Tambah Channel",- "description": "Pilih platform pesan untuk disambungkan",- "cancel": "Batal",- "continue": "Lanjutkan"- },- "channelDescriptions": {- "telegram": "Sambungkan melalui bot Telegram untuk pesan aman",- "whatsapp": "Sambungkan melalui WhatsApp untuk pesan bisnis"- },- "connected": "Terhubung",- "notConnected": "Belum Terhubung",- "manage": "Kelola",- "disconnect": "Putuskan",- "channelDisconnected": "{{channel}} terputus",- "disconnectError": "Gagal memutuskan. Silakan coba lagi.",- "channelNotConnected": "Klik pengaturan untuk menyambungkan {{channel}}",- "copiedToClipboard": "Disalin ke clipboard",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve diaktifkan",- "serveDisabled": "Tailscale Serve dinonaktifkan",- "funnelEnabled": "Tailscale Funnel diaktifkan - Endpoint Anda sekarang dapat diakses publik",- "funnelDisabled": "Tailscale Funnel dinonaktifkan",- "serveError": "Gagal mengonfigurasi Tailscale Serve",- "funnelError": "Gagal mengonfigurasi Tailscale Funnel",- "urlCopied": "URL disalin ke clipboard"- },- "telegramWizard": {- "title": "Sambungkan Telegram",- "description": "Siapkan Telegram untuk mengobrol dengan Jan dari jarak jauh",- "step1": {- "title": "Buat Bot",- "instruction1": "Buka Telegram dan cari @BotFather",- "instruction2": "Kirim /newbot untuk membuat bot baru",- "instruction3": "Ikuti petunjuk untuk memberi nama bot Anda",- "instruction4": "Salin token bot (tampak seperti: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Masukkan Token",- "placeholder": "Tempel token bot Anda di sini",- "validate": "Validasi Token",- "validating": "Memvalidasi...",- "invalidToken": "Token tidak valid. Silakan periksa dan coba lagi.",- "validToken": "Token tervalidasi! Bot: @{{username}}"- },- "step3": {- "title": "Konfigurasi & Mulai",- "connecting": "Mengonfigurasi channel Telegram...",- "success": "Channel Telegram berhasil dikonfigurasi!",- "error": "Gagal mengonfigurasi Telegram: {{error}}"- },- "step4": {- "title": "Pasangkan Perangkat",- "instruction": "Buka bot Anda di Telegram dan kirim pesan. Bot akan membalas dengan kode pairing — tempel di bawah untuk terhubung.",- "openBot": "Buka @{{username}} di Telegram",- "instruction1": "Buka bot Anda di Telegram menggunakan tautan di atas",- "instruction2": "Tekan \"Start\" atau kirim pesan apa pun ke bot",- "instruction3": "Salin kode pairing dari balasan bot dan tempel di bawah",- "codeLabel": "Kode Pairing",- "codePlaceholder": "cth. ZNAV9KZ3",- "approve": "Setujui & Sambungkan",- "approving": "Menyetujui...",- "approved": "Perangkat berhasil dipasangkan!",- "approveError": "Gagal menyetujui pairing: {{error}}",- "codeRequired": "Masukkan kode pairing dari pesan bot",- "notConnected": "Channel belum terhubung. Pastikan gateway OpenClaw berjalan.",- "skipForNow": "Lewati Dulu",- "resetPairing": "Tidak ada kode? Klik untuk reset & kirim /start lagi",- "resetSuccess": "Kode pairing dihapus — kirim /start ke bot Anda lagi",- "resetError": "Gagal mereset kode pairing"- },- "step5": {- "title": "Terhubung!",- "success": "Telegram sekarang terhubung!",- "instruction": "Anda sekarang dapat mengobrol dengan Jan dengan mengirim pesan ke bot Anda.",- "botUsername": "Bot Anda: @{{username}}",- "pairedUsers": "{{count}} perangkat dipasangkan"- },- "buttons": {- "next": "Selanjutnya",- "back": "Kembali",- "connect": "Sambungkan",- "cancel": "Batal",- "done": "Selesai",- "retry": "Coba Lagi",- "disconnect": "Putuskan"- },- "status": {- "notConnected": "Belum Terhubung",- "connected": "Terhubung",- "connecting": "Menyambungkan..."- },- "errors": {- "networkError": "Kesalahan jaringan. Periksa koneksi Anda.",- "tokenRequired": "Masukkan token bot",- "configError": "Gagal menyimpan konfigurasi"- }- },- "whatsappWizard": {- "setupTitle": "Pengaturan WhatsApp",- "setupDescription": "Sambungkan akun WhatsApp Anda untuk mengaktifkan pesan jarak jauh",- "howItWorks": "Cara kerjanya",- "whatsappStep1": "Klik 'Mulai Pengaturan' — kami akan mengonfigurasi semuanya secara otomatis",- "whatsappStep2": "Pindai kode QR dengan aplikasi WhatsApp Anda",- "whatsappStep3": "Mulai mengobrol dengan Jan dari ponsel Anda!",- "settingUp": "Menyiapkan...",- "settingUpDescription": "Mengonfigurasi OpenClaw dan mempersiapkan koneksi WhatsApp. Ini mungkin memerlukan waktu...",- "checkingOpenClaw": "Memeriksa instalasi OpenClaw",- "configuringGateway": "Mengonfigurasi koneksi Gateway",- "enablingWhatsApp": "Mengaktifkan channel WhatsApp",- "scanQrCode": "Pindai Kode QR",- "qrCodeInstructions": "Buka WhatsApp di ponsel Anda dan pindai kode QR ini",- "generatingQrCode": "Menghasilkan kode QR...",- "waitingForScan": "Menunggu pemindaian...",- "verifyingConnection": "Memverifikasi Koneksi",- "pleaseWait": "Silakan tunggu sementara kami memverifikasi koneksi Anda",- "whatsappConnected": "WhatsApp Terhubung!",- "whatsappConnectedDescription": "WhatsApp Anda sekarang terhubung. Anda dapat mengobrol dengan Jan dengan mengirim pesan.",- "connectionFailed": "Koneksi Gagal",- "unknownError": "Terjadi kesalahan yang tidak diketahui",- "back": "Kembali",- "refreshQrCode": "Segarkan Kode QR",- "tryAgain": "Coba Lagi",- "startSetup": "Mulai Pengaturan",- "connecting": "Menyambungkan..."- }- }+ "backendInstallError": "Gagal menginstal backend"}diff --git a/web-app/src/locales/ja/common.json b/web-app/src/locales/ja/common.jsonindex d8d1e5b0e..ae43d814f 100644--- a/web-app/src/locales/ja/common.json+++ b/web-app/src/locales/ja/common.json@@ -18,7 +18,6 @@"newChat": "新しいチャット","newAgentChat": "新しいエージェントチャット","chats": "チャット",- "openclawAgent": "OpenClaw エージェント","favorites": "お気に入り","recents": "最近の項目","hub": "ハブ",diff --git a/web-app/src/locales/ja/settings.json b/web-app/src/locales/ja/settings.jsonindex 971d63c5e..83d85ed48 100644--- a/web-app/src/locales/ja/settings.json+++ b/web-app/src/locales/ja/settings.json@@ -271,175 +271,5 @@"updateError": "Llamacppの更新に失敗しました"},"backendInstallSuccess": "バックエンドは正常にインストールされました",- "backendInstallError": "バックエンドのインストールに失敗しました",- "remoteAccess": {- "title": "リモートアクセス",- "running": "リモートアクセスが実行中です",- "stopped": "リモートアクセスが停止しました",- "urlCopied": "リンクがクリップボードにコピーされました",- "port": "ポート",- "runtimeVersion": "ランタイムバージョン",- "openclawVersion": "OpenClaw バージョン",- "openclawIntegration": "OpenClaw 連携",- "enableRemoteAccess": "OpenClawを有効にする",- "disableRemoteAccess": "OpenClawを無効にする",- "settings": "設定",- "install": "インストール",- "start": "開始",- "stop": "停止",- "startError": "リモートアクセスを開始できませんでした。もう一度お試しください。",- "stopError": "リモートアクセスを停止できませんでした。もう一度お試しください。",- "nodeRequired": "Node.js 22以上が必要です。先にインストールしてください。",- "portInUse": "ポート18789が使用中です。使用中の他のアプリを閉じてください。",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "チャンネル",- "runtimeMode": "実行モード",- "dockerSandbox": "Docker コンテナ",- "directProcess": "ダイレクトプロセス",- "securityAdvisory": "OpenClawはサンドボックス隔離なしで実行されています。より安全な環境にするには、Docker Desktopをインストールして開き、OpenClawを再起動してコンテナで実行してください。",- "logViewer": "サンドボックスログ",- "noLogs": "ログがありません",- "copyLogs": "すべてコピー",- "downloadLogs": "ダウンロード",- "restartSandbox": "サンドボックスを再起動",- "restarting": "サンドボックスを再起動中...",- "localNetworkOnly": "ローカルのみ",- "notConfigured": "未設定",- "publicAccess": "パブリックアクセス",- "tunnelUrl": "トンネルURL",- "copyUrl": "URLをコピー",- "openUrl": "URLを開く",- "activeTunnel": "アクティブトンネル",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Soul.md、User.md などの設定ファイルを編集する",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "ウェブダッシュボードを開く",- "addChannel": {- "title": "チャンネルを追加",- "description": "接続するメッセージングプラットフォームを選択",- "cancel": "キャンセル",- "continue": "続ける"- },- "channelDescriptions": {- "telegram": "安全なメッセージングのためにTelegramボットで接続",- "whatsapp": "ビジネスメッセージングのためにWhatsAppで接続"- },- "connected": "接続済み",- "notConnected": "未接続",- "manage": "管理",- "disconnect": "切断",- "channelDisconnected": "{{channel}}が切断されました",- "disconnectError": "切断できませんでした。もう一度お試しください。",- "channelNotConnected": "設定をクリックして{{channel}}を接続",- "copiedToClipboard": "クリップボードにコピーしました",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serveが有効になりました",- "serveDisabled": "Tailscale Serveが無効になりました",- "funnelEnabled": "Tailscale Funnelが有効になりました - エンドポイントに公開アクセス可能",- "funnelDisabled": "Tailscale Funnelが無効になりました",- "serveError": "Tailscale Serveの設定に失敗しました",- "funnelError": "Tailscale Funnelの設定に失敗しました",- "urlCopied": "URLがクリップボードにコピーされました"- },- "telegramWizard": {- "title": "Telegramを接続",- "description": "Telegramを設定してJanとリモートでチャット",- "step1": {- "title": "ボットを作成",- "instruction1": "Telegramを開いて @BotFather を検索",- "instruction2": "/newbot を送信して新しいボットを作成",- "instruction3": "プロンプトに従ってボットに名前を付ける",- "instruction4": "ボットトークンをコピー(例: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "トークンを入力",- "placeholder": "ボットトークンをここに貼り付け",- "validate": "トークンを検証",- "validating": "検証中...",- "invalidToken": "無効なトークンです。確認してもう一度お試しください。",- "validToken": "トークンが検証されました!ボット: @{{username}}"- },- "step3": {- "title": "設定と開始",- "connecting": "Telegramチャンネルを設定中...",- "success": "Telegramチャンネルが正常に設定されました!",- "error": "Telegramの設定に失敗しました: {{error}}"- },- "step4": {- "title": "デバイスをペアリング",- "instruction": "Telegramでボットを開いてメッセージを送信してください。ボットがペアリングコードを返信します — 以下に貼り付けて接続してください。",- "openBot": "Telegramで @{{username}} を開く",- "instruction1": "上のリンクを使ってTelegramでボットを開く",- "instruction2": "「開始」を押すか、ボットにメッセージを送信",- "instruction3": "ボットの返信からペアリングコードをコピーして以下に貼り付け",- "codeLabel": "ペアリングコード",- "codePlaceholder": "例: ZNAV9KZ3",- "approve": "承認して接続",- "approving": "承認中...",- "approved": "デバイスが正常にペアリングされました!",- "approveError": "ペアリングの承認に失敗しました: {{error}}",- "codeRequired": "ボットのメッセージからペアリングコードを入力してください",- "notConnected": "チャンネルがまだ接続されていません。OpenClawゲートウェイが実行中であることを確認してください。",- "skipForNow": "今はスキップ",- "resetPairing": "コードがない場合はクリックしてリセットし、/start を再送信してください",- "resetSuccess": "ペアリングコードがクリアされました — ボットに /start を再送信してください",- "resetError": "ペアリングコードのリセットに失敗しました"- },- "step5": {- "title": "接続完了!",- "success": "Telegramが接続されました!",- "instruction": "ボットにメッセージを送信してJanとチャットできます。",- "botUsername": "あなたのボット: @{{username}}",- "pairedUsers": "{{count}} 台のデバイスがペアリング済み"- },- "buttons": {- "next": "次へ",- "back": "戻る",- "connect": "接続",- "cancel": "キャンセル",- "done": "完了",- "retry": "再試行",- "disconnect": "切断"- },- "status": {- "notConnected": "未接続",- "connected": "接続済み",- "connecting": "接続中..."- },- "errors": {- "networkError": "ネットワークエラー。接続を確認してください。",- "tokenRequired": "ボットトークンを入力してください",- "configError": "設定の保存に失敗しました"- }- },- "whatsappWizard": {- "setupTitle": "WhatsApp設定",- "setupDescription": "WhatsAppアカウントを接続してリモートメッセージングを有効にする",- "howItWorks": "仕組み",- "whatsappStep1": "「セットアップ開始」をクリック — 自動的に設定します",- "whatsappStep2": "WhatsAppアプリでQRコードをスキャン",- "whatsappStep3": "スマートフォンからJanとチャットを開始!",- "settingUp": "セットアップ中...",- "settingUpDescription": "OpenClawを設定し、WhatsApp接続を準備中です。少々お待ちください...",- "checkingOpenClaw": "OpenClawのインストールを確認中",- "configuringGateway": "ゲートウェイ接続を設定中",- "enablingWhatsApp": "WhatsAppチャンネルを有効化中",- "scanQrCode": "QRコードをスキャン",- "qrCodeInstructions": "スマートフォンでWhatsAppを開いてこのQRコードをスキャン",- "generatingQrCode": "QRコードを生成中...",- "waitingForScan": "スキャンを待機中...",- "verifyingConnection": "接続を確認中",- "pleaseWait": "接続を確認中です。お待ちください",- "whatsappConnected": "WhatsAppが接続されました!",- "whatsappConnectedDescription": "WhatsAppが接続されました。メッセージを送信してJanとチャットできます。",- "connectionFailed": "接続に失敗しました",- "unknownError": "不明なエラーが発生しました",- "back": "戻る",- "refreshQrCode": "QRコードを更新",- "tryAgain": "もう一度試す",- "startSetup": "セットアップ開始",- "connecting": "接続中..."- }- }+ "backendInstallError": "バックエンドのインストールに失敗しました"}diff --git a/web-app/src/locales/pl/common.json b/web-app/src/locales/pl/common.jsonindex 7d085744d..84e663000 100644--- a/web-app/src/locales/pl/common.json+++ b/web-app/src/locales/pl/common.json@@ -18,7 +18,6 @@"newChat": "Nowy Czat","newAgentChat": "Nowy Czat Agenta","chats": "Czaty",- "openclawAgent": "OpenClaw Agent","favorites": "Ulubione","recents": "Ostatnie","hub": "Centrum Modeli",diff --git a/web-app/src/locales/pl/settings.json b/web-app/src/locales/pl/settings.jsonindex 2d59765e4..9aa738d8c 100644--- a/web-app/src/locales/pl/settings.json+++ b/web-app/src/locales/pl/settings.json@@ -274,175 +274,5 @@"updateError": "Nie udało się zaktualizować Llamacpp"},"backendInstallSuccess": "Backend został pomyślnie zainstalowany",- "backendInstallError": "Nie udało się zainstalować backendu",- "remoteAccess": {- "title": "Dostęp zdalny",- "running": "Dostęp zdalny jest teraz uruchomiony",- "stopped": "Dostęp zdalny został zatrzymany",- "urlCopied": "Link skopiowany do schowka",- "port": "Port",- "runtimeVersion": "Wersja środowiska uruchomieniowego",- "openclawVersion": "Wersja OpenClaw",- "openclawIntegration": "Integracja OpenClaw",- "enableRemoteAccess": "Włącz OpenClaw",- "disableRemoteAccess": "Wyłącz OpenClaw",- "settings": "Ustawienia",- "install": "Zainstaluj",- "start": "Uruchom",- "stop": "Zatrzymaj",- "startError": "Nie udało się uruchomić dostępu zdalnego. Spróbuj ponownie.",- "stopError": "Nie udało się zatrzymać dostępu zdalnego. Spróbuj ponownie.",- "nodeRequired": "Wymagany jest Node.js 22+. Zainstaluj go najpierw.",- "portInUse": "Port 18789 jest w użyciu. Zamknij inne aplikacje, które go używają.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Kanały",- "runtimeMode": "Tryb uruchomienia",- "dockerSandbox": "Kontener Docker",- "directProcess": "Proces bezpośredni",- "securityAdvisory": "OpenClaw działa bez izolacji sandbox. Aby uzyskać lepsze bezpieczeństwo, zainstaluj i otwórz Docker Desktop, a następnie uruchom ponownie OpenClaw, aby uruchomić go w kontenerze.",- "logViewer": "Logi piaskownicy",- "noLogs": "Brak logów",- "copyLogs": "Kopiuj wszystko",- "downloadLogs": "Pobierz",- "restartSandbox": "Uruchom ponownie piaskownicę",- "restarting": "Uruchamianie piaskownicy ponownie...",- "localNetworkOnly": "Tylko sieć lokalna",- "notConfigured": "Nie skonfigurowano",- "publicAccess": "Dostęp publiczny",- "tunnelUrl": "URL tunelu",- "copyUrl": "Kopiuj URL",- "openUrl": "Otwórz URL",- "activeTunnel": "Aktywny tunel",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Edytuj Soul.md, User.md i inne pliki konfiguracyjne",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Otwórz panel sterowania w przeglądarce",- "addChannel": {- "title": "Dodaj kanał",- "description": "Wybierz platformę komunikacyjną do połączenia",- "cancel": "Anuluj",- "continue": "Kontynuuj"- },- "channelDescriptions": {- "telegram": "Połącz przez bota Telegram dla bezpiecznej komunikacji",- "whatsapp": "Połącz przez WhatsApp dla komunikacji biznesowej"- },- "connected": "Połączono",- "notConnected": "Nie połączono",- "manage": "Zarządzaj",- "disconnect": "Rozłącz",- "channelDisconnected": "{{channel}} rozłączono",- "disconnectError": "Nie udało się rozłączyć. Spróbuj ponownie.",- "channelNotConnected": "Kliknij ustawienia, aby połączyć {{channel}}",- "copiedToClipboard": "Skopiowano do schowka",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve włączony",- "serveDisabled": "Tailscale Serve wyłączony",- "funnelEnabled": "Tailscale Funnel włączony - Twój punkt końcowy jest teraz dostępny publicznie",- "funnelDisabled": "Tailscale Funnel wyłączony",- "serveError": "Nie udało się skonfigurować Tailscale Serve",- "funnelError": "Nie udało się skonfigurować Tailscale Funnel",- "urlCopied": "URL skopiowany do schowka"- },- "telegramWizard": {- "title": "Połącz Telegram",- "description": "Skonfiguruj Telegram, aby rozmawiać z Jan zdalnie",- "step1": {- "title": "Utwórz bota",- "instruction1": "Otwórz Telegram i wyszukaj @BotFather",- "instruction2": "Wyślij /newbot, aby utworzyć nowego bota",- "instruction3": "Postępuj zgodnie z instrukcjami, aby nazwać bota",- "instruction4": "Skopiuj token bota (wygląda jak: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Wprowadź token",- "placeholder": "Wklej token bota tutaj",- "validate": "Zweryfikuj token",- "validating": "Weryfikacja...",- "invalidToken": "Nieprawidłowy token. Sprawdź i spróbuj ponownie.",- "validToken": "Token zweryfikowany! Bot: @{{username}}"- },- "step3": {- "title": "Konfiguruj i uruchom",- "connecting": "Konfigurowanie kanału Telegram...",- "success": "Kanał Telegram skonfigurowany pomyślnie!",- "error": "Nie udało się skonfigurować Telegram: {{error}}"- },- "step4": {- "title": "Sparuj urządzenie",- "instruction": "Otwórz bota na Telegramie i wyślij wiadomość. Bot odpowie kodem parowania — wklej go poniżej, aby się połączyć.",- "openBot": "Otwórz @{{username}} na Telegramie",- "instruction1": "Otwórz bota na Telegramie za pomocą powyższego linku",- "instruction2": "Naciśnij \"Start\" lub wyślij dowolną wiadomość do bota",- "instruction3": "Skopiuj kod parowania z odpowiedzi bota i wklej go poniżej",- "codeLabel": "Kod parowania",- "codePlaceholder": "np. ZNAV9KZ3",- "approve": "Zatwierdź i połącz",- "approving": "Zatwierdzanie...",- "approved": "Urządzenie sparowane pomyślnie!",- "approveError": "Nie udało się zatwierdzić parowania: {{error}}",- "codeRequired": "Wprowadź kod parowania z wiadomości bota",- "notConnected": "Kanał nie jest jeszcze połączony. Upewnij się, że bramka OpenClaw jest uruchomiona.",- "skipForNow": "Pomiń na razie",- "resetPairing": "Brak kodu? Kliknij, aby zresetować i ponownie wyślij /start",- "resetSuccess": "Kody parowania wyczyszczone — wyślij /start do bota ponownie",- "resetError": "Nie udało się zresetować kodów parowania"- },- "step5": {- "title": "Połączono!",- "success": "Telegram jest teraz połączony!",- "instruction": "Możesz teraz rozmawiać z Jan, wysyłając wiadomości do bota.",- "botUsername": "Twój bot: @{{username}}",- "pairedUsers": "{{count}} sparowanych urządzeń"- },- "buttons": {- "next": "Dalej",- "back": "Wstecz",- "connect": "Połącz",- "cancel": "Anuluj",- "done": "Gotowe",- "retry": "Ponów",- "disconnect": "Rozłącz"- },- "status": {- "notConnected": "Nie połączono",- "connected": "Połączono",- "connecting": "Łączenie..."- },- "errors": {- "networkError": "Błąd sieci. Sprawdź połączenie.",- "tokenRequired": "Wprowadź token bota",- "configError": "Nie udało się zapisać konfiguracji"- }- },- "whatsappWizard": {- "setupTitle": "Konfiguracja WhatsApp",- "setupDescription": "Połącz konto WhatsApp, aby włączyć zdalne wiadomości",- "howItWorks": "Jak to działa",- "whatsappStep1": "Kliknij \"Rozpocznij konfigurację\" — skonfigurujemy wszystko automatycznie",- "whatsappStep2": "Zeskanuj kod QR aplikacją WhatsApp",- "whatsappStep3": "Zacznij rozmawiać z Jan ze swojego telefonu!",- "settingUp": "Konfigurowanie...",- "settingUpDescription": "Konfigurowanie OpenClaw i przygotowanie połączenia WhatsApp. To może chwilę potrwać...",- "checkingOpenClaw": "Sprawdzanie instalacji OpenClaw",- "configuringGateway": "Konfigurowanie połączenia bramki",- "enablingWhatsApp": "Włączanie kanału WhatsApp",- "scanQrCode": "Zeskanuj kod QR",- "qrCodeInstructions": "Otwórz WhatsApp na telefonie i zeskanuj ten kod QR",- "generatingQrCode": "Generowanie kodu QR...",- "waitingForScan": "Oczekiwanie na skan...",- "verifyingConnection": "Weryfikowanie połączenia",- "pleaseWait": "Proszę czekać, weryfikujemy połączenie",- "whatsappConnected": "WhatsApp połączony!",- "whatsappConnectedDescription": "WhatsApp jest teraz połączony. Możesz rozmawiać z Jan, wysyłając wiadomości.",- "connectionFailed": "Połączenie nie powiodło się",- "unknownError": "Wystąpił nieznany błąd",- "back": "Wstecz",- "refreshQrCode": "Odśwież kod QR",- "tryAgain": "Spróbuj ponownie",- "startSetup": "Rozpocznij konfigurację",- "connecting": "Łączenie..."- }- }+ "backendInstallError": "Nie udało się zainstalować backendu"}diff --git a/web-app/src/locales/pt-BR/common.json b/web-app/src/locales/pt-BR/common.jsonindex a21aba2ce..829dbb9df 100644--- a/web-app/src/locales/pt-BR/common.json+++ b/web-app/src/locales/pt-BR/common.json@@ -18,7 +18,6 @@"newChat": "Novo Chat","newAgentChat": "Novo Chat de Agente","chats": "Conversas",- "openclawAgent": "OpenClaw Agent","favorites": "Favoritos","recents": "Recentes","hub": "Hub",diff --git a/web-app/src/locales/pt-BR/settings.json b/web-app/src/locales/pt-BR/settings.jsonindex 34d85ae3e..da715a18f 100644--- a/web-app/src/locales/pt-BR/settings.json+++ b/web-app/src/locales/pt-BR/settings.json@@ -306,175 +306,5 @@"updateError": "Falha ao atualizar Llamacpp"},"backendInstallSuccess": "Backend instalado com sucesso",- "backendInstallError": "Falha ao instalar backend",- "remoteAccess": {- "title": "Acesso Remoto",- "running": "Acesso Remoto está em execução",- "stopped": "Acesso Remoto foi parado",- "urlCopied": "Link copiado para a área de transferência",- "port": "Porta",- "runtimeVersion": "Versão do Runtime",- "openclawVersion": "Versão do OpenClaw",- "openclawIntegration": "Integração OpenClaw",- "enableRemoteAccess": "Ativar OpenClaw",- "disableRemoteAccess": "Desativar OpenClaw",- "settings": "Configurações",- "install": "Instalar",- "start": "Iniciar",- "stop": "Parar",- "startError": "Não foi possível iniciar o Acesso Remoto. Tente novamente.",- "stopError": "Não foi possível parar o Acesso Remoto. Tente novamente.",- "nodeRequired": "Node.js 22+ é necessário. Instale-o primeiro.",- "portInUse": "Porta 18789 está em uso. Feche outros apps que a estão usando.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Canais",- "runtimeMode": "Modo de execução",- "dockerSandbox": "Contêiner Docker",- "directProcess": "Processo direto",- "securityAdvisory": "OpenClaw está sendo executado sem isolamento de sandbox. Para maior segurança, instale e abra o Docker Desktop, depois reinicie o OpenClaw para executá-lo em um contêiner.",- "logViewer": "Logs do Sandbox",- "noLogs": "Sem logs disponíveis",- "copyLogs": "Copiar tudo",- "downloadLogs": "Baixar",- "restartSandbox": "Reiniciar Sandbox",- "restarting": "Reiniciando sandbox...",- "localNetworkOnly": "Apenas Rede Local",- "notConfigured": "Não configurado",- "publicAccess": "Acesso Público",- "tunnelUrl": "URL do Tunnel",- "copyUrl": "Copiar URL",- "openUrl": "Abrir URL",- "activeTunnel": "Tunnel Ativo",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Edite Soul.md, User.md e outros arquivos de configuração",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Abrir o painel web",- "addChannel": {- "title": "Adicionar Canal",- "description": "Selecione uma plataforma de mensagens para conectar",- "cancel": "Cancelar",- "continue": "Continuar"- },- "channelDescriptions": {- "telegram": "Conectar via bot do Telegram para mensagens seguras",- "whatsapp": "Conectar via WhatsApp para mensagens empresariais"- },- "connected": "Conectado",- "notConnected": "Não conectado",- "manage": "Gerenciar",- "disconnect": "Desconectar",- "channelDisconnected": "{{channel}} desconectado",- "disconnectError": "Não foi possível desconectar. Tente novamente.",- "channelNotConnected": "Clique em configurações para conectar {{channel}}",- "copiedToClipboard": "Copiado para a área de transferência",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve ativado",- "serveDisabled": "Tailscale Serve desativado",- "funnelEnabled": "Tailscale Funnel ativado - Seu endpoint agora é acessível publicamente",- "funnelDisabled": "Tailscale Funnel desativado",- "serveError": "Falha ao configurar Tailscale Serve",- "funnelError": "Falha ao configurar Tailscale Funnel",- "urlCopied": "URL copiada para a área de transferência"- },- "telegramWizard": {- "title": "Conectar Telegram",- "description": "Configure o Telegram para conversar com Jan remotamente",- "step1": {- "title": "Criar um Bot",- "instruction1": "Abra o Telegram e pesquise @BotFather",- "instruction2": "Envie /newbot para criar um novo bot",- "instruction3": "Siga as instruções para nomear seu bot",- "instruction4": "Copie o token do bot (parece: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Inserir Token",- "placeholder": "Cole o token do bot aqui",- "validate": "Validar Token",- "validating": "Validando...",- "invalidToken": "Token inválido. Verifique e tente novamente.",- "validToken": "Token validado! Bot: @{{username}}"- },- "step3": {- "title": "Configurar & Iniciar",- "connecting": "Configurando canal do Telegram...",- "success": "Canal do Telegram configurado com sucesso!",- "error": "Falha ao configurar Telegram: {{error}}"- },- "step4": {- "title": "Parear seu Dispositivo",- "instruction": "Abra seu bot no Telegram e envie uma mensagem. O bot responderá com um código de pareamento — cole abaixo para conectar.",- "openBot": "Abrir @{{username}} no Telegram",- "instruction1": "Abra seu bot no Telegram usando o link acima",- "instruction2": "Pressione \"Iniciar\" ou envie qualquer mensagem ao bot",- "instruction3": "Copie o código de pareamento da resposta do bot e cole abaixo",- "codeLabel": "Código de Pareamento",- "codePlaceholder": "ex: ZNAV9KZ3",- "approve": "Aprovar & Conectar",- "approving": "Aprovando...",- "approved": "Dispositivo pareado com sucesso!",- "approveError": "Falha ao aprovar pareamento: {{error}}",- "codeRequired": "Insira o código de pareamento da mensagem do bot",- "notConnected": "Canal ainda não conectado. Verifique se o gateway OpenClaw está em execução.",- "skipForNow": "Pular por agora",- "resetPairing": "Sem código? Clique para resetar & tente /start novamente",- "resetSuccess": "Códigos de pareamento limpos — envie /start ao bot novamente",- "resetError": "Falha ao resetar códigos de pareamento"- },- "step5": {- "title": "Conectado!",- "success": "Telegram está conectado!",- "instruction": "Agora você pode conversar com Jan enviando mensagens ao seu bot.",- "botUsername": "Seu bot: @{{username}}",- "pairedUsers": "{{count}} dispositivo(s) pareado(s)"- },- "buttons": {- "next": "Próximo",- "back": "Voltar",- "connect": "Conectar",- "cancel": "Cancelar",- "done": "Concluído",- "retry": "Tentar novamente",- "disconnect": "Desconectar"- },- "status": {- "notConnected": "Não conectado",- "connected": "Conectado",- "connecting": "Conectando..."- },- "errors": {- "networkError": "Erro de rede. Verifique sua conexão.",- "tokenRequired": "Insira um token de bot",- "configError": "Falha ao salvar configuração"- }- },- "whatsappWizard": {- "setupTitle": "Configuração do WhatsApp",- "setupDescription": "Conecte sua conta WhatsApp para ativar mensagens remotas",- "howItWorks": "Como funciona",- "whatsappStep1": "Clique em 'Iniciar Configuração' — configuraremos tudo automaticamente",- "whatsappStep2": "Escaneie o código QR com seu app WhatsApp",- "whatsappStep3": "Comece a conversar com Jan do seu celular!",- "settingUp": "Configurando...",- "settingUpDescription": "Configurando OpenClaw e preparando conexão WhatsApp. Isso pode levar um momento...",- "checkingOpenClaw": "Verificando instalação do OpenClaw",- "configuringGateway": "Configurando conexão do Gateway",- "enablingWhatsApp": "Ativando canal WhatsApp",- "scanQrCode": "Escanear Código QR",- "qrCodeInstructions": "Abra o WhatsApp no seu celular e escaneie este código QR",- "generatingQrCode": "Gerando código QR...",- "waitingForScan": "Aguardando escaneamento...",- "verifyingConnection": "Verificando Conexão",- "pleaseWait": "Aguarde enquanto verificamos sua conexão",- "whatsappConnected": "WhatsApp Conectado!",- "whatsappConnectedDescription": "Seu WhatsApp está conectado. Você pode conversar com Jan enviando mensagens.",- "connectionFailed": "Conexão Falhou",- "unknownError": "Ocorreu um erro desconhecido",- "back": "Voltar",- "refreshQrCode": "Atualizar Código QR",- "tryAgain": "Tentar Novamente",- "startSetup": "Iniciar Configuração",- "connecting": "Conectando..."- }- }+ "backendInstallError": "Falha ao instalar backend"}diff --git a/web-app/src/locales/ru/common.json b/web-app/src/locales/ru/common.jsonindex 5b45eb3b4..ff050cbed 100644--- a/web-app/src/locales/ru/common.json+++ b/web-app/src/locales/ru/common.json@@ -18,7 +18,6 @@"newChat": "Новый чат","newAgentChat": "Новый чат агента","chats": "Чаты",- "openclawAgent": "OpenClaw Агент","favorites": "Избранное","recents": "Недавние","hub": "Хаб",diff --git a/web-app/src/locales/ru/settings.json b/web-app/src/locales/ru/settings.jsonindex 62dfcbdfe..4e8aeff17 100644--- a/web-app/src/locales/ru/settings.json+++ b/web-app/src/locales/ru/settings.json@@ -312,175 +312,5 @@"updateError": "Не удалось обновить Llamacpp"},"backendInstallSuccess": "Компонент успешно установлен",- "backendInstallError": "Не удалось установить компонент",- "remoteAccess": {- "title": "Удалённый доступ",- "running": "Удалённый доступ запущен",- "stopped": "Удалённый доступ остановлен",- "urlCopied": "Ссылка скопирована в буфер обмена",- "port": "Порт",- "runtimeVersion": "Версия runtime",- "openclawVersion": "Версия OpenClaw",- "openclawIntegration": "Интеграция OpenClaw",- "enableRemoteAccess": "Включить OpenClaw",- "disableRemoteAccess": "Отключить OpenClaw",- "settings": "Настройки",- "install": "Установить",- "start": "Запустить",- "stop": "Остановить",- "startError": "Не удалось запустить удалённый доступ. Попробуйте снова.",- "stopError": "Не удалось остановить удалённый доступ. Попробуйте снова.",- "nodeRequired": "Требуется Node.js 22+. Сначала установите его.",- "portInUse": "Порт 18789 занят. Закройте другие приложения, использующие его.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Каналы",- "runtimeMode": "Режим запуска",- "dockerSandbox": "Docker-контейнер",- "directProcess": "Прямой процесс",- "securityAdvisory": "OpenClaw работает без изоляции песочницы. Для лучшей безопасности установите и откройте Docker Desktop, затем перезапустите OpenClaw для запуска в контейнере.",- "logViewer": "Логи песочницы",- "noLogs": "Нет логов",- "copyLogs": "Копировать всё",- "downloadLogs": "Скачать",- "restartSandbox": "Перезапустить песочницу",- "restarting": "Перезапуск песочницы...",- "localNetworkOnly": "Только локальная сеть",- "notConfigured": "Не настроено",- "publicAccess": "Публичный доступ",- "tunnelUrl": "URL туннеля",- "copyUrl": "Копировать URL",- "openUrl": "Открыть URL",- "activeTunnel": "Активный туннель",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Редактируйте Soul.md, User.md и другие конфигурационные файлы",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Открыть веб-панель управления",- "addChannel": {- "title": "Добавить канал",- "description": "Выберите мессенджер для подключения",- "cancel": "Отмена",- "continue": "Продолжить"- },- "channelDescriptions": {- "telegram": "Подключить через бота Telegram для безопасных сообщений",- "whatsapp": "Подключить через WhatsApp для бизнес-сообщений"- },- "connected": "Подключено",- "notConnected": "Не подключено",- "manage": "Управление",- "disconnect": "Отключить",- "channelDisconnected": "{{channel}} отключён",- "disconnectError": "Не удалось отключить. Попробуйте снова.",- "channelNotConnected": "Нажмите настройки, чтобы подключить {{channel}}",- "copiedToClipboard": "Скопировано в буфер обмена",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve включён",- "serveDisabled": "Tailscale Serve выключен",- "funnelEnabled": "Tailscale Funnel включён - Ваша конечная точка теперь общедоступна",- "funnelDisabled": "Tailscale Funnel выключен",- "serveError": "Не удалось настроить Tailscale Serve",- "funnelError": "Не удалось настроить Tailscale Funnel",- "urlCopied": "URL скопирован в буфер обмена"- },- "telegramWizard": {- "title": "Подключить Telegram",- "description": "Настройте Telegram для удалённого чата с Jan",- "step1": {- "title": "Создать бота",- "instruction1": "Откройте Telegram и найдите @BotFather",- "instruction2": "Отправьте /newbot для создания нового бота",- "instruction3": "Следуйте инструкциям, чтобы назвать бота",- "instruction4": "Скопируйте токен бота (выглядит как: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Введите токен",- "placeholder": "Вставьте токен бота здесь",- "validate": "Проверить токен",- "validating": "Проверка...",- "invalidToken": "Недействительный токен. Проверьте и попробуйте снова.",- "validToken": "Токен подтверждён! Бот: @{{username}}"- },- "step3": {- "title": "Настроить и запустить",- "connecting": "Настройка канала Telegram...",- "success": "Канал Telegram успешно настроен!",- "error": "Не удалось настроить Telegram: {{error}}"- },- "step4": {- "title": "Сопряжение устройства",- "instruction": "Откройте бота в Telegram и отправьте сообщение. Бот ответит кодом сопряжения — вставьте его ниже для подключения.",- "openBot": "Открыть @{{username}} в Telegram",- "instruction1": "Откройте бота в Telegram по ссылке выше",- "instruction2": "Нажмите «Старт» или отправьте любое сообщение боту",- "instruction3": "Скопируйте код сопряжения из ответа бота и вставьте ниже",- "codeLabel": "Код сопряжения",- "codePlaceholder": "например: ZNAV9KZ3",- "approve": "Одобрить и подключить",- "approving": "Одобрение...",- "approved": "Устройство успешно сопряжено!",- "approveError": "Не удалось одобрить сопряжение: {{error}}",- "codeRequired": "Введите код сопряжения из сообщения бота",- "notConnected": "Канал ещё не подключён. Убедитесь, что шлюз OpenClaw запущен.",- "skipForNow": "Пропустить пока",- "resetPairing": "Нет кода? Нажмите для сброса и отправьте /start заново",- "resetSuccess": "Коды сопряжения очищены — отправьте /start боту заново",- "resetError": "Не удалось сбросить коды сопряжения"- },- "step5": {- "title": "Подключено!",- "success": "Telegram подключён!",- "instruction": "Теперь вы можете общаться с Jan, отправляя сообщения боту.",- "botUsername": "Ваш бот: @{{username}}",- "pairedUsers": "{{count}} устройств(о) сопряжено"- },- "buttons": {- "next": "Далее",- "back": "Назад",- "connect": "Подключить",- "cancel": "Отмена",- "done": "Готово",- "retry": "Повторить",- "disconnect": "Отключить"- },- "status": {- "notConnected": "Не подключено",- "connected": "Подключено",- "connecting": "Подключение..."- },- "errors": {- "networkError": "Ошибка сети. Проверьте подключение.",- "tokenRequired": "Введите токен бота",- "configError": "Не удалось сохранить конфигурацию"- }- },- "whatsappWizard": {- "setupTitle": "Настройка WhatsApp",- "setupDescription": "Подключите аккаунт WhatsApp для удалённых сообщений",- "howItWorks": "Как это работает",- "whatsappStep1": "Нажмите «Начать настройку» — мы настроим всё автоматически",- "whatsappStep2": "Отсканируйте QR-код приложением WhatsApp",- "whatsappStep3": "Начните общаться с Jan с телефона!",- "settingUp": "Настройка...",- "settingUpDescription": "Настройка OpenClaw и подготовка подключения WhatsApp. Это может занять некоторое время...",- "checkingOpenClaw": "Проверка установки OpenClaw",- "configuringGateway": "Настройка подключения шлюза",- "enablingWhatsApp": "Активация канала WhatsApp",- "scanQrCode": "Сканировать QR-код",- "qrCodeInstructions": "Откройте WhatsApp на телефоне и отсканируйте этот QR-код",- "generatingQrCode": "Генерация QR-кода...",- "waitingForScan": "Ожидание сканирования...",- "verifyingConnection": "Проверка подключения",- "pleaseWait": "Подождите, пока мы проверяем подключение",- "whatsappConnected": "WhatsApp подключён!",- "whatsappConnectedDescription": "WhatsApp подключён. Вы можете общаться с Jan, отправляя сообщения.",- "connectionFailed": "Подключение не удалось",- "unknownError": "Произошла неизвестная ошибка",- "back": "Назад",- "refreshQrCode": "Обновить QR-код",- "tryAgain": "Попробовать снова",- "startSetup": "Начать настройку",- "connecting": "Подключение..."- }- }+ "backendInstallError": "Не удалось установить компонент"}diff --git a/web-app/src/locales/vn/common.json b/web-app/src/locales/vn/common.jsonindex 8bf6a5396..065e8467f 100644--- a/web-app/src/locales/vn/common.json+++ b/web-app/src/locales/vn/common.json@@ -18,7 +18,6 @@"newChat": "Trò chuyện Mới","newAgentChat": "Trò chuyện Agent Mới","chats": "Trò chuyện",- "openclawAgent": "OpenClaw Agent","favorites": "Yêu thích","recents": "Gần đây","hub": "Hub",diff --git a/web-app/src/locales/vn/settings.json b/web-app/src/locales/vn/settings.jsonindex d84b6c4ea..9a965d2a6 100644--- a/web-app/src/locales/vn/settings.json+++ b/web-app/src/locales/vn/settings.json@@ -274,175 +274,5 @@"updateError": "Không thể cập nhật Llamacpp"},"backendInstallSuccess": "Backend đã được cài đặt thành công",- "backendInstallError": "Không thể cài đặt backend",- "remoteAccess": {- "title": "Truy cập từ xa",- "running": "Truy cập từ xa đang chạy",- "stopped": "Truy cập từ xa đã dừng",- "urlCopied": "Liên kết đã sao chép vào clipboard",- "port": "Cổng",- "runtimeVersion": "Phiên bản Runtime",- "openclawVersion": "Phiên bản OpenClaw",- "openclawIntegration": "Tích hợp OpenClaw",- "enableRemoteAccess": "Bật OpenClaw",- "disableRemoteAccess": "Tắt OpenClaw",- "settings": "Cài đặt",- "install": "Cài đặt",- "start": "Bắt đầu",- "stop": "Dừng",- "startError": "Không thể bắt đầu Truy cập từ xa. Vui lòng thử lại.",- "stopError": "Không thể dừng Truy cập từ xa. Vui lòng thử lại.",- "nodeRequired": "Cần Node.js 22+. Vui lòng cài đặt trước.",- "portInUse": "Cổng 18789 đang được sử dụng. Vui lòng đóng các ứng dụng khác đang sử dụng nó.",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "Kênh",- "runtimeMode": "Chế độ chạy",- "dockerSandbox": "Docker Container",- "directProcess": "Tiến trình trực tiếp",- "securityAdvisory": "OpenClaw đang chạy không có sandbox. Để bảo mật tốt hơn, hãy cài đặt và mở Docker Desktop, sau đó khởi động lại OpenClaw để chạy trong container.",- "logViewer": "Logs Sandbox",- "noLogs": "Không có logs",- "copyLogs": "Sao chép tất cả",- "downloadLogs": "Tải xuống",- "restartSandbox": "Khởi động lại Sandbox",- "restarting": "Đang khởi động lại sandbox...",- "localNetworkOnly": "Chỉ mạng cục bộ",- "notConfigured": "Chưa cấu hình",- "publicAccess": "Truy cập công khai",- "tunnelUrl": "URL đường hầm",- "copyUrl": "Sao chép URL",- "openUrl": "Mở URL",- "activeTunnel": "Đường hầm hoạt động",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "Chỉnh sửa Soul.md, User.md và các tệp cấu hình khác",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "Mở bảng điều khiển web",- "addChannel": {- "title": "Thêm kênh",- "description": "Chọn nền tảng nhắn tin để kết nối",- "cancel": "Hủy",- "continue": "Tiếp tục"- },- "channelDescriptions": {- "telegram": "Kết nối qua bot Telegram để nhắn tin an toàn",- "whatsapp": "Kết nối qua WhatsApp để nhắn tin kinh doanh"- },- "connected": "Đã kết nối",- "notConnected": "Chưa kết nối",- "manage": "Quản lý",- "disconnect": "Ngắt kết nối",- "channelDisconnected": "{{channel}} đã ngắt kết nối",- "disconnectError": "Không thể ngắt kết nối. Vui lòng thử lại.",- "channelNotConnected": "Nhấp vào cài đặt để kết nối {{channel}}",- "copiedToClipboard": "Đã sao chép vào clipboard",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve đã bật",- "serveDisabled": "Tailscale Serve đã tắt",- "funnelEnabled": "Tailscale Funnel đã bật - Endpoint của bạn hiện có thể truy cập công khai",- "funnelDisabled": "Tailscale Funnel đã tắt",- "serveError": "Không thể cấu hình Tailscale Serve",- "funnelError": "Không thể cấu hình Tailscale Funnel",- "urlCopied": "URL đã sao chép vào clipboard"- },- "telegramWizard": {- "title": "Kết nối Telegram",- "description": "Thiết lập Telegram để trò chuyện với Jan từ xa",- "step1": {- "title": "Tạo Bot",- "instruction1": "Mở Telegram và tìm @BotFather",- "instruction2": "Gửi /newbot để tạo bot mới",- "instruction3": "Làm theo hướng dẫn để đặt tên bot",- "instruction4": "Sao chép mã bot (dạng: 123456789:ABCdefGHI...)"- },- "step2": {- "title": "Nhập mã",- "placeholder": "Dán mã bot vào đây",- "validate": "Xác thực mã",- "validating": "Đang xác thực...",- "invalidToken": "Mã không hợp lệ. Vui lòng kiểm tra và thử lại.",- "validToken": "Mã đã xác thực! Bot: @{{username}}"- },- "step3": {- "title": "Cấu hình & Bắt đầu",- "connecting": "Đang cấu hình kênh Telegram...",- "success": "Kênh Telegram đã cấu hình thành công!",- "error": "Cấu hình Telegram thất bại: {{error}}"- },- "step4": {- "title": "Ghép nối thiết bị",- "instruction": "Mở bot trên Telegram và gửi tin nhắn. Bot sẽ trả lời mã ghép nối — dán vào bên dưới để kết nối.",- "openBot": "Mở @{{username}} trên Telegram",- "instruction1": "Mở bot trên Telegram bằng liên kết ở trên",- "instruction2": "Nhấn \"Bắt đầu\" hoặc gửi tin nhắn bất kỳ cho bot",- "instruction3": "Sao chép mã ghép nối từ phản hồi của bot và dán vào bên dưới",- "codeLabel": "Mã ghép nối",- "codePlaceholder": "ví dụ: ZNAV9KZ3",- "approve": "Phê duyệt & Kết nối",- "approving": "Đang phê duyệt...",- "approved": "Thiết bị đã ghép nối thành công!",- "approveError": "Phê duyệt ghép nối thất bại: {{error}}",- "codeRequired": "Vui lòng nhập mã ghép nối từ tin nhắn của bot",- "notConnected": "Kênh chưa kết nối. Đảm bảo OpenClaw gateway đang chạy.",- "skipForNow": "Bỏ qua tạm thời",- "resetPairing": "Không có mã? Nhấp để đặt lại & thử /start lại",- "resetSuccess": "Đã xóa mã ghép nối — gửi /start cho bot lại",- "resetError": "Đặt lại mã ghép nối thất bại"- },- "step5": {- "title": "Đã kết nối!",- "success": "Telegram đã kết nối!",- "instruction": "Bạn có thể trò chuyện với Jan bằng cách gửi tin nhắn cho bot.",- "botUsername": "Bot của bạn: @{{username}}",- "pairedUsers": "{{count}} thiết bị đã ghép nối"- },- "buttons": {- "next": "Tiếp",- "back": "Quay lại",- "connect": "Kết nối",- "cancel": "Hủy",- "done": "Xong",- "retry": "Thử lại",- "disconnect": "Ngắt kết nối"- },- "status": {- "notConnected": "Chưa kết nối",- "connected": "Đã kết nối",- "connecting": "Đang kết nối..."- },- "errors": {- "networkError": "Lỗi mạng. Vui lòng kiểm tra kết nối.",- "tokenRequired": "Vui lòng nhập mã bot",- "configError": "Lưu cấu hình thất bại"- }- },- "whatsappWizard": {- "setupTitle": "Thiết lập WhatsApp",- "setupDescription": "Kết nối tài khoản WhatsApp để nhắn tin từ xa",- "howItWorks": "Cách hoạt động",- "whatsappStep1": "Nhấp 'Bắt đầu thiết lập' - chúng tôi sẽ tự động cấu hình",- "whatsappStep2": "Quét mã QR bằng ứng dụng WhatsApp",- "whatsappStep3": "Bắt đầu trò chuyện với Jan từ điện thoại!",- "settingUp": "Đang thiết lập...",- "settingUpDescription": "Đang cấu hình OpenClaw và chuẩn bị kết nối WhatsApp. Vui lòng đợi...",- "checkingOpenClaw": "Kiểm tra cài đặt OpenClaw",- "configuringGateway": "Cấu hình kết nối Gateway",- "enablingWhatsApp": "Kích hoạt kênh WhatsApp",- "scanQrCode": "Quét mã QR",- "qrCodeInstructions": "Mở WhatsApp trên điện thoại và quét mã QR này",- "generatingQrCode": "Đang tạo mã QR...",- "waitingForScan": "Đang chờ quét...",- "verifyingConnection": "Xác minh kết nối",- "pleaseWait": "Vui lòng đợi trong khi chúng tôi xác minh kết nối",- "whatsappConnected": "WhatsApp đã kết nối!",- "whatsappConnectedDescription": "WhatsApp đã kết nối. Bạn có thể trò chuyện với Jan bằng cách gửi tin nhắn.",- "connectionFailed": "Kết nối thất bại",- "unknownError": "Đã xảy ra lỗi không xác định",- "back": "Quay lại",- "refreshQrCode": "Làm mới mã QR",- "tryAgain": "Thử lại",- "startSetup": "Bắt đầu thiết lập",- "connecting": "Đang kết nối..."- }- }+ "backendInstallError": "Không thể cài đặt backend"}diff --git a/web-app/src/locales/zh-CN/common.json b/web-app/src/locales/zh-CN/common.jsonindex de6a4d9d6..1120eb912 100644--- a/web-app/src/locales/zh-CN/common.json+++ b/web-app/src/locales/zh-CN/common.json@@ -18,7 +18,6 @@"newChat": "新建聊天","newAgentChat": "新建智能体聊天","chats": "聊天",- "openclawAgent": "OpenClaw 智能体","favorites": "收藏","recents": "最近","hub": "中心",@@ -106,7 +105,7 @@"increaseContextSizeDescription": "您想要增加上下文大小吗?","increaseContextSize": "增加上下文大小"},- "customAvatar": "自定义头像",+ "customAvatar": "自定义头像","editAssistant": "编辑助手","jan": "Jan","metadata": "元数据",diff --git a/web-app/src/locales/zh-CN/settings.json b/web-app/src/locales/zh-CN/settings.jsonindex 78e7acbca..384213e29 100644--- a/web-app/src/locales/zh-CN/settings.json+++ b/web-app/src/locales/zh-CN/settings.json@@ -274,175 +274,5 @@"updateError": "更新 Llamacpp 失败"},"backendInstallSuccess": "后端安装成功",- "backendInstallError": "后端安装失败",- "remoteAccess": {- "title": "远程访问",- "running": "远程访问正在运行",- "stopped": "远程访问已停止",- "urlCopied": "链接已复制到剪贴板",- "port": "端口",- "runtimeVersion": "运行时版本",- "openclawVersion": "OpenClaw 版本",- "openclawIntegration": "OpenClaw 集成",- "enableRemoteAccess": "启用 OpenClaw",- "disableRemoteAccess": "禁用 OpenClaw",- "settings": "设置",- "install": "安装",- "start": "启动",- "stop": "停止",- "startError": "无法启动远程访问。请重试。",- "stopError": "无法停止远程访问。请重试。",- "nodeRequired": "需要 Node.js 22+。请先安装。",- "portInUse": "端口 18789 已被占用。请关闭占用该端口的其他应用。",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "频道",- "runtimeMode": "运行模式",- "dockerSandbox": "Docker 容器",- "directProcess": "直接进程",- "securityAdvisory": "OpenClaw 正在无沙箱隔离的环境下运行。为了更好的安全性,请安装并打开 Docker Desktop,然后重新启动 OpenClaw 以在容器中运行。",- "logViewer": "沙箱日志",- "noLogs": "暂无日志",- "copyLogs": "全部复制",- "downloadLogs": "下载",- "restartSandbox": "重启沙箱",- "restarting": "正在重启沙箱...",- "localNetworkOnly": "仅限本地网络",- "notConfigured": "未配置",- "publicAccess": "公开访问",- "tunnelUrl": "隧道 URL",- "copyUrl": "复制 URL",- "openUrl": "打开 URL",- "activeTunnel": "活跃隧道",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "编辑 Soul.md、User.md 及其他配置文件",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "打开网页控制台",- "addChannel": {- "title": "添加频道",- "description": "选择要连接的消息平台",- "cancel": "取消",- "continue": "继续"- },- "channelDescriptions": {- "telegram": "通过 Telegram 机器人连接以实现安全消息传递",- "whatsapp": "通过 WhatsApp 连接以实现商业消息传递"- },- "connected": "已连接",- "notConnected": "未连接",- "manage": "管理",- "disconnect": "断开",- "channelDisconnected": "{{channel}} 已断开",- "disconnectError": "无法断开连接。请重试。",- "channelNotConnected": "点击设置连接 {{channel}}",- "copiedToClipboard": "已复制到剪贴板",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve 已启用",- "serveDisabled": "Tailscale Serve 已禁用",- "funnelEnabled": "Tailscale Funnel 已启用 - 您的端点现在可公开访问",- "funnelDisabled": "Tailscale Funnel 已禁用",- "serveError": "配置 Tailscale Serve 失败",- "funnelError": "配置 Tailscale Funnel 失败",- "urlCopied": "URL 已复制到剪贴板"- },- "telegramWizard": {- "title": "连接 Telegram",- "description": "设置 Telegram 以远程与 Jan 聊天",- "step1": {- "title": "创建机器人",- "instruction1": "打开 Telegram 并搜索 @BotFather",- "instruction2": "发送 /newbot 创建新机器人",- "instruction3": "按照提示为机器人命名",- "instruction4": "复制机器人令牌(格式如:123456789:ABCdefGHI...)"- },- "step2": {- "title": "输入令牌",- "placeholder": "在此粘贴机器人令牌",- "validate": "验证令牌",- "validating": "验证中...",- "invalidToken": "令牌无效。请检查后重试。",- "validToken": "令牌已验证!机器人:@{{username}}"- },- "step3": {- "title": "配置并启动",- "connecting": "正在配置 Telegram 频道...",- "success": "Telegram 频道配置成功!",- "error": "Telegram 配置失败:{{error}}"- },- "step4": {- "title": "配对您的设备",- "instruction": "在 Telegram 上打开您的机器人并发送消息。机器人将回复配对码——粘贴到下方以连接。",- "openBot": "在 Telegram 上打开 @{{username}}",- "instruction1": "使用上方链接在 Telegram 上打开您的机器人",- "instruction2": "按\"开始\"或向机器人发送任意消息",- "instruction3": "从机器人的回复中复制配对码并粘贴到下方",- "codeLabel": "配对码",- "codePlaceholder": "例如:ZNAV9KZ3",- "approve": "批准并连接",- "approving": "批准中...",- "approved": "设备配对成功!",- "approveError": "配对批准失败:{{error}}",- "codeRequired": "请输入机器人消息中的配对码",- "notConnected": "频道尚未连接。请确保 OpenClaw 网关正在运行。",- "skipForNow": "暂时跳过",- "resetPairing": "没有代码?点击重置并重新发送 /start",- "resetSuccess": "配对码已清除——请重新向机器人发送 /start",- "resetError": "重置配对码失败"- },- "step5": {- "title": "已连接!",- "success": "Telegram 已连接!",- "instruction": "您现在可以通过向机器人发送消息来与 Jan 聊天。",- "botUsername": "您的机器人:@{{username}}",- "pairedUsers": "{{count}} 台设备已配对"- },- "buttons": {- "next": "下一步",- "back": "返回",- "connect": "连接",- "cancel": "取消",- "done": "完成",- "retry": "重试",- "disconnect": "断开"- },- "status": {- "notConnected": "未连接",- "connected": "已连接",- "connecting": "连接中..."- },- "errors": {- "networkError": "网络错误。请检查您的连接。",- "tokenRequired": "请输入机器人令牌",- "configError": "保存配置失败"- }- },- "whatsappWizard": {- "setupTitle": "WhatsApp 设置",- "setupDescription": "连接您的 WhatsApp 帐户以启用远程消息",- "howItWorks": "工作原理",- "whatsappStep1": "点击\"开始设置\" — 我们将自动配置一切",- "whatsappStep2": "用 WhatsApp 应用扫描二维码",- "whatsappStep3": "从手机开始与 Jan 聊天!",- "settingUp": "设置中...",- "settingUpDescription": "正在配置 OpenClaw 并准备 WhatsApp 连接。请稍候...",- "checkingOpenClaw": "检查 OpenClaw 安装",- "configuringGateway": "配置网关连接",- "enablingWhatsApp": "启用 WhatsApp 频道",- "scanQrCode": "扫描二维码",- "qrCodeInstructions": "在手机上打开 WhatsApp 并扫描此二维码",- "generatingQrCode": "正在生成二维码...",- "waitingForScan": "等待扫描...",- "verifyingConnection": "验证连接",- "pleaseWait": "请稍候,我们正在验证您的连接",- "whatsappConnected": "WhatsApp 已连接!",- "whatsappConnectedDescription": "您的 WhatsApp 已连接。您可以通过发送消息与 Jan 聊天。",- "connectionFailed": "连接失败",- "unknownError": "发生未知错误",- "back": "返回",- "refreshQrCode": "刷新二维码",- "tryAgain": "重试",- "startSetup": "开始设置",- "connecting": "连接中..."- }- }+ "backendInstallError": "后端安装失败"}diff --git a/web-app/src/locales/zh-TW/common.json b/web-app/src/locales/zh-TW/common.jsonindex d7c5f351d..9a146606e 100644--- a/web-app/src/locales/zh-TW/common.json+++ b/web-app/src/locales/zh-TW/common.json@@ -18,7 +18,6 @@"newChat": "新聊天","newAgentChat": "新智能體聊天","chats": "聊天",- "openclawAgent": "OpenClaw 智能體","favorites": "我的最愛","recents": "最近","hub": "中心",diff --git a/web-app/src/locales/zh-TW/settings.json b/web-app/src/locales/zh-TW/settings.jsonindex a4edda097..f2d52dcae 100644--- a/web-app/src/locales/zh-TW/settings.json+++ b/web-app/src/locales/zh-TW/settings.json@@ -274,175 +274,5 @@"updateError": "更新 Llamacpp 失敗"},"backendInstallSuccess": "後端安裝成功",- "backendInstallError": "後端安裝失敗",- "remoteAccess": {- "title": "遠端存取",- "running": "遠端存取正在執行",- "stopped": "遠端存取已停止",- "urlCopied": "連結已複製到剪貼簿",- "port": "連接埠",- "runtimeVersion": "執行階段版本",- "openclawVersion": "OpenClaw 版本",- "openclawIntegration": "OpenClaw 整合",- "enableRemoteAccess": "啟用 OpenClaw",- "disableRemoteAccess": "停用 OpenClaw",- "settings": "設定",- "install": "安裝",- "start": "啟動",- "stop": "停止",- "startError": "無法啟動遠端存取。請重試。",- "stopError": "無法停止遠端存取。請重試。",- "nodeRequired": "需要 Node.js 22+。請先安裝。",- "portInUse": "連接埠 18789 已被佔用。請關閉佔用該連接埠的其他應用。",- "telegram": "Telegram",- "whatsapp": "WhatsApp",- "channels": "頻道",- "runtimeMode": "執行模式",- "dockerSandbox": "Docker 容器",- "directProcess": "直接程序",- "securityAdvisory": "OpenClaw 正在無沙箱隔離的環境下執行。為了更好的安全性,請安裝並開啟 Docker Desktop,然後重新啟動 OpenClaw 以在容器中執行。",- "logViewer": "沙箱日誌",- "noLogs": "暫無日誌",- "copyLogs": "全部複製",- "downloadLogs": "下載",- "restartSandbox": "重新啟動沙箱",- "restarting": "正在重新啟動沙箱...",- "localNetworkOnly": "僅限本地網路",- "notConfigured": "未設定",- "publicAccess": "公開存取",- "tunnelUrl": "隧道 URL",- "copyUrl": "複製 URL",- "openUrl": "開啟 URL",- "activeTunnel": "活躍隧道",- "openclawFolder": "OpenClaw Folder",- "openclawFolderDesc": "編輯 Soul.md、User.md 及其他設定檔",- "gatewayUrl": "OpenClaw Dashboard",- "gatewayUrlDesc": "開啟網頁控制台",- "addChannel": {- "title": "新增頻道",- "description": "選擇要連接的訊息平台",- "cancel": "取消",- "continue": "繼續"- },- "channelDescriptions": {- "telegram": "透過 Telegram 機器人連接以實現安全訊息傳遞",- "whatsapp": "透過 WhatsApp 連接以實現商業訊息傳遞"- },- "connected": "已連接",- "notConnected": "未連接",- "manage": "管理",- "disconnect": "斷開",- "channelDisconnected": "{{channel}} 已斷開",- "disconnectError": "無法斷開連接。請重試。",- "channelNotConnected": "點擊設定連接 {{channel}}",- "copiedToClipboard": "已複製到剪貼簿",- "tailscaleSettings": {- "serveEnabled": "Tailscale Serve 已啟用",- "serveDisabled": "Tailscale Serve 已停用",- "funnelEnabled": "Tailscale Funnel 已啟用 - 您的端點現在可公開存取",- "funnelDisabled": "Tailscale Funnel 已停用",- "serveError": "設定 Tailscale Serve 失敗",- "funnelError": "設定 Tailscale Funnel 失敗",- "urlCopied": "URL 已複製到剪貼簿"- },- "telegramWizard": {- "title": "連接 Telegram",- "description": "設定 Telegram 以遠端與 Jan 聊天",- "step1": {- "title": "建立機器人",- "instruction1": "開啟 Telegram 並搜尋 @BotFather",- "instruction2": "傳送 /newbot 建立新機器人",- "instruction3": "依照提示為機器人命名",- "instruction4": "複製機器人權杖(格式如:123456789:ABCdefGHI...)"- },- "step2": {- "title": "輸入權杖",- "placeholder": "在此貼上機器人權杖",- "validate": "驗證權杖",- "validating": "驗證中...",- "invalidToken": "權杖無效。請檢查後重試。",- "validToken": "權杖已驗證!機器人:@{{username}}"- },- "step3": {- "title": "設定並啟動",- "connecting": "正在設定 Telegram 頻道...",- "success": "Telegram 頻道設定成功!",- "error": "Telegram 設定失敗:{{error}}"- },- "step4": {- "title": "配對您的裝置",- "instruction": "在 Telegram 上開啟您的機器人並傳送訊息。機器人將回覆配對碼——貼到下方以連接。",- "openBot": "在 Telegram 上開啟 @{{username}}",- "instruction1": "使用上方連結在 Telegram 上開啟您的機器人",- "instruction2": "按「開始」或向機器人傳送任意訊息",- "instruction3": "從機器人的回覆中複製配對碼並貼到下方",- "codeLabel": "配對碼",- "codePlaceholder": "例如:ZNAV9KZ3",- "approve": "批准並連接",- "approving": "批准中...",- "approved": "裝置配對成功!",- "approveError": "配對批准失敗:{{error}}",- "codeRequired": "請輸入機器人訊息中的配對碼",- "notConnected": "頻道尚未連接。請確保 OpenClaw 閘道正在執行。",- "skipForNow": "暫時跳過",- "resetPairing": "沒有代碼?點擊重設並重新傳送 /start",- "resetSuccess": "配對碼已清除——請重新向機器人傳送 /start",- "resetError": "重設配對碼失敗"- },- "step5": {- "title": "已連接!",- "success": "Telegram 已連接!",- "instruction": "您現在可以透過向機器人傳送訊息來與 Jan 聊天。",- "botUsername": "您的機器人:@{{username}}",- "pairedUsers": "{{count}} 台裝置已配對"- },- "buttons": {- "next": "下一步",- "back": "返回",- "connect": "連接",- "cancel": "取消",- "done": "完成",- "retry": "重試",- "disconnect": "斷開"- },- "status": {- "notConnected": "未連接",- "connected": "已連接",- "connecting": "連接中..."- },- "errors": {- "networkError": "網路錯誤。請檢查您的連線。",- "tokenRequired": "請輸入機器人權杖",- "configError": "儲存設定失敗"- }- },- "whatsappWizard": {- "setupTitle": "WhatsApp 設定",- "setupDescription": "連接您的 WhatsApp 帳戶以啟用遠端訊息",- "howItWorks": "運作方式",- "whatsappStep1": "點擊「開始設定」——我們將自動設定一切",- "whatsappStep2": "用 WhatsApp 應用掃描 QR 碼",- "whatsappStep3": "從手機開始與 Jan 聊天!",- "settingUp": "設定中...",- "settingUpDescription": "正在設定 OpenClaw 並準備 WhatsApp 連線。請稍候...",- "checkingOpenClaw": "檢查 OpenClaw 安裝",- "configuringGateway": "設定閘道連線",- "enablingWhatsApp": "啟用 WhatsApp 頻道",- "scanQrCode": "掃描 QR 碼",- "qrCodeInstructions": "在手機上開啟 WhatsApp 並掃描此 QR 碼",- "generatingQrCode": "正在產生 QR 碼...",- "waitingForScan": "等待掃描...",- "verifyingConnection": "驗證連線",- "pleaseWait": "請稍候,我們正在驗證您的連線",- "whatsappConnected": "WhatsApp 已連接!",- "whatsappConnectedDescription": "您的 WhatsApp 已連接。您可以透過傳送訊息與 Jan 聊天。",- "connectionFailed": "連線失敗",- "unknownError": "發生未知錯誤",- "back": "返回",- "refreshQrCode": "重新整理 QR 碼",- "tryAgain": "重試",- "startSetup": "開始設定",- "connecting": "連接中..."- }- }+ "backendInstallError": "後端安裝失敗"}diff --git a/web-app/src/routeTree.gen.ts b/web-app/src/routeTree.gen.tsindex c41183e20..eaf300218 100644--- a/web-app/src/routeTree.gen.ts+++ b/web-app/src/routeTree.gen.ts@@ -15,7 +15,6 @@ import { Route as IndexRouteImport } from './routes/index'import { Route as HubIndexRouteImport } from './routes/hub/index'import { Route as ThreadsThreadIdRouteImport } from './routes/threads/$threadId'import { Route as SettingsShortcutsRouteImport } from './routes/settings/shortcuts'-import { Route as SettingsRemoteAccessRouteImport } from './routes/settings/remote-access'import { Route as SettingsPrivacyRouteImport } from './routes/settings/privacy'import { Route as SettingsMcpServersRouteImport } from './routes/settings/mcp-servers'import { Route as SettingsLocalApiServerRouteImport } from './routes/settings/local-api-server'@@ -63,11 +62,6 @@ const SettingsShortcutsRoute = SettingsShortcutsRouteImport.update({path: '/settings/shortcuts',getParentRoute: () => rootRouteImport,} as any)-const SettingsRemoteAccessRoute = SettingsRemoteAccessRouteImport.update({- id: '/settings/remote-access',- path: '/settings/remote-access',- getParentRoute: () => rootRouteImport,-} as any)const SettingsPrivacyRoute = SettingsPrivacyRouteImport.update({id: '/settings/privacy',path: '/settings/privacy',@@ -168,7 +162,6 @@ export interface FileRoutesByFullPath {'/settings/local-api-server': typeof SettingsLocalApiServerRoute'/settings/mcp-servers': typeof SettingsMcpServersRoute'/settings/privacy': typeof SettingsPrivacyRoute- '/settings/remote-access': typeof SettingsRemoteAccessRoute'/settings/shortcuts': typeof SettingsShortcutsRoute'/threads/$threadId': typeof ThreadsThreadIdRoute'/hub/': typeof HubIndexRoute@@ -193,7 +186,6 @@ export interface FileRoutesByTo {'/settings/local-api-server': typeof SettingsLocalApiServerRoute'/settings/mcp-servers': typeof SettingsMcpServersRoute'/settings/privacy': typeof SettingsPrivacyRoute- '/settings/remote-access': typeof SettingsRemoteAccessRoute'/settings/shortcuts': typeof SettingsShortcutsRoute'/threads/$threadId': typeof ThreadsThreadIdRoute'/hub': typeof HubIndexRoute@@ -219,7 +211,6 @@ export interface FileRoutesById {'/settings/local-api-server': typeof SettingsLocalApiServerRoute'/settings/mcp-servers': typeof SettingsMcpServersRoute'/settings/privacy': typeof SettingsPrivacyRoute- '/settings/remote-access': typeof SettingsRemoteAccessRoute'/settings/shortcuts': typeof SettingsShortcutsRoute'/threads/$threadId': typeof ThreadsThreadIdRoute'/hub/': typeof HubIndexRoute@@ -246,7 +237,6 @@ export interface FileRouteTypes {| '/settings/local-api-server'| '/settings/mcp-servers'| '/settings/privacy'- | '/settings/remote-access'| '/settings/shortcuts'| '/threads/$threadId'| '/hub/'@@ -271,7 +261,6 @@ export interface FileRouteTypes {| '/settings/local-api-server'| '/settings/mcp-servers'| '/settings/privacy'- | '/settings/remote-access'| '/settings/shortcuts'| '/threads/$threadId'| '/hub'@@ -296,7 +285,6 @@ export interface FileRouteTypes {| '/settings/local-api-server'| '/settings/mcp-servers'| '/settings/privacy'- | '/settings/remote-access'| '/settings/shortcuts'| '/threads/$threadId'| '/hub/'@@ -322,7 +310,6 @@ export interface RootRouteChildren {SettingsLocalApiServerRoute: typeof SettingsLocalApiServerRouteSettingsMcpServersRoute: typeof SettingsMcpServersRouteSettingsPrivacyRoute: typeof SettingsPrivacyRoute- SettingsRemoteAccessRoute: typeof SettingsRemoteAccessRouteSettingsShortcutsRoute: typeof SettingsShortcutsRouteThreadsThreadIdRoute: typeof ThreadsThreadIdRouteHubIndexRoute: typeof HubIndexRoute@@ -374,13 +361,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SettingsShortcutsRouteImportparentRoute: typeof rootRouteImport}- '/settings/remote-access': {- id: '/settings/remote-access'- path: '/settings/remote-access'- fullPath: '/settings/remote-access'- preLoaderRoute: typeof SettingsRemoteAccessRouteImport- parentRoute: typeof rootRouteImport- }'/settings/privacy': {id: '/settings/privacy'path: '/settings/privacy'@@ -514,7 +494,6 @@ const rootRouteChildren: RootRouteChildren = {SettingsLocalApiServerRoute: SettingsLocalApiServerRoute,SettingsMcpServersRoute: SettingsMcpServersRoute,SettingsPrivacyRoute: SettingsPrivacyRoute,- SettingsRemoteAccessRoute: SettingsRemoteAccessRoute,SettingsShortcutsRoute: SettingsShortcutsRoute,ThreadsThreadIdRoute: ThreadsThreadIdRoute,HubIndexRoute: HubIndexRoute,diff --git a/web-app/src/routes/settings/remote-access.tsx b/web-app/src/routes/settings/remote-access.tsxdeleted file mode 100644index bd43fdf47..000000000--- a/web-app/src/routes/settings/remote-access.tsx+++ /dev/null@@ -1,540 +0,0 @@-import { createFileRoute } from '@tanstack/react-router'-import { route } from '@/constants/routes'-import SettingsMenu from '@/containers/SettingsMenu'-import HeaderPage from '@/containers/HeaderPage'-import { Button } from '@/components/ui/button'-import { Card, CardItem } from '@/containers/Card'-import { TelegramWizard as TelegramWizardDialog } from '@/containers/dialogs/TelegramWizardDialog'-import { WhatsAppWizardDialog } from '@/containers/dialogs/WhatsAppWizardDialog'-import { TailscaleSetupDialog } from '@/containers/dialogs/TailscaleSetupDialog'-import { SecurityConfigDialog } from '@/containers/dialogs/SecurityConfigDialog'-import { TunnelSelectionDialog } from '@/containers/dialogs/TunnelSelectionDialog'-import { EnableProgressDialog } from '@/containers/dialogs/EnableProgressDialog'-import { SandboxLogsDialog } from '@/containers/dialogs/SandboxLogsDialog'-import { ChannelCard } from '@/containers/ChannelCard'-import { useTranslation } from '@/i18n/react-i18next-compat'-import { useEffect, useState, useCallback } from 'react'-import { invoke } from '@tauri-apps/api/core'-import { useModelProvider } from '@/hooks/useModelProvider'-import { getLastUsedModel } from '@/utils/getModelToStart'-import { isLocalProvider } from '@/lib/utils'-import { toast } from 'sonner'-import { setOpenClawRunningState } from '@/utils/openclaw'-import {- IconLoader2,- IconCopy,- IconExternalLink,- IconFileText,- IconAlertTriangle,- IconFolder,-} from '@tabler/icons-react'-import type {- ChannelType,- TelegramConfig,- WhatsAppConfig,- OpenClawStatus,- TunnelProvider,- TunnelProvidersStatus,- SecurityStatus,-} from '@/types/openclaw'--// eslint-disable-next-line @typescript-eslint/no-explicit-any-export const Route = createFileRoute(route.settings.remote_access as any)({- component: RemoteAccess,-})--// const OPENCLAW_PORT = 18789--function RemoteAccess() {- const { t } = useTranslation()- const { selectedModel, providers, selectModelProvider } = useModelProvider()- const firstAvailableModel = providers- .filter((p) => isLocalProvider(p.provider) || !!p.api_key)- .flatMap((p) => p.models.map((m) => ({ provider: p.provider, model: m })))- .at(0)- const hasAnyModel = firstAvailableModel !== undefined-- const handleStartEnable = useCallback(() => {- if (!selectedModel) {- const lastUsed = getLastUsedModel()- const lastUsedExists = lastUsed && providers.some(- (p) =>- p.provider === lastUsed.provider &&- (isLocalProvider(p.provider) || !!p.api_key) &&- p.models.some((m) => m.id === lastUsed.model)- )- if (lastUsedExists) {- selectModelProvider(lastUsed!.provider, lastUsed!.model)- } else if (firstAvailableModel) {- selectModelProvider(firstAvailableModel.provider, firstAvailableModel.model.id)- }- }- setIsEnableDialogOpen(true)- }, [selectedModel, providers, firstAvailableModel, selectModelProvider])-- const [status, setStatus] = useState<OpenClawStatus | null>(null)- const [isStopping, setIsStopping] = useState(false)- const [disconnectingChannel, setDisconnectingChannel] = useState<ChannelType | null>(null)- const [isTelegramWizardOpen, setIsTelegramWizardOpen] = useState(false)- const [isWhatsAppWizardOpen, setIsWhatsAppWizardOpen] = useState(false)- const [isTailscaleDialogOpen, setIsTailscaleDialogOpen] = useState(false)- const [isSecurityDialogOpen, setIsSecurityDialogOpen] = useState(false)- const [isTunnelDialogOpen, setIsTunnelDialogOpen] = useState(false)- const [isEnableDialogOpen, setIsEnableDialogOpen] = useState(false)- const [isLogsDialogOpen, setIsLogsDialogOpen] = useState(false)- const [tunnelStatus, setTunnelStatus] = useState<TunnelProvidersStatus | null>(null)- const [, setSecurityStatus] = useState<SecurityStatus | null>(null)- const [telegramConfig, setTelegramConfig] = useState<TelegramConfig | null>(null)- const [whatsappConfig, setWhatsAppConfig] = useState<WhatsAppConfig | null>(null)- const [gatewayToken, setGatewayToken] = useState<string>('')- const [gatewayPort, setGatewayPort] = useState<number>(18789)-- const fetchStatus = useCallback(async () => {- try {- const statusData = await invoke<OpenClawStatus>('openclaw_status')- setStatus(statusData)-- // Ensure Jan's origin is configured when OpenClaw was started externally- if (statusData.running) {- await invoke('openclaw_ensure_jan_origin').catch(() => { })- }- } catch {- toast.error(t('settings:remoteAccess.startError'))- }- }, [t])-- const fetchTelegramConfig = useCallback(async () => {- try {- const config = await invoke<TelegramConfig>('telegram_get_config')- setTelegramConfig(config)- } catch {- // Telegram may not be configured yet- }- }, [])-- const fetchWhatsAppConfig = useCallback(async () => {- try {- const config = await invoke<WhatsAppConfig>('whatsapp_get_config')- setWhatsAppConfig(config)- } catch {- // WhatsApp may not be configured yet- }- }, [])-- const fetchTunnelStatus = useCallback(async () => {- try {- const tunnelData = await invoke<TunnelProvidersStatus>('tunnel_get_providers')- setTunnelStatus(tunnelData)- } catch {- // Tunnel providers may not be available- }- }, [])-- const fetchSecurityStatus = useCallback(async () => {- try {- const securityData = await invoke<SecurityStatus>('security_get_status')- setSecurityStatus(securityData)- } catch {- // Security config may not be available- }- }, [])-- useEffect(() => {- fetchStatus()- fetchTelegramConfig()- fetchWhatsAppConfig()- fetchTunnelStatus()- fetchSecurityStatus()- }, [fetchStatus, fetchTelegramConfig, fetchWhatsAppConfig, fetchTunnelStatus, fetchSecurityStatus])-- const refreshAllStatus = useCallback(async () => {- await Promise.all([fetchStatus(), fetchTunnelStatus(), fetchSecurityStatus()])- }, [fetchStatus, fetchTunnelStatus, fetchSecurityStatus])-- const handleCopyUrl = useCallback((url: string) => {- navigator.clipboard.writeText(url)- toast.success(t('settings:remoteAccess.urlCopied'))- }, [t])-- const getTunnelProviderName = (provider: TunnelProvider): string => {- switch (provider) {- case 'tailscale': return 'Tailscale'- case 'ngrok': return 'ngrok'- case 'cloudflare': return 'Cloudflare Tunnel'- case 'localonly': return t('settings:remoteAccess.localNetworkOnly')- default: return t('settings:remoteAccess.notConfigured')- }- }-- const handleStop = async () => {- try {- setIsStopping(true)- await invoke('openclaw_stop')- setOpenClawRunningState(false)- setStatus((prev) => prev ? { ...prev, running: false } : prev)- toast.success(t('settings:remoteAccess.stopped'))- } catch {- toast.error(t('settings:remoteAccess.stopError'))- } finally {- setIsStopping(false)- }- }-- const getChannelName = (channel: string): string => {- switch (channel) {- case 'telegram': return t('settings:remoteAccess.telegram')- case 'whatsapp': return t('settings:remoteAccess.whatsapp')- default: return channel- }- }-- const handleAddChannel = (channel: ChannelType) => {- switch (channel) {- case 'telegram': setIsTelegramWizardOpen(true); break- case 'whatsapp': setIsWhatsAppWizardOpen(true); break- }- }-- const handleDisconnectChannel = async (channel: ChannelType) => {- setDisconnectingChannel(channel)- try {- switch (channel) {- case 'telegram':- await invoke('telegram_disconnect')- setTelegramConfig(null)- break- case 'whatsapp':- await invoke('whatsapp_disconnect')- setWhatsAppConfig(null)- break- }- toast.success(- t('settings:remoteAccess.channelDisconnected', { channel: getChannelName(channel) })- )- } catch {- toast.error(t('settings:remoteAccess.disconnectError'))- } finally {- setDisconnectingChannel(null)- }- }-- const isRunning = status?.running ?? false- const isInstalled = status?.installed ?? false-- useEffect(() => {- if (isRunning) {- invoke<string>('openclaw_get_auth_token').then(setGatewayToken).catch(() => { })- invoke<{ gateway: { port: number } }>('openclaw_get_config').then((c) => setGatewayPort(c.gateway.port)).catch(() => { })- }- }, [isRunning])-- return (- <div className="flex flex-col h-svh w-full">- <HeaderPage>- <div className="flex items-center gap-2 w-full">- <span className="font-medium text-base font-studio">- {t('common:settings')}- </span>- </div>- </HeaderPage>- <div className="flex h-[calc(100%-60px)]">- <SettingsMenu />- <div className="p-4 pt-0 w-full overflow-y-auto">- <div className="flex flex-col justify-between gap-4 gap-y-3 w-full">- {/* Status Card */}- {/* <Card title={t('settings:remoteAccess.title')}>- <CardItem- title={t('settings:remoteAccess.status')}- actions={- <div className="flex items-center gap-2">- <div- className={cn("size-2 rounded-full",- isRunning ? 'bg-green-500' : 'bg-red-500'- )}- />- <span className="text-foreground font-medium">- {isRunning- ? t('settings:remoteAccess.enabled')- : t('settings:remoteAccess.disabled')}- </span>- </div>- }- />- <CardItem- title={t('settings:remoteAccess.activeChannels')}- actions={- <span className="text-foreground">- {isRunning && getConnectedChannels().length > 0- ? getConnectedChannels()- .map((ch) => getChannelName(ch))- .join(', ')- : '-'}- </span>- }- />- <CardItem- title={t('settings:remoteAccess.connectedUsers')}- actions={- <span className="text-foreground">- {isRunning- ? String(- (telegramConfig?.paired_users ?? 0) +- (whatsappConfig?.contacts_count ?? 0)- )- : '0'}- </span>- }- />- <CardItem- title={t('settings:remoteAccess.port')}- actions={<span className="text-foreground">{OPENCLAW_PORT}</span>}- />- {status?.runtime_version && (- <CardItem- title={t('settings:remoteAccess.runtimeVersion')}- actions={<span className="text-foreground">{status.runtime_version}</span>}- />- )}- {status?.openclaw_version && (- <CardItem- title={t('settings:remoteAccess.openclawVersion')}- actions={<span className="text-foreground">{status.openclaw_version}</span>}- />- )}- </Card> */}-- <Card title={t('settings:remoteAccess.openclawIntegration')}>- <CardItem- title={- isRunning- ? t('settings:remoteAccess.disableRemoteAccess')- : t('settings:remoteAccess.enableRemoteAccess')- }- actions={- <div className="flex items-center gap-2">- {isRunning ? (- <Button- variant="destructive"- size="sm"- onClick={handleStop}- disabled={isStopping}- >- {isStopping && <IconLoader2 className="animate-spin size-4" />}- {t('settings:remoteAccess.stop')}- </Button>- ) : (- <Button size="sm" onClick={handleStartEnable} disabled={!hasAnyModel}>- {t('settings:remoteAccess.start')}- </Button>- )}- </div>- }- description={!isRunning && !hasAnyModel ? t('settings:remoteAccess.noModelAvailable') : undefined}- />-- {!isRunning && (- <p className="text-sm text-muted-foreground px-1">- {t('settings:remoteAccess.nodejsPrerequisite')}- </p>- )}-- {isRunning && status?.sandbox_type && (- <CardItem- title={t('settings:remoteAccess.runtimeMode')}- actions={- <div className="flex items-center gap-2">- <span className="text-foreground text-sm">- {status.isolation_tier === 'full_container'- ? t('settings:remoteAccess.dockerSandbox')- : t('settings:remoteAccess.directProcess')}- </span>- {status.isolation_tier === 'full_container' && (- <Button- variant="ghost"- size="icon-sm"- onClick={() => setIsLogsDialogOpen(true)}- title={t('settings:viewLogs')}- >- <IconFileText className="h-4 w-4" />- </Button>- )}- </div>- }- />- )}-- {/* Security Advisory - show when no sandbox (Tier 0) */}- {isRunning && (!status?.isolation_tier || status.isolation_tier === 'none') && (- <div className="flex items-start gap-2 rounded-md border border-yellow-500/30 bg-yellow-500/10 p-3">- <IconAlertTriangle className="h-5 w-5 text-yellow-500 shrink-0 mt-0.5" />- <p className="text-sm text-yellow-600 dark:text-yellow-400">- {t('settings:remoteAccess.securityAdvisory')}- </p>- </div>- )}-- {isRunning && (<CardItem- title={t('settings:remoteAccess.openclawFolder')}- description={t('settings:remoteAccess.openclawFolderDesc')}- actions={- <Button- variant="ghost"- size="icon-sm"- onClick={async () => {- const dir = await invoke<string>('openclaw_get_config_dir')- await invoke('open_file_explorer', { path: dir })- }}- title={t('settings:remoteAccess.openclawFolder')}- >- <IconFolder className="h-4 w-4" />- </Button>- }- />- )}-- {isRunning && (- <CardItem- title={t('settings:remoteAccess.gatewayUrl')}- description={t('settings:remoteAccess.gatewayUrlDesc')}- actions={- <div className="flex items-center gap-2">- <code className="text-sm font-mono text-foreground bg-secondary px-2 py-1 rounded">- {gatewayToken- ? `http://localhost:${gatewayPort}?token=****`- : `http://localhost:${gatewayPort}`}- </code>- <Button- variant="ghost"- size="icon-sm"- onClick={() => handleCopyUrl(gatewayToken ? `http://localhost:${gatewayPort}?token=${gatewayToken}` : `http://localhost:${gatewayPort}`)}- title={t('settings:remoteAccess.copyUrl')}- >- <IconCopy className="h-4 w-4" />- </Button>- <a- href={gatewayToken ? `http://localhost:${gatewayPort}?token=${gatewayToken}` : `http://localhost:${gatewayPort}`}- target="_blank"- rel="noopener noreferrer"- title={t('settings:remoteAccess.openUrl')}- className="inline-flex items-center justify-center h-7 w-7 rounded-md hover:bg-accent transition-colors"- >- <IconExternalLink className="h-4 w-4" />- </a>- </div>- }- />- )}-- <div className="space-y-3 mt-4">- <p className='text-foreground font-medium mb-2'>{t('settings:remoteAccess.channels')}</p>- <ChannelCard- type="telegram"- config={telegramConfig}- onSettings={() => handleAddChannel('telegram')}- onDisconnect={() => handleDisconnectChannel('telegram')}- OCIsInstalled={isInstalled}- isDisconnecting={disconnectingChannel === 'telegram'}- />- <ChannelCard- type="whatsapp"- config={whatsappConfig}- onSettings={() => handleAddChannel('whatsapp')}- onDisconnect={() => handleDisconnectChannel('whatsapp')}- OCIsInstalled={isInstalled}- isDisconnecting={disconnectingChannel === 'whatsapp'}- />- </div>- </Card>-- {tunnelStatus?.active_tunnel && (- <Card title={t('settings:remoteAccess.activeTunnel')}>- <div className="flex items-center gap-3 mb-4">- <div className="w-3 h-3 rounded-full bg-green-500 animate-pulse" />- <span className="text-foreground font-medium">- {getTunnelProviderName(tunnelStatus.active_tunnel.provider)}- </span>- {tunnelStatus.active_tunnel.is_public && (- <span className="text-xs px-2 py-0.5 rounded-full bg-orange-500/10 text-orange-500 border border-orange-500/30">- {t('settings:remoteAccess.publicAccess')}- </span>- )}- </div>- <CardItem- title={t('settings:remoteAccess.tunnelUrl')}- actions={- <div className="flex items-center gap-2">- <code className="text-sm font-mono text-foreground bg-secondary px-2 py-1 rounded max-w-[200px] truncate">- {tunnelStatus.active_tunnel.url}- </code>- <Button- variant="ghost"- size="icon-sm"- onClick={() => handleCopyUrl(tunnelStatus.active_tunnel!.url)}- title={t('settings:remoteAccess.copyUrl')}- >- <IconCopy className="h-4 w-4" />- </Button>- <Button- variant="ghost"- size="icon-sm"- onClick={() => window.open(tunnelStatus.active_tunnel!.url, '_blank')}- title={t('settings:remoteAccess.openUrl')}- >- <IconExternalLink className="h-4 w-4" />- </Button>- </div>- }- />- <CardItem- title={t('settings:remoteAccess.port')}- actions={- <span className="text-foreground">{tunnelStatus.active_tunnel.port}</span>- }- />- </Card>- )}- </div>- </div>- </div>-- <TelegramWizardDialog- isOpen={isTelegramWizardOpen}- onOpenChange={setIsTelegramWizardOpen}- onConnected={setTelegramConfig}- />- <WhatsAppWizardDialog- isOpen={isWhatsAppWizardOpen}- onOpenChange={setIsWhatsAppWizardOpen}- onConnected={setWhatsAppConfig}- />- <TailscaleSetupDialog- isOpen={isTailscaleDialogOpen}- onClose={() => setIsTailscaleDialogOpen(false)}- onSuccess={refreshAllStatus}- />- <SecurityConfigDialog- isOpen={isSecurityDialogOpen}- onClose={() => setIsSecurityDialogOpen(false)}- onSave={refreshAllStatus}- />- <TunnelSelectionDialog- isOpen={isTunnelDialogOpen}- onClose={() => setIsTunnelDialogOpen(false)}- onTailscaleSetup={() => {- setIsTunnelDialogOpen(false)- setIsTailscaleDialogOpen(true)- }}- onSave={refreshAllStatus}- />- <EnableProgressDialog- isOpen={isEnableDialogOpen}- onOpenChange={setIsEnableDialogOpen}- onSuccess={fetchStatus}- />- <SandboxLogsDialog- isOpen={isLogsDialogOpen}- onOpenChange={setIsLogsDialogOpen}- />- </div>- )-}diff --git a/web-app/src/types/openclaw.ts b/web-app/src/types/openclaw.tsdeleted file mode 100644index d40768e3a..000000000--- a/web-app/src/types/openclaw.ts+++ /dev/null@@ -1,63 +0,0 @@-/**- * Shared types for the OpenClaw remote access integration.- * These mirror the Rust backend types in src-tauri/src/core/openclaw/models.rs.- */--export type ChannelType = 'telegram' | 'whatsapp'--export interface TelegramConfig {- bot_token: string- bot_username: string | null- connected: boolean- pairing_code: string | null- paired_users: number-}--export interface WhatsAppConfig {- account_id: string- session_path: string- connected: boolean- phone_number: string | null- qr_code: string | null- contacts_count: number-}--export type ChannelConfig = TelegramConfig | WhatsAppConfig--export interface OpenClawStatus {- installed: boolean- running: boolean- runtime_version: string | null- openclaw_version: string | null- port_available: boolean- error: string | null- sandbox_type?: string | null- isolation_tier?: string | null-}--export type TunnelProvider = 'none' | 'tailscale' | 'ngrok' | 'cloudflare' | 'localonly'--export interface TunnelInfo {- provider: TunnelProvider- url: string- started_at: string- port: number- is_public: boolean-}--export interface TunnelProvidersStatus {- tailscale: { installed: boolean; authenticated: boolean; version: string | null }- ngrok: { installed: boolean; authenticated: boolean; version: string | null }- cloudflare: { installed: boolean; authenticated: boolean; version: string | null }- active_provider: TunnelProvider- active_tunnel: TunnelInfo | null-}--export interface SecurityStatus {- auth_mode: 'token' | 'password' | 'none'- has_token: boolean- has_password: boolean- require_pairing: boolean- approved_device_count: number- recent_auth_failures: number-}diff --git a/web-app/src/utils/openclaw.ts b/web-app/src/utils/openclaw.tsdeleted file mode 100644index 164f48de1..000000000--- a/web-app/src/utils/openclaw.ts+++ /dev/null@@ -1,195 +0,0 @@-import { invoke } from '@tauri-apps/api/core'-import { useAgentMode } from '@/hooks/useAgentMode'-import { useAppState } from '@/hooks/useAppState'--/** OpenClaw gateway base URL for the OpenAI-compatible HTTP API. */-export const OPENCLAW_GATEWAY_URL = 'http://127.0.0.1:18789/v1'--let openClawRunningCache: boolean | null = null-let lastCheckTime = 0-const CACHE_TTL_MS = 30_000--/** Check if OpenClaw is running, with a 30s cache to avoid excessive IPC calls. */-export async function isOpenClawRunning(forceRefresh = false): Promise<boolean> {- const now = Date.now()- if (!forceRefresh && openClawRunningCache !== null && (now - lastCheckTime) < CACHE_TTL_MS) {- return openClawRunningCache- }-- try {- const status = await invoke<{ running: boolean }>('openclaw_status')- openClawRunningCache = status.running- lastCheckTime = now- return status.running- } catch {- openClawRunningCache = false- lastCheckTime = now- return false- }-}--/** Update the running cache directly (called when user enables/disables OpenClaw). */-export function setOpenClawRunningState(isRunning: boolean): void {- openClawRunningCache = isRunning- lastCheckTime = Date.now()-- useAppState.getState().setOpenClawRunning(isRunning)-- // When OpenClaw is stopped, clear agent mode for all threads so the UI reverts- if (!isRunning) {- useAgentMode.getState().clearAll()- }-}--/** Clear the cache (e.g., on app startup). */-export function clearOpenClawCache(): void {- openClawRunningCache = null- lastCheckTime = 0-}--/** Get cached state without IPC. Returns null if stale. */-export function getOpenClawRunningCached(): boolean | null {- const now = Date.now()- if (openClawRunningCache !== null && (now - lastCheckTime) < CACHE_TTL_MS) {- return openClawRunningCache- }- return null-}--/**- * Sync the selected model to OpenClaw. Skips silently if OpenClaw is not running.- * Designed to have minimal impact on users who don't use OpenClaw.- */-export async function syncModelToOpenClaw(- modelId: string,- provider?: string,- modelName?: string-): Promise<void> {- try {- const cachedState = getOpenClawRunningCached()- if (cachedState === false) return-- const running = await isOpenClawRunning()- if (!running) return-- await invoke('openclaw_sync_model', {- modelId,- provider: provider || null,- modelName: modelName || null,- })- } catch {- // Background sync — fail silently- }-}--/**- * Bulk sync all models from Jan's provider store to OpenClaw.- * Called after Remote Access starts so OpenClaw knows the full catalog.- */-export async function syncAllModelsToOpenClaw(- providers: ModelProvider[],- selectedModelId?: string-): Promise<number> {- try {- const models: Array<{ modelId: string; provider: string; displayName: string; contextWindow?: number }> = []-- for (const provider of providers) {- if (!provider.active) continue- if (!provider.models || provider.models.length === 0) continue- for (const model of provider.models) {- const modelId = model.id ?? model.model- if (!modelId || typeof modelId !== 'string') continue- if (model.embedding) continue-- // Extract context window from Jan's model settings (ctx_len)- const ctxLenRaw = model.settings?.ctx_len?.controller_props?.value- const contextWindow = typeof ctxLenRaw === 'number' && ctxLenRaw > 0- ? ctxLenRaw- : typeof ctxLenRaw === 'string' && parseInt(ctxLenRaw) > 0- ? parseInt(ctxLenRaw)- : undefined-- models.push({- modelId,- provider: provider.provider,- displayName: model.displayName || model.name || modelId,- contextWindow,- })- }- }-- if (models.length === 0) return 0-- const result = await invoke<{ synced_count: number; default_model: string | null }>(- 'openclaw_sync_all_models',- { models, defaultModelId: selectedModelId || null }- )- return result.synced_count- } catch {- return 0- }-}--// --- Auth token -----let authTokenCache: string | null = null-let authTokenFetchTime = 0-const AUTH_TOKEN_CACHE_TTL = 60_000-let httpApiEnsured = false--/**- * Ensure the OpenClaw HTTP chat completions endpoint is enabled.- * Called once before first agent mode request; no-op after that.- * If the config was changed, restarts the gateway so it picks up the new setting.- */-export async function ensureOpenClawHttpApi(): Promise<void> {- if (httpApiEnsured) return- try {- const changed = await invoke<boolean>('openclaw_ensure_http_api')- if (changed) {- await invoke('openclaw_restart')- await new Promise((resolve) => setTimeout(resolve, 2000))- }- httpApiEnsured = true- } catch (error) {- throw new Error(- `Failed to initialize OpenClaw HTTP API: ${error instanceof Error ? error.message : String(error)}`- )- }-}--/** Get the OpenClaw gateway auth token, with a 60s cache. */-export async function getOpenClawAuthToken(forceRefresh = false): Promise<string | null> {- const now = Date.now()- if (!forceRefresh && authTokenCache && (now - authTokenFetchTime) < AUTH_TOKEN_CACHE_TTL) {- return authTokenCache- }- try {- const token = await invoke<string>('openclaw_get_auth_token')- authTokenCache = token- authTokenFetchTime = now- return token- } catch {- authTokenCache = null- return null- }-}--/** TCP-level gateway reachability check via Tauri IPC. Works on all platforms. */-export async function checkOpenClawGateway(): Promise<boolean> {- try {- return await invoke<boolean>('openclaw_check_gateway')- } catch {- return false- }-}--/** Get the currently configured model in OpenClaw. */-export async function getOpenClawModel(): Promise<string | null> {- try {- return await invoke<string>('openclaw_get_model')- } catch {- return null- }-}-diff --git a/yarn.lock b/yarn.lockindex cc2ba1284..20c9f26ed 100644--- a/yarn.lock+++ b/yarn.lock@@ -11176,11 +11176,11 @@ __metadata:languageName: nodelinkType: hard-"framer-motion@npm:^12.36.0":- version: 12.36.0- resolution: "framer-motion@npm:12.36.0"+"framer-motion@npm:^12.37.0":+ version: 12.37.0+ resolution: "framer-motion@npm:12.37.0"dependencies:- motion-dom: "npm:^12.36.0"+ motion-dom: "npm:^12.37.0"motion-utils: "npm:^12.36.0"tslib: "npm:^2.4.0"peerDependencies:@@ -11194,7 +11194,7 @@ __metadata:optional: truereact-dom:optional: true- checksum: 10c0/3acbb210d374ab80f4b086bcb8e7f722271f5d8e5d3e9f643ee0b5e7641bf34e100aaead68c99a4d478e67ccdda4b3ff89779bc0c9e5fe9aab8a955a5a6cfaa4+ checksum: 10c0/6bdf132876e5a323c60ba3930bf2d894338f6235d942b219cf3068b330ecc7c915d9b8ee6631f89ddcde7a4ba7373bad3abf40d19d2c882b186697cbe11ee311languageName: nodelinkType: hard@@ -15026,12 +15026,12 @@ __metadata:languageName: nodelinkType: hard-"motion-dom@npm:^12.36.0":- version: 12.36.0- resolution: "motion-dom@npm:12.36.0"+"motion-dom@npm:^12.37.0":+ version: 12.37.0+ resolution: "motion-dom@npm:12.37.0"dependencies:motion-utils: "npm:^12.36.0"- checksum: 10c0/7f97b1e310310b44e6144f7303604d7c3f37f1e278b41ac5b57dca2abe082213d40a9f59cf5a2cb3442d27b8fd82e29f17f31d7b24d4b240f9b908fc97b42d80+ checksum: 10c0/e3b2be1e6796658d021921fed8f5ce690b833c4ce5f63d0ca11c86b5520b35a626d29ef9d97bd8551bd946333c3d4ab159d95aae9951c92ce8733039560b4c0clanguageName: nodelinkType: hard@@ -15078,10 +15078,10 @@ __metadata:linkType: hard"motion@npm:^12.35.0":- version: 12.36.0- resolution: "motion@npm:12.36.0"+ version: 12.37.0+ resolution: "motion@npm:12.37.0"dependencies:- framer-motion: "npm:^12.36.0"+ framer-motion: "npm:^12.37.0"tslib: "npm:^2.4.0"peerDependencies:"@emotion/is-prop-valid": "*"@@ -15094,7 +15094,7 @@ __metadata:optional: truereact-dom:optional: true- checksum: 10c0/3ad56cbc4d7de107dc8e72c4e5738b885fa455224461ca1e68545e5e790b9d5e27f4b01a6d9129899ee7e214cff10247f7b9b6edff25d3ef5ed292b212ed95a6+ checksum: 10c0/e1bb6ebde3d25f7afb119a51df5b9bd531482e94a367e8a1b6cc67376714445276f1105f158fbb63ed506a33c622fdc7e2842d840792e06582863a114ff5c16flanguageName: nodelinkType: hard