mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 04:15:45 +08:00
* 重构文档结构:移除 docs 目录,调整文件组织结构 * Reorder "插件 SDK API" section in docs.json * Refactor and clarify various documentation sections * Refine warnings and info boxes across multiple docs * Refactor and simplify Japanese documentation content * Update package.json to include mintlify as a dependency and add pnpm-lock.yaml for dependency management * Update blog link and add description in docs.json --------- Co-authored-by: Junyan Chin <[email protected]>
77 lines
2.4 KiB
Plaintext
77 lines
2.4 KiB
Plaintext
---
|
|
title: "调试插件运行时、CLI、SDK"
|
|
---
|
|
|
|
<Info>
|
|
插件运行时、CLI、SDK 开源在: https://github.com/langbot-app/langbot-plugin-sdk
|
|
</Info>
|
|
|
|
Clone 插件运行时源码:
|
|
|
|
```bash
|
|
git clone https://github.com/langbot-app/langbot-plugin-sdk
|
|
```
|
|
|
|
进入插件运行时目录,安装依赖:
|
|
|
|
```bash
|
|
cd langbot-plugin-sdk
|
|
uv sync --dev
|
|
```
|
|
|
|
此时,uv 将自动为您创建虚拟环境(.venv),若您的编辑器询问您是否使用此虚拟环境,请选择`是`。
|
|
|
|
<img
|
|
width="600"
|
|
src="/images/zh/develop/confirm_venv.png"
|
|
/>
|
|
|
|
或者请您手动激活此虚拟环境:
|
|
|
|
```bash
|
|
source .venv/bin/activate
|
|
```
|
|
|
|
## 启动插件运行时
|
|
|
|
```bash
|
|
lbp rt
|
|
```
|
|
|
|
请确保`lbp`命令是该目录下的虚拟环境中的`lbp`可执行文件,或通过`python -m langbot_plugin.cli.__init__ rt`启动。
|
|
|
|
Plugin Runtime 接受以下参数:
|
|
|
|
- `--debug-only`: 不启动`data/plugins`目录下的插件,仅允许通过调试连接加载插件。
|
|
- `--ws-debug-port`: 监听的调试端口,默认是`5401`。
|
|
- `--ws-control-port`: 监听的控制端口(供 LangBot 主程序连接),默认是`5400`。
|
|
- `-s`: 使用`stdio`接受控制连接。**仅在生产环境使用**。
|
|
- `--skip-deps-check`: 为了确保插件依赖均已安装,Runtime 会在每次启动时检查并安装所有已安装插件的依赖。携带此参数可禁用此检查。
|
|
|
|
### 使 LangBot 连接到此运行时
|
|
|
|
在 LangBot 的`data/config.yaml`中配置`plugin.runtime_ws_url`为`ws://localhost:5400/control/ws`。
|
|
|
|
```yaml
|
|
plugin:
|
|
runtime_ws_url: ws://localhost:5400/control/ws
|
|
```
|
|
|
|
并在启动 LangBot 主程序时携带启动参数`--standalone-runtime`(如:`uv run main.py --standalone-runtime`)。\
|
|
重启 LangBot,将会使用 WebSocket 连接到此运行时。
|
|
|
|
## langbot-plugin-sdk 架构
|
|
|
|
本代码库中包含以下内容:
|
|
|
|
- `langbot_plugin.api`:插件相关实体和 API 定义。
|
|
- `langbot_plugin.assets`:插件模板。
|
|
- `langbot_plugin.cli`:插件开发 CLI 工具。
|
|
- `langbot_plugin.entities`:插件系统中非 API 定义的相关实体。
|
|
- `langbot_plugin.runtime`:插件运行时和底层通信(stdio 和 websocket)实现。
|
|
|
|
## `lbp` CLI 工具
|
|
|
|
CLI 工具提供 Runtime 启动、插件初始化、插件组件管理、Marketplace 交互等功能。
|
|
|
|
详细的程序入口请查看[`langbot_plugin.cli.__init__`](https://github.com/langbot-app/langbot-plugin-sdk/blob/main/src/langbot_plugin/cli/__init__.py)。 |