diff --git a/README.md b/README.md index 504423bf..68f71ac4 100644 --- a/README.md +++ b/README.md @@ -383,6 +383,7 @@ codewhale resume --last # resume the most recent sessi codewhale resume # resume a specific session by UUID codewhale fork # fork a saved session into a sibling path codewhale serve --http # HTTP/SSE API server +codewhale serve --mobile # LAN mobile control page; token-gated by default codewhale serve --acp # ACP stdio adapter for Zed/custom agents codewhale run pr # fetch PR and pre-seed review prompt codewhale mcp list # list configured MCP servers @@ -577,7 +578,7 @@ without recreating skills the user deliberately deleted. | [PROVIDERS.md](docs/PROVIDERS.md) | Provider IDs, auth, model defaults, and capability metadata | | [MODES.md](docs/MODES.md) | Plan / Agent / YOLO modes | | [MCP.md](docs/MCP.md) | Model Context Protocol integration | -| [RUNTIME_API.md](docs/RUNTIME_API.md) | HTTP/SSE API server | +| [RUNTIME_API.md](docs/RUNTIME_API.md) | HTTP/SSE API server and mobile control page | | [INSTALL.md](docs/INSTALL.md) | Platform-specific install guide | | [DOCKER.md](docs/DOCKER.md) | GHCR image, volumes, and Docker usage | | [CNB_MIRROR.md](docs/CNB_MIRROR.md) | CNB mirror and China-friendly install notes | diff --git a/README.zh-CN.md b/README.zh-CN.md index c65fe4bc..93a848fd 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -322,6 +322,7 @@ codewhale resume --last # 恢复最近会话 codewhale resume # 按 UUID 恢复指定会话 codewhale fork # 将已保存会话分叉为兄弟路径 codewhale serve --http # HTTP/SSE API 服务 +codewhale serve --mobile # 局域网移动端控制页,默认启用 token 保护 codewhale serve --acp # Zed/自定义智能体的 ACP stdio 适配器 codewhale run pr # 获取 PR 并预填审查提示 codewhale mcp list # 列出已配置 MCP 服务器 @@ -501,7 +502,7 @@ description: 当 DeepSeek 需要遵循我的自定义工作流时使用这个技 | [CONFIGURATION.md](docs/CONFIGURATION.md) | 完整配置参考 | | [MODES.md](docs/MODES.md) | Plan / Agent / YOLO 模式 | | [MCP.md](docs/MCP.md) | Model Context Protocol 集成 | -| [RUNTIME_API.md](docs/RUNTIME_API.md) | HTTP/SSE API 服务 | +| [RUNTIME_API.md](docs/RUNTIME_API.md) | HTTP/SSE API 服务和移动端控制页 | | [INSTALL.md](docs/INSTALL.md) | 各平台安装指南 | | [DOCKER.md](docs/DOCKER.md) | GHCR 镜像、volume 和 Docker 用法 | | [CNB_MIRROR.md](docs/CNB_MIRROR.md) | CNB 镜像和中国大陆友好安装说明 | diff --git a/crates/tui/src/main.rs b/crates/tui/src/main.rs index 593a2f2f..539162ef 100644 --- a/crates/tui/src/main.rs +++ b/crates/tui/src/main.rs @@ -578,12 +578,15 @@ struct ServeArgs { /// Start runtime HTTP/SSE API server #[arg(long)] http: bool, + /// Start runtime HTTP/SSE API server with the built-in mobile control page + #[arg(long)] + mobile: bool, /// Start ACP server over stdio for editor clients such as Zed #[arg(long)] acp: bool, - /// Bind host for HTTP server (default localhost) - #[arg(long, default_value = "127.0.0.1")] - host: String, + /// Bind host for HTTP server (default localhost; --mobile defaults to 0.0.0.0) + #[arg(long)] + host: Option, /// Bind port for HTTP server #[arg(long, default_value_t = 7878)] port: u16, @@ -605,6 +608,44 @@ struct ServeArgs { insecure_no_auth: bool, } +#[derive(Debug, Clone, PartialEq, Eq)] +struct ServeBindHost { + host: String, + mobile_rebound_to_lan: bool, +} + +fn resolve_serve_bind_host(mobile: bool, host: Option) -> ServeBindHost { + match (mobile, host) { + (true, None) => ServeBindHost { + host: "0.0.0.0".to_string(), + mobile_rebound_to_lan: true, + }, + (_, Some(host)) => ServeBindHost { + host, + mobile_rebound_to_lan: false, + }, + (false, None) => ServeBindHost { + host: "127.0.0.1".to_string(), + mobile_rebound_to_lan: false, + }, + } +} + +fn validate_serve_mode_selection(mcp: bool, http: bool, mobile: bool, acp: bool) -> Result { + if http && mobile { + bail!("--http and --mobile are mutually exclusive; choose one"); + } + let http_selected = http || mobile; + let selected_modes = [mcp, http_selected, acp] + .into_iter() + .filter(|selected| *selected) + .count(); + if selected_modes != 1 { + bail!("Choose exactly one server mode: --mcp, --http/--mobile, or --acp"); + } + Ok(http_selected) +} + #[derive(Subcommand, Debug, Clone)] enum McpCommand { /// List configured MCP servers @@ -935,28 +976,30 @@ async fn main() -> Result<()> { let workspace = cli.workspace.clone().unwrap_or_else(|| { std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")) }); - let selected_modes = [args.mcp, args.http, args.acp] - .into_iter() - .filter(|selected| *selected) - .count(); - if selected_modes != 1 { - bail!("Choose exactly one server mode: --mcp, --http, or --acp"); - } + let http_selected = + validate_serve_mode_selection(args.mcp, args.http, args.mobile, args.acp)?; if args.mcp { tokio::task::block_in_place(|| mcp_server::run_mcp_server(workspace)) - } else if args.http { + } else if http_selected { let config = load_config_from_cli(&cli)?; let cors_origins = resolve_cors_origins(&config, &args.cors_origin); + let bind_host = resolve_serve_bind_host(args.mobile, args.host); + if bind_host.mobile_rebound_to_lan { + println!( + "WARNING: --mobile is binding to 0.0.0.0 so LAN devices can reach the mobile control page. Use --host 127.0.0.1 to keep mobile loopback-only." + ); + } runtime_api::run_http_server( config, workspace, runtime_api::RuntimeApiOptions { - host: args.host, + host: bind_host.host, port: args.port, workers: args.workers.clamp(1, 8), cors_origins, auth_token: args.auth_token, insecure_no_auth: args.insecure_no_auth, + mobile: args.mobile, }, ) .await @@ -5656,6 +5699,53 @@ async fn run_exec_agent( Ok(()) } +#[cfg(test)] +mod serve_bind_host_tests { + use super::*; + + #[test] + fn http_defaults_to_loopback() { + assert_eq!( + resolve_serve_bind_host(false, None), + ServeBindHost { + host: "127.0.0.1".to_string(), + mobile_rebound_to_lan: false, + } + ); + } + + #[test] + fn mobile_default_rebinds_to_lan_with_warning_flag() { + assert_eq!( + resolve_serve_bind_host(true, None), + ServeBindHost { + host: "0.0.0.0".to_string(), + mobile_rebound_to_lan: true, + } + ); + } + + #[test] + fn mobile_respects_explicit_loopback_host() { + assert_eq!( + resolve_serve_bind_host(true, Some("127.0.0.1".to_string())), + ServeBindHost { + host: "127.0.0.1".to_string(), + mobile_rebound_to_lan: false, + } + ); + } + + #[test] + fn http_and_mobile_are_mutually_exclusive() { + let err = validate_serve_mode_selection(false, true, true, false).unwrap_err(); + assert!( + err.to_string() + .contains("--http and --mobile are mutually exclusive") + ); + } +} + #[cfg(test)] mod doctor_endpoint_tests { use super::*; diff --git a/crates/tui/src/runtime_api.rs b/crates/tui/src/runtime_api.rs index e7311208..dfbeac2b 100644 --- a/crates/tui/src/runtime_api.rs +++ b/crates/tui/src/runtime_api.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use std::convert::Infallible; use std::fs; -use std::net::SocketAddr; +use std::net::{SocketAddr, UdpSocket}; use std::path::PathBuf; use std::process::Command; use std::sync::Arc; @@ -14,6 +14,7 @@ use async_stream::stream; use axum::extract::{Path, Query, Request, State}; use axum::http::{HeaderValue, Method, StatusCode, header}; use axum::middleware::{self, Next}; +use axum::response::Html; use axum::response::sse::{Event as SseEvent, KeepAlive, Sse}; use axum::response::{IntoResponse, Response}; use axum::routing::{get, post}; @@ -60,6 +61,7 @@ pub struct RuntimeApiState { auth_required: bool, bind_host: String, bind_port: u16, + mobile_enabled: bool, } #[derive(Debug, Clone)] @@ -78,6 +80,8 @@ pub struct RuntimeApiOptions { pub auth_token: Option, /// Allow `/v1/*` routes without auth when no token is configured. pub insecure_no_auth: bool, + /// Enables the built-in mobile control page at `/mobile`. + pub mobile: bool, } impl Default for RuntimeApiOptions { @@ -89,6 +93,7 @@ impl Default for RuntimeApiOptions { cors_origins: Vec::new(), auth_token: None, insecure_no_auth: false, + mobile: false, } } } @@ -442,6 +447,7 @@ pub async fn run_http_server( auth_required: auth_enabled, bind_host: options.host.clone(), bind_port: options.port, + mobile_enabled: options.mobile, }; let app = build_router(state); @@ -464,6 +470,9 @@ pub async fn run_http_server( } else { println!("Runtime API auth: disabled by explicit insecure mode."); } + if options.mobile { + print_mobile_urls(addr, runtime_token.as_deref(), auth_enabled); + } let is_loopback = options.host == "127.0.0.1" || options.host == "::1"; if is_loopback { println!("Security: this server is local-first. Do not expose it to untrusted networks."); @@ -552,6 +561,8 @@ pub fn build_router(state: RuntimeApiState) -> Router { Router::new() .route("/health", get(health)) + .route("/mobile", get(mobile_page)) + .route("/mobile/", get(mobile_page)) .route("/v1/runtime/info", get(runtime_info)) .merge(api_routes) .layer(cors_layer(&state.cors_origins)) @@ -566,8 +577,17 @@ async fn require_runtime_token( let Some(expected) = state.runtime_token.as_deref() else { return next.run(req).await; }; - let authorized = req - .headers() + let authorized = request_has_runtime_token(&req, expected); + + if authorized { + next.run(req).await + } else { + runtime_token_required_response() + } +} + +fn request_has_runtime_token(req: &Request, expected: &str) -> bool { + req.headers() .get(header::AUTHORIZATION) .and_then(|value| value.to_str().ok()) .and_then(|raw| raw.strip_prefix("Bearer ")) @@ -577,33 +597,127 @@ async fn require_runtime_token( .get("x-deepseek-runtime-token") .and_then(|value| value.to_str().ok()) .is_some_and(|token| token == expected) - || token_from_query(req.uri().query()).is_some_and(|token| token == expected); - - if authorized { - next.run(req).await - } else { - ( - StatusCode::UNAUTHORIZED, - Json(json!({ - "error": { - "message": "runtime API bearer token required", - "status": StatusCode::UNAUTHORIZED.as_u16(), - } - })), - ) - .into_response() - } + || token_from_query(req.uri().query()).is_some_and(|token| token == expected) } -fn token_from_query(query: Option<&str>) -> Option<&str> { +fn runtime_token_required_response() -> Response { + ( + StatusCode::UNAUTHORIZED, + Json(json!({ + "error": { + "message": "runtime API bearer token required", + "status": StatusCode::UNAUTHORIZED.as_u16(), + } + })), + ) + .into_response() +} + +fn token_from_query(query: Option<&str>) -> Option { query.and_then(|query| { query.split('&').find_map(|pair| { let (key, value) = pair.split_once('=')?; - (key == "token").then_some(value) + (key == "token") + .then(|| percent_decode_query_component(value)) + .flatten() }) }) } +fn percent_decode_query_component(value: &str) -> Option { + let bytes = value.as_bytes(); + let mut decoded = Vec::with_capacity(bytes.len()); + let mut index = 0; + while index < bytes.len() { + match bytes[index] { + b'%' => { + let hi = *bytes.get(index + 1)?; + let lo = *bytes.get(index + 2)?; + let hi = (hi as char).to_digit(16)? as u8; + let lo = (lo as char).to_digit(16)? as u8; + decoded.push((hi << 4) | lo); + index += 3; + } + b'+' => { + decoded.push(b' '); + index += 1; + } + byte => { + decoded.push(byte); + index += 1; + } + } + } + String::from_utf8(decoded).ok() +} + +async fn mobile_page(State(state): State, req: Request) -> Response { + if !state.mobile_enabled { + return ( + StatusCode::NOT_FOUND, + "mobile control is disabled; start with `codewhale serve --mobile`", + ) + .into_response(); + } + if let Some(expected) = state.runtime_token.as_deref() + && !request_has_runtime_token(&req, expected) + { + return runtime_token_required_response(); + } + Html(MOBILE_HTML).into_response() +} + +fn print_mobile_urls(addr: SocketAddr, token: Option<&str>, auth_enabled: bool) { + println!("Mobile control page enabled."); + let token_query = if auth_enabled { + token + .filter(|token| !token.trim().is_empty()) + .map(|token| format!("?token={}", url_query_component(token))) + .unwrap_or_default() + } else { + String::new() + }; + + let port = addr.port(); + if addr.ip().is_unspecified() { + println!(" Local: http://127.0.0.1:{port}/mobile{token_query}"); + if let Some(ip) = detect_lan_ip() { + println!(" LAN: http://{ip}:{port}/mobile{token_query}"); + } else { + println!( + " LAN: bind is 0.0.0.0; open http://:{port}/mobile{token_query}" + ); + } + } else { + println!(" URL: http://{addr}/mobile{token_query}"); + } + println!("Mobile security: use only on a trusted LAN/VPN; this server does not provide TLS."); +} + +fn url_query_component(value: &str) -> String { + let mut encoded = String::with_capacity(value.len()); + for byte in value.bytes() { + match byte { + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'.' | b'_' | b'~' => { + encoded.push(byte as char); + } + _ => { + use std::fmt::Write as _; + let _ = write!(encoded, "%{byte:02X}"); + } + } + } + encoded +} + +fn detect_lan_ip() -> Option { + let socket = UdpSocket::bind("0.0.0.0:0").ok()?; + // UDP connect only selects the outbound interface locally; no packet is sent. + socket.connect("10.255.255.255:1").ok()?; + let addr = socket.local_addr().ok()?; + Some(addr.ip().to_string()) +} + async fn health() -> Json { Json(HealthResponse { status: "ok", @@ -1644,6 +1758,8 @@ fn map_compat_stream_event(event: &crate::runtime_threads::RuntimeEventRecord) - } } "approval.required" => Some(sse_json("approval.required", payload.clone())), + "approval.decided" => Some(sse_json("approval.decided", payload.clone())), + "approval.timeout" => Some(sse_json("approval.timeout", payload.clone())), "sandbox.denied" => Some(sse_json("sandbox.denied", payload.clone())), "turn.completed" => { let usage = payload @@ -1824,6 +1940,8 @@ async fn get_usage( Ok(Json(json!(aggregation))) } +const MOBILE_HTML: &str = include_str!("runtime_mobile.html"); + /// Built-in dev origins always allowed by the runtime API (whalescale#255). const DEFAULT_CORS_ORIGINS: &[&str] = &[ "http://localhost:3000", @@ -2104,6 +2222,23 @@ mod tests { assert!(auth.token.is_some()); } + #[test] + fn url_query_component_percent_encodes_token() { + assert_eq!( + url_query_component("abc ABC+/?:=&%"), + "abc%20ABC%2B%2F%3F%3A%3D%26%25" + ); + } + + #[test] + fn token_from_query_decodes_percent_encoded_token() { + assert_eq!( + token_from_query(Some("since_seq=0&token=abc%20ABC%2B%2F%3F%3A%3D%26%25")), + Some("abc ABC+/?:=&%".to_string()) + ); + assert_eq!(token_from_query(Some("token=bad%ZZ")), None); + } + async fn spawn_test_server_with_root( root: PathBuf, sessions_dir: PathBuf, @@ -2127,6 +2262,21 @@ mod tests { SharedRuntimeThreadManager, tokio::task::JoinHandle<()>, )>, + > { + spawn_test_server_with_root_token_and_mobile(root, sessions_dir, runtime_token, false).await + } + + async fn spawn_test_server_with_root_token_and_mobile( + root: PathBuf, + sessions_dir: PathBuf, + runtime_token: Option, + mobile_enabled: bool, + ) -> Result< + Option<( + SocketAddr, + SharedRuntimeThreadManager, + tokio::task::JoinHandle<()>, + )>, > { fs::create_dir_all(&sessions_dir)?; let manager = TaskManager::start_with_executor( @@ -2189,6 +2339,7 @@ mod tests { auth_required, bind_host: "127.0.0.1".to_string(), bind_port: 0, + mobile_enabled, }; let app = build_router(state); let listener = match TcpListener::bind("127.0.0.1:0").await { @@ -3754,6 +3905,115 @@ mod tests { Ok(()) } + #[tokio::test] + async fn mobile_page_is_available_only_when_enabled() -> Result<()> { + let tmp = tempfile::tempdir()?; + let root = tmp.path().to_path_buf(); + let sessions_dir = root.join("sessions"); + let Some((addr, _runtime_threads, handle)) = spawn_test_server_with_root_token_and_mobile( + root.clone(), + sessions_dir.clone(), + None, + false, + ) + .await? + else { + return Ok(()); + }; + let client = reqwest::Client::new(); + let disabled = client.get(format!("http://{addr}/mobile")).send().await?; + assert_eq!(disabled.status(), StatusCode::NOT_FOUND); + handle.abort(); + + let Some((addr, _runtime_threads, handle)) = + spawn_test_server_with_root_token_and_mobile(root, sessions_dir, None, true).await? + else { + return Ok(()); + }; + let enabled = client + .get(format!("http://{addr}/mobile")) + .send() + .await? + .error_for_status()?; + let html = enabled.text().await?; + assert!(html.contains("CodeWhale Mobile")); + assert!(html.contains("/v1/approvals/")); + + handle.abort(); + Ok(()) + } + + #[tokio::test] + async fn mobile_page_requires_runtime_token_when_auth_enabled() -> Result<()> { + let tmp = tempfile::tempdir()?; + let root = tmp.path().to_path_buf(); + let sessions_dir = root.join("sessions"); + let token = "abc ABC+/?:=&%".to_string(); + let Some((addr, _runtime_threads, handle)) = spawn_test_server_with_root_token_and_mobile( + root, + sessions_dir, + Some(token.clone()), + true, + ) + .await? + else { + return Ok(()); + }; + let client = reqwest::Client::new(); + + let unauthorized = client.get(format!("http://{addr}/mobile")).send().await?; + assert_eq!(unauthorized.status(), StatusCode::UNAUTHORIZED); + + let encoded = url_query_component(&token); + let query = client + .get(format!("http://{addr}/mobile?token={encoded}")) + .send() + .await? + .error_for_status()?; + assert!(query.text().await?.contains("CodeWhale Mobile")); + + let bearer = client + .get(format!("http://{addr}/mobile")) + .bearer_auth(&token) + .send() + .await? + .error_for_status()?; + assert!(bearer.text().await?.contains("CodeWhale Mobile")); + + handle.abort(); + Ok(()) + } + + #[tokio::test] + async fn mobile_insecure_mode_allows_page_and_v1_routes_without_token() -> Result<()> { + let tmp = tempfile::tempdir()?; + let root = tmp.path().to_path_buf(); + let sessions_dir = root.join("sessions"); + let Some((addr, _runtime_threads, handle)) = + spawn_test_server_with_root_token_and_mobile(root, sessions_dir, None, true).await? + else { + return Ok(()); + }; + let client = reqwest::Client::new(); + + let page = client + .get(format!("http://{addr}/mobile")) + .send() + .await? + .error_for_status()?; + assert!(page.text().await?.contains("CodeWhale Mobile")); + + let summary = client + .get(format!("http://{addr}/v1/threads/summary")) + .send() + .await? + .error_for_status()?; + assert_eq!(summary.status(), StatusCode::OK); + + handle.abort(); + Ok(()) + } + #[tokio::test] async fn decide_approval_404s_when_nothing_pending() -> Result<()> { let Some((addr, _runtime_threads, handle)) = spawn_test_server().await? else { diff --git a/crates/tui/src/runtime_mobile.html b/crates/tui/src/runtime_mobile.html new file mode 100644 index 00000000..cf8d6e44 --- /dev/null +++ b/crates/tui/src/runtime_mobile.html @@ -0,0 +1,544 @@ + + + + + + CodeWhale Mobile + + + +
+

