Compare commits
10 Commits
e26c811b51
...
966f7e0ac8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
966f7e0ac8 | ||
|
|
1a84adb97b | ||
|
|
5e9d63ae1a | ||
|
|
cde26a8f7f | ||
|
|
40983ec0ee | ||
|
|
68c1bee826 | ||
|
|
0108f7fa2f | ||
|
|
25f31c596d | ||
|
|
d33688454b | ||
|
|
8385460172 |
82
README.md
82
README.md
@@ -2,8 +2,7 @@
|
||||
|
||||
<p align="center">最近更新于:2026年2月13日</p>
|
||||
|
||||
<!-- TODO: Hero 图片(中文文件名) -->
|
||||
<!--  -->
|
||||
<p align="center"><img src="images/hero-banner.png" alt="龙虾 Claude AI 拼车 — 扫码加入群聊" width="600"></p>
|
||||
|
||||
说实话,我之前一直想要一个能真正帮我做事的 AI 助手,后来发现了 OpenClaw(龙虾AI)。它不只是聊天工具,能直接帮你清理邮箱、管理日程、订机票,而且完全本地部署、数据不出本机。最重要的是,还能免费白嫖 MiniMax 大模型7天。配置过程也很简单,一行命令搞定,不用折腾环境。这篇教程把我踩过的坑都整理好了,照着做5分钟就能跑起来。
|
||||
|
||||
@@ -20,7 +19,7 @@
|
||||
|
||||
* **方法二:AWS Bedrock $200(适合海外用户)**:新用户赠送 $200,免费用 Claude 3个月。查看:[AWS Bedrock](#方法二白嫖-aws-bedrock-claude)
|
||||
|
||||
* **方法三:合租拼车(长期使用,适合国内用户)**:Claude Pro/Code 合租,14元/月起。查看:[合租拼车](#方法三通过合租拼车降低-claude-价格)
|
||||
* **方法三:Claude 拼车(长期使用,适合国内用户)**:250元/月起,$25/天额度。查看:[Claude 拼车](#方法三通过合租拼车降低-claude-价格适合国内用户)
|
||||
|
||||
</blockquote>
|
||||
|
||||
@@ -69,12 +68,11 @@ OpenClaw 不只是聊天,而是真正能**帮你做事**的 AI 助手:
|
||||
|
||||
| 步骤 | macOS | Windows |
|
||||
|------|-------|---------|
|
||||
| 1 | 检查/安装 Node.js 22+(通过 Homebrew) | 检查/安装 WSL2 + Ubuntu 24.04 |
|
||||
| 2 | 安装 OpenClaw(静默安装) | 启用 systemd + 安装 Node.js 22+ |
|
||||
| 3 | 启动配置向导 | 安装 OpenClaw + 网关守护进程 |
|
||||
| 4 | — | 启动配置向导 |
|
||||
| 1 | 检查/安装 Node.js 22+(通过 Homebrew) | 检查/安装 Node.js 22+(通过 winget / Chocolatey) |
|
||||
| 2 | 安装 OpenClaw | 安装 OpenClaw |
|
||||
| 3 | 启动配置向导 | 启动配置向导 |
|
||||
|
||||
脚本不会在 Homebrew (macOS) 或 WSL (Windows) 之外安装任何东西。
|
||||
脚本不会在 Homebrew (macOS) 或 npm (Windows) 之外安装任何东西。
|
||||
|
||||
### macOS
|
||||
|
||||
@@ -86,13 +84,13 @@ curl -fsSL https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/in
|
||||
|
||||
### Windows
|
||||
|
||||
以**管理员身份**打开 PowerShell,运行:
|
||||
打开 PowerShell,运行:
|
||||
|
||||
```powershell
|
||||
iwr -useb https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/install-windows.ps1 | iex
|
||||
```
|
||||
|
||||
> **Windows 说明:** 脚本会自动安装 WSL2(Windows 子系统 Linux)。可能需要重启,重启后再次运行脚本即可。
|
||||
> **Windows 说明:** 脚本会自动安装 Node.js(通过 winget 或 Chocolatey)+ OpenClaw。如果无法自动安装 Node.js,请先从 [nodejs.cn](https://nodejs.cn/download/) 手动下载安装。
|
||||
|
||||
### 配置流程
|
||||
|
||||
@@ -235,12 +233,20 @@ AWS Bedrock 为新用户提供**最高 $200 免费额度**(注册送 $100 +
|
||||
|
||||
#### 8. 运行一键配置脚本
|
||||
|
||||
拿到 Access Key 后,在终端运行:
|
||||
拿到 Access Key 后,运行一键配置脚本:
|
||||
|
||||
**macOS / Linux:**
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/configure-aws-bedrock.sh | bash
|
||||
```
|
||||
|
||||
**Windows(管理员 PowerShell):**
|
||||
|
||||
```powershell
|
||||
iwr -useb https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/configure-aws-bedrock.ps1 | iex
|
||||
```
|
||||
|
||||
脚本会提示你输入上一步获取的 Access Key ID 和 Secret Access Key,然后自动完成配置、重启网关并测试连接。
|
||||
|
||||

|
||||
@@ -254,41 +260,51 @@ curl -fsSL https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/co
|
||||
| **Claude Sonnet 4.5(默认)** | `global.anthropic.claude-sonnet-4-5-20250929-v1:0` | 有 | 日常开发,性价比最高 |
|
||||
| Claude Haiku 4.5 | `global.anthropic.claude-haiku-4-5-20251001-v1:0` | 无 | 轻量任务,速度最快 |
|
||||
|
||||
> **配置参考**:完整配置示例请查看 [pahud 的 Gist](https://gist.github.com/pahud/8965bfeec441225009abfa96f4751f48)
|
||||
|
||||
> **注意**:AWS Bedrock 需要海外信用卡和地址,国内用户可能无法注册。国内用户建议选择方法一(MiniMax)或方法三(合租)。
|
||||
> **注意**:AWS Bedrock 需要海外信用卡和地址,国内用户可能无法注册。国内用户建议选择方法一(MiniMax)或方法三(拼车)。
|
||||
|
||||
---
|
||||
|
||||
## 方法三:通过合租/拼车降低 Claude 价格(适合国内用户)
|
||||
## 方法三:通过合租拼车降低 Claude 价格(适合国内用户)
|
||||
|
||||
如果你需要长期使用 Claude,但觉得官方 API 太贵,可以通过第三方平台**合租 Claude Pro** 或 **Claude Code 订阅**,价格只有原价的 1/5 左右。
|
||||
Claude 官方价格不便宜 — Claude Code $100/月(~750元),Claude Max $200/月(~1,500元)。通过**拼车**,你可以用零头的价格获得远超官方的用量。
|
||||
|
||||
### 什么是 Claude 合租/拼车?
|
||||
<p align="center"><img src="images/hero-banner.png" alt="龙虾 Claude AI 拼车" width="500"></p>
|
||||
|
||||
多个用户共享一个 Claude Pro 或 Claude Code 订阅账号,分摊费用。第三方平台负责管理账号和分配使用额度,每个用户都能正常使用 Claude,但价格大幅降低。
|
||||
### 我们的拼车服务
|
||||
|
||||
### 推荐平台
|
||||
| 套餐 | 价格 | 每日额度 | 每月等值 | 适合人群 |
|
||||
|------|-----|---------|---------|---------|
|
||||
| 标准版 | **250元/月** | $25/天 | ~$775/月 | 日常开发,轻度使用 |
|
||||
| 进阶版 | **450元/月** | $50/天 | ~$1,550/月 | 重度开发,多项目并行 |
|
||||
| 团队版 | **900元/月** | $100/天 | ~$3,100/月 | 团队协作,不限量写代码 |
|
||||
|
||||
| 平台 | Claude Code 价格 | Claude Pro 价格 | 特点 |
|
||||
|------|----------------|----------------|------|
|
||||
| 星际放映厅 | 14元/月起 | 20元/月起 | 有备案,支持发票 |
|
||||
| 其他平台 | 10-30元/月 | 15-40元/月 | 价格波动大 |
|
||||
> **对比官方**:标准版 250元/月 就能获得 **$775/月** 的 API 用量,远超 Claude Code 官方的 $100/月,价格却只有官方的 **1/3**。
|
||||
|
||||
> **风险提示**:合租账号存在以下风险:
|
||||
> - 可能被官方封号(虽然概率较低)
|
||||
> - 平台跑路风险
|
||||
> - 使用额度限制
|
||||
> - 不适合企业/商业用途
|
||||
**我们的优势:**
|
||||
- **极速拼车**:即刻出发,无需等待
|
||||
- **官方渠道**:安全可靠,不是黑卡
|
||||
- **封号重练**:无忧售后,封号免费换号
|
||||
|
||||
### 如何在 OpenClaw 中使用合租账号?
|
||||
### 如何加入?
|
||||
|
||||
合租平台通常提供 API Key 或 共享账号,你可以:
|
||||
扫码加入 **Claude 拼车群**,或者加我微信咨询:
|
||||
|
||||
1. 如果提供 **API Key**:在 OpenClaw 配置向导中选择 **Anthropic**,填入平台提供的 API Key
|
||||
2. 如果提供 **共享账号**:联系平台客服,询问是否支持 OpenClaw 接入
|
||||
<p align="center">
|
||||
<img src="images/my-group-wechat.JPG" alt="Claude 拼车群" width="250">
|
||||
|
||||
<img src="images/my-wechat-qr.JPG" alt="加我微信" width="250">
|
||||
</p>
|
||||
<p align="center">👈 扫码加群 加我微信咨询 👉</p>
|
||||
|
||||
> **我的建议**:合租适合轻度使用,如果你是重度用户或企业用途,建议选择方法二(AWS Bedrock)或直接购买 Anthropic 官方 API。
|
||||
### 如何在 OpenClaw 中使用拼车账号?
|
||||
|
||||
拼车后你会收到一个 API Key,在 OpenClaw 中配置:
|
||||
|
||||
1. 运行 `openclaw onboard`
|
||||
2. 选择 **Anthropic**
|
||||
3. 填入我们提供的 API Key
|
||||
|
||||
就可以在 OpenClaw 中直接使用 Claude 了。
|
||||
|
||||
---
|
||||
|
||||
|
||||
246
configure-aws-bedrock.ps1
Normal file
246
configure-aws-bedrock.ps1
Normal file
@@ -0,0 +1,246 @@
|
||||
# ─────────────────────────────────────────────
|
||||
# OpenClaw AWS Bedrock 配置脚本 (Windows)
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
||||
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
||||
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
||||
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg }
|
||||
|
||||
try {
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor White
|
||||
Write-Host " OpenClaw AWS Bedrock 配置器 (Windows)" -ForegroundColor White
|
||||
Write-Host "========================================" -ForegroundColor White
|
||||
Write-Host ""
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 1: 检查 OpenClaw
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在检查 OpenClaw 安装..."
|
||||
|
||||
try {
|
||||
$null = Get-Command openclaw -ErrorAction Stop
|
||||
Write-Ok "已找到 OpenClaw。"
|
||||
} catch {
|
||||
Write-Err "未找到 OpenClaw。请先运行安装脚本:`niwr -useb https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/install-windows.ps1 | iex"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 2: 获取 AWS 凭证
|
||||
# ─────────────────────────────────────────────
|
||||
$openclawDir = Join-Path $env:USERPROFILE ".openclaw"
|
||||
$envFile = Join-Path $openclawDir ".env"
|
||||
$configFile = Join-Path $openclawDir "openclaw.json"
|
||||
|
||||
$skipInput = $false
|
||||
|
||||
if (Test-Path $envFile) {
|
||||
$envContent = Get-Content $envFile -Raw
|
||||
if ($envContent -match "AWS_ACCESS_KEY_ID") {
|
||||
Write-Warn "检测到已存在 AWS 凭证配置"
|
||||
$useExisting = Read-Host "是否使用现有凭证? [Y/n]"
|
||||
if ($useExisting -ne "n" -and $useExisting -ne "N") {
|
||||
$skipInput = $true
|
||||
# 加载现有凭证
|
||||
foreach ($line in (Get-Content $envFile)) {
|
||||
if ($line -match '^\s*export\s+(\w+)="?([^"]*)"?') {
|
||||
[Environment]::SetEnvironmentVariable($Matches[1], $Matches[2], "Process")
|
||||
}
|
||||
}
|
||||
Write-Ok "使用现有凭证"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $skipInput) {
|
||||
Write-Info "请输入你的 AWS Access Key ID:"
|
||||
Write-Host "(从 IAM 控制台获取)" -ForegroundColor Yellow
|
||||
$accessKey = Read-Host
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($accessKey)) {
|
||||
Write-Err "AWS Access Key ID 不能为空"
|
||||
}
|
||||
|
||||
Write-Info "请输入你的 AWS Secret Access Key:"
|
||||
$secretKey = Read-Host -AsSecureString
|
||||
$secretKeyPlain = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
|
||||
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($secretKey)
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($secretKeyPlain)) {
|
||||
Write-Err "AWS Secret Access Key 不能为空"
|
||||
}
|
||||
|
||||
Write-Info "请输入 AWS 区域 (默认: us-west-2):"
|
||||
$region = Read-Host
|
||||
if ([string]::IsNullOrWhiteSpace($region)) {
|
||||
$region = "us-west-2"
|
||||
}
|
||||
|
||||
$env:AWS_ACCESS_KEY_ID = $accessKey
|
||||
$env:AWS_SECRET_ACCESS_KEY = $secretKeyPlain
|
||||
$env:AWS_REGION = $region
|
||||
|
||||
Write-Ok "已获取 AWS 凭证"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 3: 创建环境变量文件
|
||||
# ─────────────────────────────────────────────
|
||||
if (-not $skipInput) {
|
||||
Write-Info "正在创建 $envFile..."
|
||||
|
||||
if (-not (Test-Path $openclawDir)) {
|
||||
New-Item -ItemType Directory -Path $openclawDir -Force | Out-Null
|
||||
}
|
||||
|
||||
# 备份
|
||||
if (Test-Path $envFile) {
|
||||
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||
Copy-Item $envFile "$envFile.backup.$timestamp"
|
||||
Write-Warn "已备份现有 .env 文件"
|
||||
}
|
||||
|
||||
$envContent = @"
|
||||
# AWS Bedrock Credentials
|
||||
export AWS_ACCESS_KEY_ID="$($env:AWS_ACCESS_KEY_ID)"
|
||||
export AWS_SECRET_ACCESS_KEY="$($env:AWS_SECRET_ACCESS_KEY)"
|
||||
export AWS_REGION="$($env:AWS_REGION)"
|
||||
"@
|
||||
|
||||
Set-Content -Path $envFile -Value $envContent -Encoding UTF8
|
||||
Write-Ok "已创建环境变量文件"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 4: 配置 openclaw.json
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在配置 $configFile..."
|
||||
|
||||
# 备份
|
||||
if (Test-Path $configFile) {
|
||||
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||
Copy-Item $configFile "$configFile.backup.$timestamp"
|
||||
Write-Warn "已备份现有 openclaw.json 文件"
|
||||
}
|
||||
|
||||
$awsRegion = if ($env:AWS_REGION) { $env:AWS_REGION } else { "us-west-2" }
|
||||
|
||||
$configContent = @"
|
||||
{
|
||||
"gateway": {
|
||||
"mode": "local"
|
||||
},
|
||||
"models": {
|
||||
"providers": {
|
||||
"amazon-bedrock": {
|
||||
"baseUrl": "https://bedrock-runtime.$awsRegion.amazonaws.com",
|
||||
"api": "bedrock-converse-stream",
|
||||
"auth": "aws-sdk",
|
||||
"models": [
|
||||
{
|
||||
"id": "global.anthropic.claude-opus-4-6-v1",
|
||||
"name": "Claude Opus 4.6 (Bedrock)",
|
||||
"reasoning": true,
|
||||
"input": ["text", "image"],
|
||||
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||
"contextWindow": 200000,
|
||||
"maxTokens": 8192
|
||||
},
|
||||
{
|
||||
"id": "global.anthropic.claude-opus-4-5-20251001-v1:0",
|
||||
"name": "Claude Opus 4.5 (Bedrock)",
|
||||
"reasoning": true,
|
||||
"input": ["text", "image"],
|
||||
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||
"contextWindow": 200000,
|
||||
"maxTokens": 8192
|
||||
},
|
||||
{
|
||||
"id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
||||
"name": "Claude Sonnet 4.5 (Bedrock)",
|
||||
"reasoning": true,
|
||||
"input": ["text", "image"],
|
||||
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||
"contextWindow": 200000,
|
||||
"maxTokens": 8192
|
||||
},
|
||||
{
|
||||
"id": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
|
||||
"name": "Claude Haiku 4.5 (Bedrock)",
|
||||
"reasoning": false,
|
||||
"input": ["text", "image"],
|
||||
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||
"contextWindow": 200000,
|
||||
"maxTokens": 8192
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": {
|
||||
"primary": "amazon-bedrock/global.anthropic.claude-sonnet-4-5-20250929-v1:0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"@
|
||||
|
||||
Set-Content -Path $configFile -Value $configContent -Encoding UTF8
|
||||
Write-Ok "已配置 openclaw.json"
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 5: 设置环境变量到当前会话
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在设置环境变量..."
|
||||
|
||||
# 设置为用户级环境变量(持久化)
|
||||
[Environment]::SetEnvironmentVariable("AWS_ACCESS_KEY_ID", $env:AWS_ACCESS_KEY_ID, "User")
|
||||
[Environment]::SetEnvironmentVariable("AWS_SECRET_ACCESS_KEY", $env:AWS_SECRET_ACCESS_KEY, "User")
|
||||
[Environment]::SetEnvironmentVariable("AWS_REGION", $env:AWS_REGION, "User")
|
||||
|
||||
Write-Ok "已设置用户环境变量(新 PowerShell 窗口自动生效)"
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 6: 完成
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host " 配置完成!" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host " 配置摘要:" -ForegroundColor White
|
||||
Write-Host " Provider: AWS Bedrock" -ForegroundColor Cyan
|
||||
Write-Host " Region: $awsRegion" -ForegroundColor Cyan
|
||||
Write-Host " 默认模型: Claude Sonnet 4.5" -ForegroundColor Cyan
|
||||
Write-Host " 已配置模型:" -ForegroundColor White
|
||||
Write-Host " * Claude Opus 4.6" -ForegroundColor Cyan
|
||||
Write-Host " * Claude Opus 4.5" -ForegroundColor Cyan
|
||||
Write-Host " * Claude Sonnet 4.5" -ForegroundColor Cyan
|
||||
Write-Host " * Claude Haiku 4.5" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host " 使用方法:" -ForegroundColor White
|
||||
Write-Host " cd 你的项目路径" -ForegroundColor Gray
|
||||
Write-Host " openclaw" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host " 测试连接:" -ForegroundColor White
|
||||
Write-Host " openclaw agent --session-id test --message `"Say OK`" --local" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host " 所需 IAM 权限:" -ForegroundColor White
|
||||
Write-Host " * bedrock:InvokeModel" -ForegroundColor Yellow
|
||||
Write-Host " * bedrock:InvokeModelWithResponseStream" -ForegroundColor Yellow
|
||||
Write-Host " 或使用托管策略:AmazonBedrockFullAccess" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
} catch {
|
||||
Write-Host ""
|
||||
Write-Host "[错误] 脚本执行失败: $_" -ForegroundColor Red
|
||||
Write-Host ""
|
||||
} finally {
|
||||
Write-Host ""
|
||||
Read-Host "按 Enter 键关闭此窗口"
|
||||
}
|
||||
BIN
images/hero-banner.png
Normal file
BIN
images/hero-banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 MiB |
BIN
images/my-group-wechat.JPG
Normal file
BIN
images/my-group-wechat.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 284 KiB |
BIN
images/my-wechat-qr.JPG
Normal file
BIN
images/my-wechat-qr.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 KiB |
BIN
images/pinche.png
Normal file
BIN
images/pinche.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 MiB |
218
install-windows-en.ps1
Normal file
218
install-windows-en.ps1
Normal file
@@ -0,0 +1,218 @@
|
||||
# ─────────────────────────────────────────────
|
||||
# OpenClaw One-Click Installer (Windows)
|
||||
# Installs Node.js + OpenClaw, runs natively
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
function Write-Info($msg) { Write-Host "[INFO] $msg" -ForegroundColor Cyan }
|
||||
function Write-Ok($msg) { Write-Host "[DONE] $msg" -ForegroundColor Green }
|
||||
function Write-Warn($msg) { Write-Host "[WARN] $msg" -ForegroundColor Yellow }
|
||||
function Write-Err($msg) { Write-Host "[ERROR] $msg" -ForegroundColor Red; throw $msg }
|
||||
|
||||
function Write-Header {
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor White
|
||||
Write-Host " OpenClaw One-Click Installer (Windows)" -ForegroundColor White
|
||||
Write-Host "========================================" -ForegroundColor White
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Write-Header
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Step 1: Check / Install Node.js 22+
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "Checking Node.js..."
|
||||
|
||||
$needsNode = $true
|
||||
|
||||
try {
|
||||
$nodeVersion = (node -v 2>$null)
|
||||
if ($nodeVersion -match "v(\d+)") {
|
||||
$major = [int]$Matches[1]
|
||||
if ($major -ge 22) {
|
||||
Write-Ok "Found Node.js $nodeVersion"
|
||||
$needsNode = $false
|
||||
} else {
|
||||
Write-Warn "Found Node.js $nodeVersion, but v22+ is required. Upgrading..."
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Warn "Node.js not found."
|
||||
}
|
||||
|
||||
if ($needsNode) {
|
||||
Write-Info "Installing Node.js 22..."
|
||||
|
||||
$installed = $false
|
||||
|
||||
# Method 1: winget (built into Windows 11 / Windows 10)
|
||||
if (-not $installed -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "Installing via winget..."
|
||||
winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$installed = $true
|
||||
Write-Ok "Node.js installed via winget"
|
||||
}
|
||||
}
|
||||
|
||||
# Method 2: Chocolatey
|
||||
if (-not $installed -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "Installing via Chocolatey..."
|
||||
choco install nodejs-lts -y 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$installed = $true
|
||||
Write-Ok "Node.js installed via Chocolatey"
|
||||
}
|
||||
}
|
||||
|
||||
# Method 3: Manual download prompt
|
||||
if (-not $installed) {
|
||||
Write-Err "Could not install Node.js automatically. Please install manually and re-run this script:`n`n Download: https://nodejs.org/en/download/`n`n After installing, reopen PowerShell and run this script again."
|
||||
}
|
||||
|
||||
# Refresh PATH
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
# Verify installation
|
||||
try {
|
||||
$nodeVersion = (node -v 2>$null)
|
||||
Write-Ok "Node.js $nodeVersion installed successfully"
|
||||
} catch {
|
||||
Write-Err "Node.js verification failed after install. Please close and reopen PowerShell, then try again."
|
||||
}
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Step 2: Check / Install Git
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "Checking Git..."
|
||||
|
||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||
Write-Ok "Found Git."
|
||||
} else {
|
||||
Write-Info "Installing Git (required by OpenClaw dependencies)..."
|
||||
|
||||
$gitInstalled = $false
|
||||
|
||||
if (-not $gitInstalled -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "Installing Git via winget..."
|
||||
winget install Git.Git --accept-package-agreements --accept-source-agreements 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$gitInstalled = $true
|
||||
Write-Ok "Git installed via winget"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $gitInstalled -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "Installing Git via Chocolatey..."
|
||||
choco install git -y 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$gitInstalled = $true
|
||||
Write-Ok "Git installed via Chocolatey"
|
||||
}
|
||||
}
|
||||
|
||||
# Method 3: Direct download and silent install
|
||||
if (-not $gitInstalled) {
|
||||
Write-Info "Downloading Git installer directly..."
|
||||
$gitInstaller = Join-Path $env:TEMP "git-installer.exe"
|
||||
try {
|
||||
$releases = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest" -ErrorAction Stop
|
||||
$asset = $releases.assets | Where-Object { $_.name -match "Git-.*-64-bit\.exe$" } | Select-Object -First 1
|
||||
if ($asset) {
|
||||
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $gitInstaller -ErrorAction Stop
|
||||
Write-Info "Installing Git silently..."
|
||||
Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS" -Wait
|
||||
Remove-Item $gitInstaller -Force -ErrorAction SilentlyContinue
|
||||
$gitInstalled = $true
|
||||
Write-Ok "Git installed via direct download"
|
||||
}
|
||||
} catch {
|
||||
Write-Warn "Direct download failed: $_"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $gitInstalled) {
|
||||
Write-Err "Could not install Git automatically. Please install manually and re-run this script:`n`n Download: https://git-scm.com/download/win`n`n After installing, reopen PowerShell and run this script again."
|
||||
}
|
||||
|
||||
# Refresh PATH
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Step 3: Install OpenClaw
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "Checking OpenClaw..."
|
||||
|
||||
$needsInstall = $true
|
||||
|
||||
try {
|
||||
$null = Get-Command openclaw -ErrorAction Stop
|
||||
Write-Ok "Found OpenClaw."
|
||||
$needsInstall = $false
|
||||
} catch {
|
||||
Write-Info "Installing OpenClaw..."
|
||||
}
|
||||
|
||||
if ($needsInstall) {
|
||||
npm install -g openclaw@latest 2>&1 | Write-Host
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Err "OpenClaw installation failed. Please run manually: npm install -g openclaw@latest"
|
||||
}
|
||||
|
||||
# Refresh PATH
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
# Add npm global bin to PATH
|
||||
try {
|
||||
$npmPrefix = (npm config get prefix 2>$null).Trim()
|
||||
if ($npmPrefix) {
|
||||
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
if (-not ($userPath -split ";" | Where-Object { $_ -ieq $npmPrefix })) {
|
||||
[Environment]::SetEnvironmentVariable("Path", "$userPath;$npmPrefix", "User")
|
||||
$env:Path += ";$npmPrefix"
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
|
||||
Write-Ok "OpenClaw installed."
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Step 3: Launch interactive setup
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host " OpenClaw installed! Starting setup..." -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host " Tip: When the setup wizard asks for a provider," -ForegroundColor White
|
||||
Write-Host " choose MiniMax for a 7-day free trial - no credit card needed." -ForegroundColor White
|
||||
Write-Host " Sign up: https://platform.minimax.io" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
openclaw onboard --accept-risk --flow quickstart --node-manager npm --skip-skills
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host " Setup complete!" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host " Next steps:" -ForegroundColor White
|
||||
Write-Host " 1. Navigate to your project: cd your-project-path" -ForegroundColor Gray
|
||||
Write-Host " 2. Start OpenClaw: openclaw" -ForegroundColor Gray
|
||||
Write-Host " 3. Add skills (optional): openclaw configure --section skills" -ForegroundColor Gray
|
||||
Write-Host " 4. Browse available skills: openclaw skills" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
} catch {
|
||||
Write-Host ""
|
||||
Write-Host "[ERROR] Script failed: $_" -ForegroundColor Red
|
||||
Write-Host ""
|
||||
} finally {
|
||||
Write-Host ""
|
||||
Read-Host "Press Enter to close this window"
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
# ─────────────────────────────────────────────
|
||||
# OpenClaw 一键部署安装脚本 (Windows)
|
||||
# 安装 WSL2 + Ubuntu,然后在 WSL 中设置 OpenClaw
|
||||
# 安装 Node.js + OpenClaw,原生 Windows 运行
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
||||
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
||||
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
||||
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; exit 1 }
|
||||
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg }
|
||||
|
||||
function Write-Header {
|
||||
Write-Host ""
|
||||
@@ -18,154 +16,174 @@ function Write-Header {
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Write-Header
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 1: 检查 / 安装 WSL2
|
||||
# 步骤 1: 检查 / 安装 Node.js 22+
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在检查 WSL2 安装..."
|
||||
Write-Info "正在检查 Node.js..."
|
||||
|
||||
$wslInstalled = $false
|
||||
try {
|
||||
$wslOutput = wsl --status 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$wslInstalled = $true
|
||||
}
|
||||
} catch {
|
||||
$wslInstalled = $false
|
||||
}
|
||||
|
||||
# 检查 WSL 中是否有 Ubuntu
|
||||
$ubuntuAvailable = $false
|
||||
if ($wslInstalled) {
|
||||
$distros = wsl --list --quiet 2>&1
|
||||
if ($distros -match "Ubuntu") {
|
||||
$ubuntuAvailable = $true
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $wslInstalled -or -not $ubuntuAvailable) {
|
||||
Write-Info "正在安装 WSL2 和 Ubuntu 24.04..."
|
||||
Write-Warn "可能需要重启。重启后请再次运行此脚本。"
|
||||
|
||||
wsl --install -d Ubuntu-24.04
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Err "WSL2 安装失败。请手动安装:wsl --install -d Ubuntu-24.04"
|
||||
}
|
||||
|
||||
Write-Ok "WSL2 + Ubuntu 24.04 安装完成。"
|
||||
Write-Warn "如果提示重启,请重启计算机后再次运行此脚本。"
|
||||
|
||||
# 检查是否需要重启
|
||||
$restartNeeded = $false
|
||||
try {
|
||||
wsl --status 2>&1 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) { $restartNeeded = $true }
|
||||
} catch {
|
||||
$restartNeeded = $true
|
||||
}
|
||||
|
||||
if ($restartNeeded) {
|
||||
Write-Host ""
|
||||
Write-Warn "需要重启才能完成 WSL2 安装。"
|
||||
Write-Host "重启后,请再次运行此脚本。" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Read-Host "按 Enter 键退出"
|
||||
exit 0
|
||||
}
|
||||
} else {
|
||||
Write-Ok "已找到 WSL2 和 Ubuntu。"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 2: 在 WSL 中启用 systemd
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在配置 WSL 中的 systemd..."
|
||||
|
||||
$checkSystemd = wsl -d Ubuntu-24.04 -- bash -c "cat /etc/wsl.conf 2>/dev/null || echo ''"
|
||||
if ($checkSystemd -notmatch "systemd=true") {
|
||||
wsl -d Ubuntu-24.04 -- bash -c "echo '[boot]' | sudo tee /etc/wsl.conf > /dev/null && echo 'systemd=true' | sudo tee -a /etc/wsl.conf > /dev/null"
|
||||
Write-Ok "已在 /etc/wsl.conf 中启用 systemd"
|
||||
|
||||
# ─────────────────────────────────────────
|
||||
# 步骤 3: 重启 WSL
|
||||
# ─────────────────────────────────────────
|
||||
Write-Info "正在重启 WSL 以应用 systemd..."
|
||||
wsl --shutdown
|
||||
Start-Sleep -Seconds 3
|
||||
Write-Ok "WSL 已重启。"
|
||||
} else {
|
||||
Write-Ok "systemd 已启用。"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 4: 在 WSL 中安装 Node 22+
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在检查 WSL 中的 Node.js..."
|
||||
|
||||
$nodeCheck = wsl -d Ubuntu-24.04 -- bash -c "command -v node && node -v || echo 'NOT_FOUND'" 2>&1
|
||||
$needsNode = $true
|
||||
|
||||
if ($nodeCheck -notmatch "NOT_FOUND" -and $nodeCheck -match "v(\d+)") {
|
||||
$nodeVersion = [int]$Matches[1]
|
||||
if ($nodeVersion -ge 22) {
|
||||
Write-Ok "WSL 中已找到 Node.js v$nodeVersion (>= 22)。"
|
||||
try {
|
||||
$nodeVersion = (node -v 2>$null)
|
||||
if ($nodeVersion -match "v(\d+)") {
|
||||
$major = [int]$Matches[1]
|
||||
if ($major -ge 22) {
|
||||
Write-Ok "已找到 Node.js $nodeVersion"
|
||||
$needsNode = $false
|
||||
} else {
|
||||
Write-Warn "WSL 中已找到 Node.js v$nodeVersion,但需要 >= 22。正在升级..."
|
||||
Write-Warn "已找到 Node.js $nodeVersion,但需要 v22+,正在升级..."
|
||||
}
|
||||
} else {
|
||||
Write-Warn "WSL 中未找到 Node.js。"
|
||||
}
|
||||
} catch {
|
||||
Write-Warn "未找到 Node.js。"
|
||||
}
|
||||
|
||||
if ($needsNode) {
|
||||
Write-Info "正在通过 NodeSource 在 WSL 中安装 Node.js 22..."
|
||||
Write-Info "正在安装 Node.js 22..."
|
||||
|
||||
$installNodeScript = @'
|
||||
set -e
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
node -v
|
||||
'@
|
||||
$installed = $false
|
||||
|
||||
wsl -d Ubuntu-24.04 -- bash -c $installNodeScript
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Err "WSL 中 Node.js 安装失败。"
|
||||
# 方式 1: winget(Windows 11 / Windows 10 自带)
|
||||
if (-not $installed -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "使用 winget 安装..."
|
||||
winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$installed = $true
|
||||
Write-Ok "Node.js 已通过 winget 安装"
|
||||
}
|
||||
Write-Ok "WSL 中 Node.js 22 安装完成。"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 5: 在 WSL 中安装 OpenClaw
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在在 WSL 中安装 OpenClaw..."
|
||||
|
||||
$openclawCheck = wsl -d Ubuntu-24.04 -- bash -c "command -v openclaw || echo 'NOT_FOUND'" 2>&1
|
||||
|
||||
if ($openclawCheck -match "NOT_FOUND") {
|
||||
wsl -d Ubuntu-24.04 -- bash -c "curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Err "WSL 中 OpenClaw 安装失败。"
|
||||
}
|
||||
Write-Ok "WSL 中 OpenClaw 安装完成。"
|
||||
} else {
|
||||
Write-Ok "WSL 中已安装 OpenClaw。"
|
||||
|
||||
# 方式 2: Chocolatey
|
||||
if (-not $installed -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "使用 Chocolatey 安装..."
|
||||
choco install nodejs-lts -y 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$installed = $true
|
||||
Write-Ok "Node.js 已通过 Chocolatey 安装"
|
||||
}
|
||||
}
|
||||
|
||||
# 方式 3: 手动下载提示
|
||||
if (-not $installed) {
|
||||
Write-Err "无法自动安装 Node.js。请手动下载安装:`n`n 下载地址:https://nodejs.cn/download/`n 或:https://nodejs.org/en/download/`n`n 安装完成后重新打开 PowerShell 运行此脚本。"
|
||||
}
|
||||
|
||||
# 刷新 PATH
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
# 验证安装
|
||||
try {
|
||||
$nodeVersion = (node -v 2>$null)
|
||||
Write-Ok "Node.js $nodeVersion 安装成功"
|
||||
} catch {
|
||||
Write-Err "Node.js 安装后验证失败。请关闭 PowerShell 重新打开后再试。"
|
||||
}
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 6: 安装 OpenClaw 网关守护进程
|
||||
# 步骤 2: 检查 / 安装 Git
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在安装 OpenClaw 网关守护进程..."
|
||||
Write-Info "正在检查 Git..."
|
||||
|
||||
wsl -d Ubuntu-24.04 -- bash -c 'export PATH="$HOME/.openclaw/bin:$PATH" && openclaw gateway install'
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Warn "网关守护进程安装遇到问题。您可以稍后使用以下命令安装:openclaw gateway install"
|
||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||
Write-Ok "已找到 Git。"
|
||||
} else {
|
||||
Write-Ok "网关守护进程安装完成。"
|
||||
Write-Info "正在安装 Git(OpenClaw 依赖需要)..."
|
||||
|
||||
$gitInstalled = $false
|
||||
|
||||
if (-not $gitInstalled -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "使用 winget 安装 Git..."
|
||||
winget install Git.Git --accept-package-agreements --accept-source-agreements 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$gitInstalled = $true
|
||||
Write-Ok "Git 已通过 winget 安装"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $gitInstalled -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Info "使用 Chocolatey 安装 Git..."
|
||||
choco install git -y 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$gitInstalled = $true
|
||||
Write-Ok "Git 已通过 Chocolatey 安装"
|
||||
}
|
||||
}
|
||||
|
||||
# 方式 3: 直接下载安装
|
||||
if (-not $gitInstalled) {
|
||||
Write-Info "正在直接下载 Git 安装包..."
|
||||
$gitInstaller = Join-Path $env:TEMP "git-installer.exe"
|
||||
try {
|
||||
# 从 GitHub 获取最新 64-bit 安装包 URL
|
||||
$releases = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest" -ErrorAction Stop
|
||||
$asset = $releases.assets | Where-Object { $_.name -match "Git-.*-64-bit\.exe$" } | Select-Object -First 1
|
||||
if ($asset) {
|
||||
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $gitInstaller -ErrorAction Stop
|
||||
Write-Info "正在静默安装 Git..."
|
||||
Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS" -Wait
|
||||
Remove-Item $gitInstaller -Force -ErrorAction SilentlyContinue
|
||||
$gitInstalled = $true
|
||||
Write-Ok "Git 已通过直接下载安装"
|
||||
}
|
||||
} catch {
|
||||
Write-Warn "直接下载安装失败: $_"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $gitInstalled) {
|
||||
Write-Err "无法自动安装 Git。请手动下载安装:`n`n 下载地址:https://git-scm.com/download/win`n`n 安装完成后重新打开 PowerShell 运行此脚本。"
|
||||
}
|
||||
|
||||
# 刷新 PATH
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 7: 启动交互式配置
|
||||
# 步骤 3: 安装 OpenClaw
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Info "正在检查 OpenClaw..."
|
||||
|
||||
$needsInstall = $true
|
||||
|
||||
try {
|
||||
$null = Get-Command openclaw -ErrorAction Stop
|
||||
Write-Ok "已找到 OpenClaw。"
|
||||
$needsInstall = $false
|
||||
} catch {
|
||||
Write-Info "正在安装 OpenClaw..."
|
||||
}
|
||||
|
||||
if ($needsInstall) {
|
||||
npm install -g openclaw@latest 2>&1 | Write-Host
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Err "OpenClaw 安装失败。请手动运行:npm install -g openclaw@latest"
|
||||
}
|
||||
|
||||
# 刷新 PATH
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
|
||||
# 把 npm global bin 加到 PATH
|
||||
try {
|
||||
$npmPrefix = (npm config get prefix 2>$null).Trim()
|
||||
if ($npmPrefix) {
|
||||
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
if (-not ($userPath -split ";" | Where-Object { $_ -ieq $npmPrefix })) {
|
||||
[Environment]::SetEnvironmentVariable("Path", "$userPath;$npmPrefix", "User")
|
||||
$env:Path += ";$npmPrefix"
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
|
||||
Write-Ok "OpenClaw 安装完成。"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# 步骤 3: 启动交互式配置
|
||||
# ─────────────────────────────────────────────
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
@@ -177,7 +195,7 @@ Write-Host " 选择 MiniMax 可获得 7天免费试用 - 无需信用卡。" -F
|
||||
Write-Host " 注册地址:https://platform.minimax.io" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
wsl -d Ubuntu-24.04 -- bash -c 'export PATH="$HOME/.openclaw/bin:$PATH" && openclaw onboard --accept-risk --flow quickstart --node-manager npm --skip-skills < /dev/tty'
|
||||
openclaw onboard --accept-risk --flow quickstart --node-manager npm --skip-skills
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
@@ -185,7 +203,17 @@ Write-Host " 配置完成!" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host " 接下来:" -ForegroundColor White
|
||||
Write-Host " 1. 开始使用 OpenClaw:openclaw(在 WSL 中)" -ForegroundColor Gray
|
||||
Write-Host " 2. 添加技能(可选):openclaw configure --section skills" -ForegroundColor Gray
|
||||
Write-Host " 3. 浏览可用技能:openclaw skills" -ForegroundColor Gray
|
||||
Write-Host " 1. 进入项目目录:cd 你的项目路径" -ForegroundColor Gray
|
||||
Write-Host " 2. 开始使用 OpenClaw:openclaw" -ForegroundColor Gray
|
||||
Write-Host " 3. 添加技能(可选):openclaw configure --section skills" -ForegroundColor Gray
|
||||
Write-Host " 4. 浏览可用技能:openclaw skills" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
} catch {
|
||||
Write-Host ""
|
||||
Write-Host "[错误] 脚本执行失败: $_" -ForegroundColor Red
|
||||
Write-Host ""
|
||||
} finally {
|
||||
Write-Host ""
|
||||
Read-Host "按 Enter 键关闭此窗口"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user