86 lines
3.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PicoBot 常用命令
```bash
# 编译
cargo build
# 启动网关 (默认 127.0.0.1:19876)
cargo run -- gateway
# 检查核心、配置相关和可选运行依赖;结构化输出加 --json
picobot health
picobot health --json
# 覆盖监听地址和端口
cargo run -- gateway --host 0.0.0.0 --port 19876
# Docker Compose 默认监听并发布 0.0.0.0:19876也可分别覆盖
PICOBOT_GATEWAY_HOST=0.0.0.0 PICOBOT_PUBLISH_HOST=192.168.1.10 PICOBOT_GATEWAY_PORT=19876 docker compose up -d
# WebUI 随 Gateway 提供,浏览器打开
# http://127.0.0.1:19876/
# 为新浏览器生成 5 分钟有效的一次性配对码
picobot pair
# 撤销全部设备并生成新配对码
picobot pair --revoke-all
# Docker 部署:必须在 Gateway 容器内执行,保证请求来自容器回环地址
docker compose exec picobot picobot pair --gateway-url http://127.0.0.1:19876
# 使用仓库测试 Compose 文件时
docker compose -f docker-compose.test.yml exec picobot picobot pair --gateway-url http://127.0.0.1:19876
# 修改 WebUI 后独立检查Node.js 20+
cd webui
npm ci
npm run check
npm run build
# cargo build 会增量生成并嵌入正式 WebUI 资源
cd ..
cargo build
# 首次配对并启动 CLI 客户端;后续可直接运行 chat
cargo run -- chat --pair-code <CODE>
cargo run -- chat
# 浏览器工具依赖PicoBot 验证版本)
npm install -g agent-browser@0.33.0
agent-browser install
# Linux 缺少浏览器系统库时改用agent-browser install --with-deps
# 安装并启动 Linux systemd 用户服务
picobot service install
picobot service start
# 查看、重启或停止服务
picobot service status
picobot service restart
picobot service stop
# 停止、禁用并删除服务
picobot service uninstall
# 运行单元测试
cargo test --lib
# 运行离线集成/协议测试
cargo test --test test_scheduler
cargo test --test test_request_format
# 运行代码检查Rust 修改必跑)
cargo clippy --all-targets --all-features -- -D warnings
# 运行模型 API 集成测试(需配置 tests/test.env
cargo test --test test_integration -- --ignored
cargo test --test test_tool_calling -- --ignored
```
`test_scheduler``test_request_format` 不需要 API Key也没有标记 `#[ignore]`。只有会真实调用 Provider 的测试需要从 `tests/test.env.example` 创建 `tests/test.env` 后使用 `-- --ignored`
最终用户使用 WebUI 不需要单独构建;开发源码采用 Svelte 5、Vite 和 Bits UI`cargo build` 会增量生成前端到 Cargo `OUT_DIR` 并嵌入二进制生成产物不提交。WebUI 支持在线聊天、动态斜杠命令补全、日志、任务、记忆以及 `config.json``USER.md``AGENTS.md` 编辑。新设备默认必须配对,管理 API 与 WebSocket 共用设备鉴权;非回环部署仍需要 TLS。
配对码签发接口同时校验真实回环来源和 `~/.picobot/web_admin_token`。Docker 发布端口上的宿主机请求在容器内不是回环连接,因此应使用 `docker compose exec` 在 Gateway 容器中运行 `picobot pair`;不要手工读取或传递管理密钥。配对码为 8 位、5 分钟有效且只能消费一次。