mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-22 13:37:32 +08:00
Plugin and Box now share one transport rule via ManagedRuntimeConnector.select_runtime_transport(): an explicit endpoint, Docker or --standalone-* means WebSocket to an external runtime; every other case (Windows, Linux, macOS) launches the runtime as a child process and talks over its stdio pipes. The Windows-only "subprocess + WebSocket" branch is removed from both connectors together with its helpers (control-token generation, port probing, readiness polling, subprocess disposal). Since langbot-plugin 0.6.0 the runtime side reads/writes stdio from blocking threads on Windows, so the WinError 6 that motivated the branch no longer applies. Docs (zh/en/ja compatibility + deep-dive, ARCHITECTURE.md, dev-docs reviews) now describe the actual transports, including the Windows runtime-to-worker WebSocket on the plugin debug port. Refs #2545 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
33 lines
2.0 KiB
Plaintext
33 lines
2.0 KiB
Plaintext
---
|
||
title: "系统兼容处理"
|
||
---
|
||
|
||
LangBot 插件系统由三层进程组成:LangBot 主程序、Plugin Runtime、每个插件各自的 worker 进程。本文说明各层之间在不同系统上使用什么方式通信。
|
||
|
||
## LangBot 与 Plugin Runtime
|
||
|
||
LangBot 与 Plugin Runtime 之间的传输方式只取决于 Runtime 由谁启动,与操作系统无关:
|
||
|
||
| 部署方式 | 传输方式 |
|
||
|---|---|
|
||
| 直接运行 LangBot(Windows / Linux / macOS) | LangBot 以子进程启动 Plugin Runtime,通过子进程的 stdio 通信 |
|
||
| Docker 部署 | 通过 WebSocket 连接 `plugin.runtime_ws_url`(默认 Compose 服务 `langbot_plugin_runtime:5400`) |
|
||
| 使用 `--standalone-runtime` 启动 | 通过 WebSocket 连接 `plugin.runtime_ws_url`,Runtime 需自行启动 |
|
||
|
||
Box Runtime 遵循同样的规则:直接运行时走 stdio;Docker、`--standalone-box` 或配置了 `box.runtime.endpoint` 时走 WebSocket。
|
||
|
||
<Note>
|
||
Windows 上的 asyncio `ProactorEventLoop` 无法把子进程继承来的匿名管道注册到 IOCP,直接使用 `connect_read_pipe` / `connect_write_pipe` 会报 `WinError 6`。自 `langbot-plugin` 0.6.0 起,Runtime 在 Windows 上改用后台线程阻塞读写 stdio,因此 LangBot 在 Windows 上与 Linux / macOS 一样直接使用 stdio,无需额外配置。
|
||
</Note>
|
||
|
||
## Plugin Runtime 与插件 worker
|
||
|
||
Plugin Runtime 为每个已安装插件启动一个 worker 子进程:
|
||
|
||
- **Linux / macOS**:通过 worker 子进程的 stdio 通信。
|
||
- **Windows**:Runtime 以子进程启动 worker,worker 再通过 WebSocket 连回 Runtime 的插件调试端口(`ws://localhost:<端口>/plugin/ws`)。
|
||
|
||
该调试端口默认是 `5401`,跟随 `plugin.display_plugin_debug_url` 的端口配置。在 Windows 上,请确保该端口未被占用,且本机回环连接未被防火墙拦截;同一台机器运行多个 LangBot 实例时,请为每个实例配置不同的 `display_plugin_debug_url` 端口。
|
||
|
||
以上均由 LangBot 根据部署方式和系统自动选择,您无需手动配置传输方式。
|