🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
📝 docs: simplify device gateway setup guides (#21368)
Bryan08534a2ea41b
diff --git a/docs/self-hosting/advanced/desktop.mdx b/docs/self-hosting/advanced/desktop.mdxindex 7ab743e2990..b61d0f38528 100644--- a/docs/self-hosting/advanced/desktop.mdx+++ b/docs/self-hosting/advanced/desktop.mdx@@ -69,31 +69,26 @@ If you are deploying LobeHub using one-click deployment methods (such as Vercel,### Connecting the Device Gateway-The Device Gateway lets agents run tools on this computer. The desktop app and CLI connect to `<gateway address>/ws` with a token from the instance they are signed in to, so they must use that instance's gateway. In Docker Compose this is the `gateway` service on port `8788`. Never give clients the server-internal `DEVICE_GATEWAY_URL` (`http://gateway:8788`).--1. Publish port `8788` over HTTPS with WebSocket upgrades enabled. For example, in Nginx:-- ```nginx- location / {- proxy_pass http://127.0.0.1:8788;- proxy_http_version 1.1;- proxy_set_header Upgrade $http_upgrade;- proxy_set_header Connection 'upgrade';- proxy_set_header Host $host;- }- ```+The Device Gateway lets agents run local tools on this computer.++1. Start the gateway using the [Docker Compose guide](/docs/self-hosting/platform/docker-compose). If you use a domain, proxy it to port `8788` with HTTPS and WebSocket support.- Running `curl https://device-gateway.example.com/health` on the client computer prints `OK`.+2. To let clients get the address automatically, set this environment variable on your LobeHub server, then redeploy:-2. Optional: set [`DEVICE_GATEWAY_PUBLIC_URL`](/docs/self-hosting/environment-variables/basic#device_gateway_public_url) to this address so clients that support discovery get it from your instance. You can also leave it unset and give each client the address.+ ```env+ DEVICE_GATEWAY_PUBLIC_URL=https://device-gateway.example.com+ ```-3. In the desktop app, click the **Device Gateway** icon in the title bar and turn on the switch. The app uses the first address it finds: its own `DEVICE_GATEWAY_URL` environment variable, an existing saved address other than `https://device-gateway.lobehub.com`, the address published by your instance, then `https://device-gateway.lobehub.com`.+3. Sign in to that instance in the desktop app and turn on **Device Gateway** in the title bar. For the CLI, run:- The desktop app only reads existing saved gateway addresses; it does not provide an address editor or write the discovered address to its settings. Configure `DEVICE_GATEWAY_PUBLIC_URL` on the server, or set `DEVICE_GATEWAY_URL` when starting the desktop app.+ ```sh+ lh login --server https://lobe.example.com+ lh connect+ ```-4. For the CLI, run `lh login --server https://lobe.example.com`, then `lh connect`. `lh` uses `--gateway <url>` (saved for later runs), the address saved for this instance, then the address published by your instance. If none exists, it asks for `--gateway <url>`.+The device list shows this computer's online status after it connects.-<Callout>Clients without discovery support ignore the published address. Give them the address with the desktop `DEVICE_GATEWAY_URL` or `lh connect --gateway <url>`.</Callout>+<Callout>Existing custom gateway addresses take priority. You can also specify an address with the desktop `DEVICE_GATEWAY_URL` environment variable or `lh connect --gateway <url>` without setting the server variable.</Callout>## Frequently Asked Questions@@ -125,12 +120,8 @@ Check if the `APP_URL` environment variable matches the URL you are accessing.### Device Gateway Does Not Connect-**Issue:** The Device Gateway switch turns off right after you turn it on, or the connection keeps retrying.--**Solution:**--- If `lh status` prints `FAILED - Authentication failed: crypto/rsa: verification error`, the gateway does not trust the instance that issued the token. Use the gateway of the instance the client is signed in to, and check that the gateway's `JWKS_PUBLIC_KEY` matches your current `JWKS_KEY`. Without a published or configured address, the desktop app uses the LobeHub Cloud gateway, which rejects self-hosted tokens.-- If the connection times out, run the `/health` check above on the client computer, then check the reverse proxy's WebSocket settings and certificate.+- **Disconnects immediately**: check that the gateway belongs to the instance you signed in to, including any custom address configured on the client.+- **Connection times out**: run `curl https://device-gateway.example.com/health` on your computer. It should return `OK`; otherwise, check the gateway address, network and reverse proxy settings.### macOS Startup Hangs or Crashesdiff --git a/docs/self-hosting/advanced/desktop.zh-CN.mdx b/docs/self-hosting/advanced/desktop.zh-CN.mdxindex ee0cf039745..022b7b7e87f 100644--- a/docs/self-hosting/advanced/desktop.zh-CN.mdx+++ b/docs/self-hosting/advanced/desktop.zh-CN.mdx@@ -67,31 +67,26 @@ LobeHub 桌面端可以与您自托管的 LobeHub 实例连接,以便您可以### 连接设备网关-设备网关让助理可以在这台电脑上运行工具。桌面端和 CLI 会使用当前登录实例签发的令牌连接 `<网关地址>/ws`,因此必须使用该实例的网关。在 Docker Compose 中,它是 `gateway` 服务的 `8788` 端口。不要把服务端内部使用的 `DEVICE_GATEWAY_URL`(`http://gateway:8788`)提供给客户端。--1. 通过 HTTPS 公开 `8788` 端口,并允许 WebSocket 升级。Nginx 示例:-- ```nginx- location / {- proxy_pass http://127.0.0.1:8788;- proxy_http_version 1.1;- proxy_set_header Upgrade $http_upgrade;- proxy_set_header Connection 'upgrade';- proxy_set_header Host $host;- }- ```+设备网关让助理在这台电脑上运行本地工具。++1. 按 [Docker Compose 部署说明](/zh/docs/self-hosting/platform/docker-compose) 启动网关。通过域名访问时,反向代理到 `8788` 端口,并开启 HTTPS 和 WebSocket 支持。- 在客户端电脑上运行 `curl https://device-gateway.example.com/health`,应输出 `OK`。+2. 如需让客户端自动获取地址,在 LobeHub 服务端设置以下环境变量,然后重新部署:-2. 可选:将 [`DEVICE_GATEWAY_PUBLIC_URL`](/zh/docs/self-hosting/environment-variables/basic#device_gateway_public_url) 设置为该地址,支持自动发现的客户端即可从您的实例获取它。也可以不配置,为每个客户端自行提供地址。+ ```env+ DEVICE_GATEWAY_PUBLIC_URL=https://device-gateway.example.com+ ```-3. 在桌面端点击标题栏中的 **设备网关** 图标并打开开关。桌面端按以下顺序使用找到的第一个地址:桌面端自己的 `DEVICE_GATEWAY_URL` 环境变量、已有且不是 `https://device-gateway.lobehub.com` 的保存地址、您的实例下发的地址,最后是 `https://device-gateway.lobehub.com`。+3. 在桌面端登录该实例,打开标题栏中的 **设备网关** 开关。CLI 用户运行:- 桌面端只读取已有的网关地址,不提供地址编辑入口,也不会把下发的地址写入设置。请在服务端配置 `DEVICE_GATEWAY_PUBLIC_URL`,或在启动桌面端时设置 `DEVICE_GATEWAY_URL`。+ ```sh+ lh login --server https://lobe.example.com+ lh connect+ ```-4. 使用 CLI 时,先运行 `lh login --server https://lobe.example.com`,再运行 `lh connect`。`lh` 依次使用 `--gateway <url>`(会保存供之后使用)、为当前实例保存的地址、您的实例下发的地址;都没有时会提示提供 `--gateway <url>`。+连接后,可在设备列表中查看这台电脑的在线状态。-<Callout>不支持自动发现的客户端会忽略实例下发的地址,请通过桌面端的 `DEVICE_GATEWAY_URL` 或 `lh connect --gateway <url>` 提供地址。</Callout>+<Callout>已有的自定义网关地址仍会优先使用。也可通过桌面端的 `DEVICE_GATEWAY_URL` 环境变量或 `lh connect --gateway <url>` 手动指定地址,无需配置服务端环境变量。</Callout>## 常见问题@@ -123,12 +118,8 @@ proxy_busy_buffers_size 32k;### 设备网关无法连接-**问题:** 打开设备网关开关后立即恢复关闭,或连接一直在重试。--**解决方案:**--- 如果 `lh status` 输出 `FAILED - Authentication failed: crypto/rsa: verification error`,说明网关不信任签发令牌的实例。请使用客户端所登录实例的网关,并确认网关的 `JWKS_PUBLIC_KEY` 与当前 `JWKS_KEY` 匹配。没有下发或配置地址时,桌面端会使用 LobeHub Cloud 网关,它会拒绝自托管实例的令牌。-- 如果连接超时,请在客户端电脑上运行上文的 `/health` 检查,再检查反向代理的 WebSocket 设置和证书。+- **打开后立即断开**:确认网关地址属于当前登录的实例,并检查客户端已有的自定义地址。+- **连接超时**:在客户端电脑运行 `curl https://device-gateway.example.com/health`,应返回 `OK`;否则检查网关地址、网络和反向代理设置。### macOS 启动卡住或闪退diff --git a/docs/self-hosting/environment-variables/basic.mdx b/docs/self-hosting/environment-variables/basic.mdxindex f61e6bd36cf..857944a8f91 100644--- a/docs/self-hosting/environment-variables/basic.mdx+++ b/docs/self-hosting/environment-variables/basic.mdx@@ -153,14 +153,14 @@ Business builds enable Gateway Mode automatically. Self-hosted deployments can s### `DEVICE_GATEWAY_URL`- Type: Optional-- Description: Device Gateway endpoint for server-to-gateway requests, such as the Docker Compose service name. LobeHub uses it to reach connected devices. It stays on the server and is never sent to clients.+- Description: Device Gateway address for server requests. This internal address is not sent to clients.- Default: -- Example: `http://gateway:8788`### `DEVICE_GATEWAY_PUBLIC_URL`- Type: Optional-- Description: Device Gateway address as reached by desktop and CLI clients. When set, LobeHub publishes it in the server config (`deviceGatewayUrl`) so clients that support discovery can get the address from this server. When unset, nothing is published and clients keep the address configured on each of them, for example with `lh connect --gateway <url>`. Both ways work, and you can leave it unset permanently. Use the base address without a path such as `/ws`; a value with credentials, a query string or a fragment fails environment validation, and a trailing slash is removed. `DEVICE_GATEWAY_URL` is never published in its place.+- Description: Device Gateway address that desktop and CLI clients can discover automatically. Leave unset to specify the address on each client. Use an HTTP or HTTPS base URL without the `/ws` suffix, credentials, query parameters or a `#` fragment.- Default: -- Example: `https://device-gateway.example.com` or `http://your_server_ip:8788`diff --git a/docs/self-hosting/environment-variables/basic.zh-CN.mdx b/docs/self-hosting/environment-variables/basic.zh-CN.mdxindex 02256708f0f..3447a689a66 100644--- a/docs/self-hosting/environment-variables/basic.zh-CN.mdx+++ b/docs/self-hosting/environment-variables/basic.zh-CN.mdx@@ -149,14 +149,14 @@ LobeHub 在部署时提供了一些额外的配置项,你可以使用环境变### `DEVICE_GATEWAY_URL`- 类型:可选-- 描述:服务端访问 Device Gateway 使用的地址,例如 Docker Compose 服务名。LobeHub 通过它访问已连接的设备。该地址只在服务端使用,不会下发给客户端。+- 描述:服务端访问设备网关的内部地址,不会下发给客户端。- 默认值:-- 示例:`http://gateway:8788`### `DEVICE_GATEWAY_PUBLIC_URL`- 类型:可选-- 描述:桌面端和 CLI 客户端访问 Device Gateway 使用的地址。配置后,LobeHub 会在服务端配置中下发该地址(`deviceGatewayUrl`),支持自动发现的客户端可以从当前服务端获取它。不配置时不下发任何地址,客户端继续使用各自配置的地址,例如 `lh connect --gateway <url>`。两种方式都可以使用,也可以一直不配置。请填写不带 `/ws` 等路径的基础地址;包含账号密码、查询参数或片段(`#`)的地址无法通过环境变量校验,末尾的 `/` 会被去掉。`DEVICE_GATEWAY_URL` 不会被用来代替它下发。+- 描述:桌面端和 CLI 自动获取的设备网关地址。不配置时可在客户端手动指定。使用不带 `/ws` 后缀的 HTTP 或 HTTPS 地址,不含账号密码、查询参数或 `#` 片段。- 默认值:-- 示例:`https://device-gateway.example.com` 或 `http://your_server_ip:8788`diff --git a/docs/self-hosting/platform/docker-compose.mdx b/docs/self-hosting/platform/docker-compose.mdxindex 80e24ab32b7..0763fcbf40d 100644--- a/docs/self-hosting/platform/docker-compose.mdx+++ b/docs/self-hosting/platform/docker-compose.mdx@@ -363,7 +363,7 @@ docker run --rm --entrypoint /bin/node lobehub/lobehub -e 'const c=require("crypDevices joined with `lh connect --gateway http://your_server_ip:8788` can run local tools for this deployment through the device gateway on port `8788`.</Callout>-`DEVICE_GATEWAY_PUBLIC_URL` is optional. Set it in `.env` to the device gateway address as reached by desktop and CLI clients, such as `http://your_server_ip:8788` or a domain you reverse proxy to port `8788` with WebSocket upgrades enabled. LobeHub then publishes it so clients that support discovery get the address from this server. Leave it unset to keep passing the address to each client yourself, as with `--gateway` above; both ways keep working, and existing deployments need no change. Don't copy the `DEVICE_GATEWAY_URL` value into it: `http://gateway:8788` only resolves inside the Compose network.+Optional: set `DEVICE_GATEWAY_PUBLIC_URL` in `.env` to a client-accessible gateway address, such as `http://your_server_ip:8788`. Do not use the container-internal address `http://gateway:8788`. Leave it unset to keep using `--gateway` above. For domain setup, see [Connecting the Device Gateway](/docs/self-hosting/advanced/desktop#connecting-the-device-gateway).## Upgrading an Existing Deploymentdiff --git a/docs/self-hosting/platform/docker-compose.zh-CN.mdx b/docs/self-hosting/platform/docker-compose.zh-CN.mdxindex 4c7298aa653..2151c7c98b9 100644--- a/docs/self-hosting/platform/docker-compose.zh-CN.mdx+++ b/docs/self-hosting/platform/docker-compose.zh-CN.mdx@@ -357,7 +357,7 @@ docker run --rm --entrypoint /bin/node lobehub/lobehub -e 'const c=require("cryp通过 `lh connect --gateway http://your_server_ip:8788` 接入的设备,可以经由 `8788` 端口的设备网关为该部署执行本地工具。</Callout>-`DEVICE_GATEWAY_PUBLIC_URL` 为可选项。在 `.env` 中将其设置为桌面端和 CLI 客户端访问设备网关的地址,例如 `http://your_server_ip:8788`,或反向代理到 `8788` 端口并开启 WebSocket 升级的域名。配置后,LobeHub 会下发该地址,支持自动发现的客户端可以从当前服务端获取它。不配置时,继续像上面的 `--gateway` 一样为每个客户端自行指定地址;两种方式都可以使用,已有部署无需修改。不要直接复用 `DEVICE_GATEWAY_URL` 的值:`http://gateway:8788` 只能在 Compose 网络内解析。+可选:在 `.env` 中设置 `DEVICE_GATEWAY_PUBLIC_URL` 为客户端可访问的网关地址,例如 `http://your_server_ip:8788`,不要使用容器内部地址 `http://gateway:8788`。不配置时可继续使用上面的 `--gateway`;域名配置参见 [连接设备网关](/zh/docs/self-hosting/advanced/desktop#连接设备网关)。## 升级已有部署