Files
openclaw/docs/zh-CN/start/setup.md

154 lines
4.8 KiB
Markdown
Raw Normal View History

2026-02-01 22:47:44 +01:00
---
read_when:
- 设置新机器
- 你想要"最新最好的"而不破坏你的个人设置
summary: 设置指南:在保持最新的同时保持你的 OpenClaw 设置个性化
2026-02-01 22:47:44 +01:00
title: 设置
x-i18n:
generated_at: "2026-02-03T07:54:27Z"
2026-02-01 22:47:44 +01:00
model: claude-opus-4-5
provider: pi
source_hash: b7f4bd657d0df4feb5035c9f5ee727f9c67b991e9cedfc7768f99d010553fa01
source_path: start/setup.md
workflow: 15
---
# 设置
最后更新2026-01-01
## 太长不看
2026-02-01 22:47:44 +01:00
- **个性化设置存放在仓库之外:** `~/.openclaw/workspace`(工作区)+ `~/.openclaw/openclaw.json`(配置)。
- **稳定工作流:** 安装 macOS 应用;让它运行内置的 Gateway 网关。
- **前沿工作流:** 通过 `pnpm gateway:watch` 自己运行 Gateway 网关,然后让 macOS 应用以本地模式连接。
2026-02-01 22:47:44 +01:00
## 先决条件(从源码)
2026-02-01 22:47:44 +01:00
- Node `>=22`
- `pnpm`
- Docker可选仅用于容器化设置/e2e — 参阅 [Docker](/install/docker)
2026-02-01 22:47:44 +01:00
## 个性化策略(让更新不会造成问题)
2026-02-01 22:47:44 +01:00
如果你想要"100% 为我定制"*并且*易于更新,将你的自定义内容保存在:
2026-02-01 22:47:44 +01:00
- **配置:** `~/.openclaw/openclaw.json`JSON/JSON5 格式)
- **工作区:** `~/.openclaw/workspace`Skills、提示、记忆将其设为私有 git 仓库)
2026-02-01 22:47:44 +01:00
引导一次:
2026-02-01 22:47:44 +01:00
```bash
openclaw setup
```
在此仓库内部,使用本地 CLI 入口:
2026-02-01 22:47:44 +01:00
```bash
openclaw setup
```
如果你还没有全局安装,通过 `pnpm openclaw setup` 运行它。
2026-02-01 22:47:44 +01:00
## 稳定工作流macOS 应用优先)
1. 安装并启动 **OpenClaw.app**(菜单栏)。
2. 完成新手引导/权限检查清单TCC 提示)。
3. 确保 Gateway 网关是**本地**并正在运行(应用管理它)。
4. 链接表面示例WhatsApp
2026-02-01 22:47:44 +01:00
```bash
openclaw channels login
```
5. 完整性检查:
2026-02-01 22:47:44 +01:00
```bash
openclaw health
```
如果你的构建版本中没有新手引导:
2026-02-01 22:47:44 +01:00
- 运行 `openclaw setup`,然后 `openclaw channels login`,然后手动启动 Gateway 网关(`openclaw gateway`)。
2026-02-01 22:47:44 +01:00
## 前沿工作流(在终端中运行 Gateway 网关)
2026-02-01 22:47:44 +01:00
目标:开发 TypeScript Gateway 网关,获得热重载,保持 macOS 应用 UI 连接。
2026-02-01 22:47:44 +01:00
### 0)(可选)也从源码运行 macOS 应用
2026-02-01 22:47:44 +01:00
如果你也想让 macOS 应用保持前沿:
2026-02-01 22:47:44 +01:00
```bash
./scripts/restart-mac.sh
```
### 1) 启动开发 Gateway 网关
2026-02-01 22:47:44 +01:00
```bash
pnpm install
pnpm gateway:watch
```
`gateway:watch` 以监视模式运行 Gateway 网关,并在 TypeScript 更改时重新加载。
2026-02-01 22:47:44 +01:00
### 2) 将 macOS 应用指向你正在运行的 Gateway 网关
**OpenClaw.app** 中:
2026-02-01 22:47:44 +01:00
- 连接模式:**本地**
应用将连接到在配置端口上运行的 Gateway 网关。
2026-02-01 22:47:44 +01:00
### 3) 验证
- 应用内 Gateway 网关状态应显示 **"Using existing gateway …"**
- 或通过 CLI
2026-02-01 22:47:44 +01:00
```bash
openclaw health
```
### 常见陷阱
- **端口错误:** Gateway 网关 WS 默认为 `ws://127.0.0.1:18789`;保持应用 + CLI 在同一端口上。
2026-02-01 22:47:44 +01:00
- **状态存储位置:**
- 凭证:`~/.openclaw/credentials/`
2026-02-01 22:47:44 +01:00
- 会话:`~/.openclaw/agents/<agentId>/sessions/`
- 日志:`/tmp/openclaw/`
## 凭证存储映射
2026-02-01 22:47:44 +01:00
在调试认证或决定备份什么时使用此映射:
2026-02-01 22:47:44 +01:00
- **WhatsApp**`~/.openclaw/credentials/whatsapp/<accountId>/creds.json`
- **Telegram bot token**:配置/环境变量或 `channels.telegram.tokenFile`
- **Discord bot token**:配置/环境变量(尚不支持令牌文件)
- **Slack tokens**:配置/环境变量(`channels.slack.*`
2026-02-01 22:47:44 +01:00
- **配对允许列表**`~/.openclaw/credentials/<channel>-allowFrom.json`
- **模型认证配置文件**`~/.openclaw/agents/<agentId>/agent/auth-profiles.json`
- **旧版 OAuth 导入**`~/.openclaw/credentials/oauth.json`
更多详情:[安全](/gateway/security#credential-storage-map)。
## 更新(不破坏你的设置)
2026-02-01 22:47:44 +01:00
-`~/.openclaw/workspace``~/.openclaw/` 保持为"你的东西";不要将个人提示/配置放入 `openclaw` 仓库。
- 更新源码:`git pull` + `pnpm install`(当锁文件更改时)+ 继续使用 `pnpm gateway:watch`
2026-02-01 22:47:44 +01:00
## Linuxsystemd 用户服务)
Linux 安装使用 systemd **用户**服务。默认情况下systemd 在注销/空闲时停止用户服务,这会终止 Gateway 网关。新手引导会尝试为你启用 lingering可能提示 sudo。如果仍然关闭运行
2026-02-01 22:47:44 +01:00
```bash
sudo loginctl enable-linger $USER
```
对于常驻或多用户服务器,考虑使用**系统**服务而不是用户服务(不需要 lingering。参阅 [Gateway 网关运行手册](/gateway) 了解 systemd 说明。
2026-02-01 22:47:44 +01:00
## 相关文档
- [Gateway 网关运行手册](/gateway)(标志、监督、端口)
- [Gateway 网关配置](/gateway/configuration)(配置模式 + 示例)
2026-02-01 22:47:44 +01:00
- [Discord](/channels/discord) 和 [Telegram](/channels/telegram)(回复标签 + replyToMode 设置)
- [OpenClaw 助手设置](/start/openclaw)
- [macOS 应用](/platforms/macos)Gateway 网关生命周期)