diff --git a/gitbooks/developing/architecture/tauri-shell.md b/gitbooks/developing/architecture/tauri-shell.md index 9df31f4bca..5929c79fff 100644 --- a/gitbooks/developing/architecture/tauri-shell.md +++ b/gitbooks/developing/architecture/tauri-shell.md @@ -1,23 +1,23 @@ --- -description: The desktop host (`app/src-tauri/`) - Tauri v2 + WebView, IPC, sidecar lifecycle, core bridge. +description: The desktop host (`app/src-tauri/`) - Tauri v2 + WebView, IPC, embedded core lifecycle, core bridge. icon: desktop --- # Tauri shell (`app/src-tauri/`) -The desktop host for OpenHuman: Tauri v2 + WebView, IPC commands, window management, and bridging to the `openhuman-core` Rust sidecar (core JSON-RPC). It does **not** duplicate the full domain stack; that lives in the repo-root Rust crate (`openhuman_core`, `src/main.rs`). +The desktop host for OpenHuman: Tauri v2 + WebView, IPC commands, window management, and bridging to the embedded `openhuman-core` Rust runtime (core JSON-RPC). It does **not** duplicate the full domain stack; that lives in the repo-root Rust crate (`openhuman_core`, `src/main.rs`). ## Responsibilities 1. **Web UI**. Load the Vite build from `app/dist` (or dev server on port 1420). -2. **IPC**. Expose a small, explicit set of Tauri commands (see [Commands](#commands)). -3. **Core lifecycle**. Ensure the `openhuman-core` binary is running (child process and/or service) and proxy JSON-RPC via `core_rpc_relay`. +2. **IPC**. Expose a small, explicit set of Tauri commands (see [Commands](#tauri-ipc-commands-app-src-tauri)). +3. **Core lifecycle**. Start the in-process core server and proxy JSON-RPC via `core_rpc_relay`. 4. **AI prompts on disk**. Resolve bundled `src/openhuman/agent/prompts` from resources / dev cwd for `ai_get_config` / `write_ai_config_file`. 5. **Window + tray**. Desktop window behavior and system tray (see `lib.rs`). -## Building the sidecar +## Core process model -`app/package.json` `core:stage` runs `scripts/stage-core-sidecar.mjs`, which runs `cargo build --bin openhuman-core` at the repo root and copies the binary into `app/src-tauri/binaries/` for Tauri `externalBin`. +`app/package.json` `core:stage` is intentionally a no-op kept for script compatibility. The desktop app links the core in-process, so local builds no longer need a staged `openhuman-core-*` sidecar under `app/src-tauri/binaries/`. ## Stuck process recovery @@ -31,7 +31,7 @@ Startup recovery skips when `OPENHUMAN_CORE_REUSE_EXISTING=1` is set (so manual ### Overview -The **`app/src-tauri`** crate (Rust package **`OpenHuman`**, binary **`OpenHuman`**) is a **desktop-only** host. It embeds the React UI, registers plugins (deep link, opener, OS, notifications, autostart, updater), manages the main window and tray, and **relays JSON-RPC** to the separately built **`openhuman-core`** binary. +The **`app/src-tauri`** crate (Rust package **`OpenHuman`**, binary **`OpenHuman`**) is a **desktop-only** host. It embeds the React UI, registers plugins (deep link, opener, OS, notifications, autostart, updater), manages the main window and tray, and **relays JSON-RPC** to the embedded core server. Non-desktop targets fail at compile time (`compile_error!` in `lib.rs`). @@ -41,7 +41,7 @@ Non-desktop targets fail at compile time (`compile_error!` in `lib.rs`). app/src-tauri/src/ ├── lib.rs # `run()`, tray/menu actions, plugins, `generate_handler!`, core startup ├── main.rs # Binary entry -├── core_process.rs # CoreProcessHandle, spawn/monitor openhuman sidecar +├── core_process.rs # CoreProcessHandle, embedded core server task ├── core_rpc.rs # HTTP client to core JSON-RPC ├── commands/ │ ├── mod.rs # Re-exports @@ -61,10 +61,10 @@ There is **no** `src-tauri/src/services/session_service.rs` in this tree; sessio React (invoke) → core_rpc_relay { method, params, serviceManaged? } → core_rpc::call HTTP POST to OPENHUMAN_CORE_RPC_URL - → openhuman binary (src/bin/openhuman.rs → core_server) + → embedded openhuman core server ``` -`CoreProcessHandle` in `core_process.rs` starts or waits for the sidecar; `commands/core_relay.rs` optionally ensures a **service-managed** core is running before relaying. +`CoreProcessHandle` in `core_process.rs` owns the embedded server task; `commands/core_relay.rs` optionally ensures a **service-managed** core is running before relaying. ### Window and tray behavior diff --git a/gitbooks/developing/architecture/tauri-shell.zh-CN.md b/gitbooks/developing/architecture/tauri-shell.zh-CN.md index 1133228050..0a6233699d 100644 --- a/gitbooks/developing/architecture/tauri-shell.zh-CN.md +++ b/gitbooks/developing/architecture/tauri-shell.zh-CN.md @@ -1,23 +1,23 @@ --- -description: 桌面宿主 (`app/src-tauri/`) —— Tauri v2 + WebView、IPC、sidecar 生命周期、核心桥接。 +description: 桌面宿主 (`app/src-tauri/`) —— Tauri v2 + WebView、IPC、嵌入式核心生命周期、核心桥接。 icon: desktop --- # Tauri Shell (`app/src-tauri/`) -OpenHuman 的桌面宿主:Tauri v2 + WebView、IPC 命令、窗口管理,以及桥接到 `openhuman-core` Rust sidecar(核心 JSON-RPC)。它**不会**重复完整的领域栈;那部分存在于仓库根目录的 Rust crate 中(`openhuman_core`、`src/main.rs`)。 +OpenHuman 的桌面宿主:Tauri v2 + WebView、IPC 命令、窗口管理,以及桥接到嵌入式 `openhuman-core` Rust 运行时(核心 JSON-RPC)。它**不会**重复完整的领域栈;那部分存在于仓库根目录的 Rust crate 中(`openhuman_core`、`src/main.rs`)。 ## 职责 1. **Web UI**。从 `app/dist` 加载 Vite 构建(或开发服务器,端口 1420)。 2. **IPC**。暴露一小套明确的 Tauri 命令(见 [Commands](#tauri-ipc-commands-app-src-tauri))。 -3. **核心生命周期**。确保 `openhuman-core` 二进制文件正在运行(子进程和/或服务)并通过 `core_rpc_relay` 代理 JSON-RPC。 +3. **核心生命周期**。启动进程内核心服务器,并通过 `core_rpc_relay` 代理 JSON-RPC。 4. **磁盘上的 AI 提示**。从资源 / 开发 cwd 解析捆绑的 `src/openhuman/agent/prompts`,用于 `ai_get_config` / `write_ai_config_file`。 5. **窗口 + 托盘**。桌面窗口行为和系统托盘(见 `lib.rs`)。 -## 构建 sidecar +## 核心进程模型 -`app/package.json` 的 `core:stage` 运行 `scripts/stage-core-sidecar.mjs`,后者在仓库根目录运行 `cargo build --bin openhuman-core` 并将二进制文件复制到 `app/src-tauri/binaries/`,供 Tauri `externalBin` 使用。 +`app/package.json` 的 `core:stage` 现在有意保持为 no-op,仅用于脚本兼容性。桌面应用会在进程内链接核心,因此本地构建不再需要在 `app/src-tauri/binaries/` 下 staging `openhuman-core-*` sidecar。 ## 卡死进程恢复 @@ -32,7 +32,7 @@ OpenHuman 的桌面宿主:Tauri v2 + WebView、IPC 命令、窗口管理,以 ### 概述 -**`app/src-tauri`** crate(Rust 包 **`OpenHuman`**,二进制文件 **`OpenHuman`**)是一个**仅限桌面**的宿主。它嵌入 React UI,注册插件(深度链接、打开器、OS、通知、自动启动、更新器),管理主窗口和托盘,并**中继 JSON-RPC** 到单独构建的 **`openhuman-core`** 二进制文件。 +**`app/src-tauri`** crate(Rust 包 **`OpenHuman`**,二进制文件 **`OpenHuman`**)是一个**仅限桌面**的宿主。它嵌入 React UI,注册插件(深度链接、打开器、OS、通知、自动启动、更新器),管理主窗口和托盘,并**中继 JSON-RPC** 到嵌入式核心服务器。 非桌面目标在编译时失败(`lib.rs` 中的 `compile_error!`)。 @@ -42,7 +42,7 @@ OpenHuman 的桌面宿主:Tauri v2 + WebView、IPC 命令、窗口管理,以 app/src-tauri/src/ ├── lib.rs # `run()`、托盘/菜单动作、插件、`generate_handler!`、核心启动 ├── main.rs # 二进制入口 -├── core_process.rs # CoreProcessHandle、生成/监控 openhuman sidecar +├── core_process.rs # CoreProcessHandle、嵌入式核心服务器任务 ├── core_rpc.rs # 核心 JSON-RPC 的 HTTP 客户端 ├── commands/ │ ├── mod.rs # 重新导出 @@ -62,10 +62,10 @@ app/src-tauri/src/ React (invoke) → core_rpc_relay { method, params, serviceManaged? } → core_rpc::call HTTP POST 到 OPENHUMAN_CORE_RPC_URL - → openhuman 二进制文件 (src/bin/openhuman.rs → core_server) + → 嵌入式 openhuman 核心服务器 ``` -`core_process.rs` 中的 `CoreProcessHandle` 启动或等待 sidecar;`commands/core_relay.rs` 可选地在 relay 之前确保**服务管理**的核心正在运行。 +`core_process.rs` 中的 `CoreProcessHandle` 拥有嵌入式服务器任务;`commands/core_relay.rs` 可选地在 relay 之前确保**服务管理**的核心正在运行。 ### 窗口和托盘行为 diff --git a/gitbooks/developing/getting-set-up.md b/gitbooks/developing/getting-set-up.md index 57e44dfb58..84751642cb 100644 --- a/gitbooks/developing/getting-set-up.md +++ b/gitbooks/developing/getting-set-up.md @@ -1,5 +1,5 @@ --- -description: How to build OpenHuman from source - toolchain, vendored Tauri CLI, sidecar staging. +description: How to build OpenHuman from source - toolchain, vendored Tauri CLI, and local desktop builds. icon: wrench --- @@ -60,25 +60,17 @@ git submodule update --init --recursive # 3) Install JS deps (workspace) pnpm install -# 4) Build Rust core binary -cargo build --manifest-path Cargo.toml --bin openhuman-core - -# 5) Run the desktop staging hook (currently a no-op; kept for script compatibility) -cd app -pnpm core:stage - -# 6) Build desktop app artifacts +# 4) Build desktop app artifacts pnpm build ``` For local development instead of production build: ```bash -# Web-only UI development: run inside app/ after the `cd app` step above +# Web-only UI development pnpm dev # Desktop app development with the vendored Tauri/CEF CLI: run from the workspace root -cd .. pnpm --filter openhuman-app dev:app ``` diff --git a/gitbooks/developing/getting-set-up.zh-CN.md b/gitbooks/developing/getting-set-up.zh-CN.md index 902ba17973..307d2b2397 100644 --- a/gitbooks/developing/getting-set-up.zh-CN.md +++ b/gitbooks/developing/getting-set-up.zh-CN.md @@ -1,5 +1,5 @@ --- -description: 如何从源码构建 OpenHuman —— 工具链、 vendored Tauri CLI、sidecar staging。 +description: 如何从源码构建 OpenHuman —— 工具链、vendored Tauri CLI 和本地桌面构建。 icon: wrench lang: zh-CN --- @@ -61,25 +61,17 @@ git submodule update --init --recursive # 3) 安装 JS 依赖(workspace) pnpm install -# 4) 构建 Rust 核心二进制文件 -cargo build --manifest-path Cargo.toml --bin openhuman-core - -# 5) 运行桌面 staging hook(当前为 no-op;为脚本兼容性保留) -cd app -pnpm core:stage - -# 6) 构建桌面应用产物 +# 4) 构建桌面应用产物 pnpm build ``` 本地开发(而非生产构建): ```bash -# 仅 Web UI 开发:在上述 cd app 步骤后,在 app/ 内运行 +# 仅 Web UI 开发 pnpm dev # 使用 vendored Tauri/CEF CLI 的桌面应用开发:从 workspace 根目录运行 -cd .. pnpm --filter openhuman-app dev:app ``` diff --git a/scripts/worktree-bootstrap.sh b/scripts/worktree-bootstrap.sh index 4173ccc252..ca311bb5c9 100755 --- a/scripts/worktree-bootstrap.sh +++ b/scripts/worktree-bootstrap.sh @@ -2,8 +2,8 @@ # Bootstrap a fresh git worktree for OpenHuman dev. # # `git worktree add` only checks out the tree. Submodules, untracked env -# files, and the staged core binary under app/src-tauri/binaries/ don't come -# along — the app won't build until they do. Run this once per worktree. +# files don't come along — the app won't build until they do. Run this once +# per worktree. # # Usage: from inside the worktree, `bash scripts/worktree-bootstrap.sh`. @@ -33,18 +33,6 @@ for rel in ".env" "app/.env.local"; do fi done -# Stage the core sidecar binary. Either symlink to main's staged copy (fast, -# but will run main's code) OR build fresh from this worktree (slow, runs -# this branch's code). Default to fresh build — the whole point of a -# worktree is testing divergent code. -BIN="$WORKTREE_ROOT/app/src-tauri/binaries/openhuman-core-aarch64-apple-darwin" -if [[ ! -e "$BIN" ]]; then - echo "[bootstrap] building + staging core sidecar from this worktree..." - mkdir -p "$(dirname "$BIN")" - (cd "$WORKTREE_ROOT" && cargo build --bin openhuman-core) - (cd "$WORKTREE_ROOT/app" && pnpm core:stage) -fi - echo "[bootstrap] installing node_modules (needed for husky hooks + prettier)..." (cd "$WORKTREE_ROOT" && pnpm install)