CodeWhale Mobile

+ +
+ +
+
+
+ Connection + +
+
+ +
Not connected
+
+
+ +
+
+ Threads + +
+
+
+ +
+
+ No thread selected + 0 events +
+
+
+ +
+
+ Composer + +
+
+ +
+ + + +
+
+ + +
+
+
+
+ + + + diff --git a/docs/RUNTIME_API.md b/docs/RUNTIME_API.md index 504154f0..d7ec8331 100644 --- a/docs/RUNTIME_API.md +++ b/docs/RUNTIME_API.md @@ -117,6 +117,7 @@ codewhale doctor --json ```bash codewhale serve --http [--host 127.0.0.1] [--port 7878] [--workers 2] [--auth-token TOKEN] +codewhale serve --mobile [--host 0.0.0.0] [--port 7878] [--auth-token TOKEN] ``` Defaults: host `127.0.0.1`, port `7878`, 2 workers (clamped 1–8). @@ -124,16 +125,35 @@ Defaults: host `127.0.0.1`, port `7878`, 2 workers (clamped 1–8). The server binds to `localhost` by default. Configuration is via CLI flags — there is no `[app_server]` config section. -By default, existing local behavior is unchanged and `/v1/*` routes are not -authenticated. To require a bearer token for `/v1/*` routes, pass -`--auth-token TOKEN` or set `DEEPSEEK_RUNTIME_TOKEN=TOKEN` before starting the -server. `/health` remains public for local process supervision and readiness -checks. +`/v1/*` routes require a bearer token unless `--insecure` is explicitly set. +Pass `--auth-token TOKEN` or set `DEEPSEEK_RUNTIME_TOKEN=TOKEN` before starting +the server. If neither is set, the process generates a one-time token and prints +it at startup. `/health` and `/v1/runtime/info` remain public for local +supervision and bootstrap. `/mobile` returns 404 when mobile mode is disabled; +when mobile mode is enabled and auth is enabled, `/mobile` returns 401 unless +the request supplies the runtime token. Authenticated clients can provide the token as `Authorization: Bearer TOKEN`, `X-DeepSeek-Runtime-Token: TOKEN`, or `?token=TOKEN` for EventSource-style clients that cannot set custom headers. +### Mobile control page + +`codewhale serve --mobile` starts the same HTTP/SSE runtime API and serves a +phone-friendly control page at `/mobile`. When the bind host is left at the +default, mobile mode binds to `0.0.0.0`, prints a warning, and prints local/LAN +URLs. Pass `--host 127.0.0.1` to keep the mobile page loopback-only. If a +runtime token is generated or supplied, the printed mobile URL includes it as a +query parameter; the page stores it locally and removes it from the address bar. +The static HTML page contains no secrets, but it is still token-gated when auth +is enabled so unauthenticated LAN clients cannot fingerprint the mobile surface. + +The mobile page can list/create threads, send prompts, follow live SSE events, +steer or interrupt an active turn, and resolve normal tool approvals through +`POST /v1/approvals/{approval_id}`. It is still a local/LAN convenience surface: +do not expose it directly to the public internet without TLS and a trusted +fronting layer. + ### Endpoints **Health** @@ -188,6 +208,10 @@ accept an empty string to clear a previously-set value. Added in v0.8.10 (#562): - `POST /v1/threads/{id}/turns/{turn_id}/interrupt` - `POST /v1/threads/{id}/compact` (manual compaction) +**Approvals** +- `POST /v1/approvals/{approval_id}` with body + `{ "decision": "allow" | "deny", "remember": false }` + **Events** (SSE replay + live stream) - `GET /v1/threads/{id}/events?since_seq=` @@ -306,13 +330,16 @@ The SSE event payload shape: Common event names: `thread.started`, `thread.forked`, `turn.started`, `turn.lifecycle`, `turn.steered`, `turn.interrupt_requested`, `turn.completed`, `item.started`, `item.delta`, `item.completed`, -`item.failed`, `item.interrupted`, `approval.required`, `sandbox.denied`, -`coherence.state`. +`item.failed`, `item.interrupted`, `approval.required`, `approval.decided`, +`approval.timeout`, `sandbox.denied`, `coherence.state`. ## Security boundary -- **Localhost only**. The server binds to `127.0.0.1` by default. Set - `--host 0.0.0.0` only when you have a reverse-proxy / VPN that +- **Localhost by default**. The server binds to `127.0.0.1` by default. + `--mobile` binds to `0.0.0.0` when no host is supplied so phones on the same + LAN can reach it, and the CLI prints a warning for that rebind. Pass + `--host 127.0.0.1` for a loopback-only mobile page. Set a non-loopback host + only when you trust the network path or have a reverse-proxy / VPN that authenticates. The runtime does not provide user isolation or TLS. - **Optional token guard**. `--auth-token` or `DEEPSEEK_RUNTIME_TOKEN` requires a matching bearer token for `/v1/*` routes. This is a local