mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
fix: windows PowerShell script
This commit is contained in:
12
README.md
12
README.md
@@ -23,8 +23,8 @@
|
||||
|
||||
- ✅ **自主任务规划**:能够理解复杂任务并自主规划执行,持续思考和调用工具直到完成目标
|
||||
- ✅ **长期记忆:** 自动将对话记忆持久化至本地文件和数据库中,包括核心记忆和日级记忆,支持关键词及向量检索
|
||||
- ✅ **技能系统:** 实现了 Skills 创建和运行的引擎,支持从 Skill Hub、GitHub 等安装技能,或通过对话创造自定义 Skills
|
||||
- ✅ **工具系统:** 内置文件读写、终端执行、浏览器操作、定时任务、消息发送等工具,Agent 自主调用以完成复杂任务
|
||||
- ✅ **技能系统:** Skills 安装和运行的引擎,支持从 Skill Hub、GitHub 等安装技能,或通过对话创造 Skills
|
||||
- ✅ **工具系统:** 内置文件读写、终端执行、浏览器操作、定时任务等工具,Agent 自主调用以完成复杂任务
|
||||
- ✅ **CLI系统:** 提供终端命令和对话命令,支持进程管理、技能安装、配置修改等操作
|
||||
- ✅ **多模态消息:** 支持对文本、图片、语音、文件等多类型消息进行解析、处理、生成、发送等操作
|
||||
- ✅ **多模型支持:** 支持 OpenAI, Claude, Gemini, DeepSeek, MiniMax、GLM、Qwen、Kimi、Doubao 等国内外主流模型厂商
|
||||
@@ -88,11 +88,17 @@
|
||||
|
||||
在终端执行以下命令:
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
|
||||
脚本使用说明:[一键运行脚本](https://docs.cowagent.ai/guide/quick-start)。安装后也可使用 `cow start`、`cow stop` 等 [CLI 命令](https://docs.cowagent.ai/commands/index) 管理服务。
|
||||
**Windows(PowerShell):**
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
|
||||
脚本使用说明:[一键运行脚本](https://docs.cowagent.ai/guide/quick-start)。安装后可使用 `cow start`、`cow stop` 等 [CLI 命令](https://docs.cowagent.ai/commands/index) 管理服务。
|
||||
|
||||
|
||||
## 一、准备
|
||||
|
||||
@@ -6,7 +6,7 @@ import subprocess
|
||||
|
||||
import click
|
||||
|
||||
PLAYWRIGHT_VERSION = "1.49.0"
|
||||
PLAYWRIGHT_VERSION = "1.52.0"
|
||||
PLAYWRIGHT_LEGACY_VERSION = "1.28.0"
|
||||
GLIBC_THRESHOLD = (2, 28)
|
||||
CHINA_MIRROR = "https://registry.npmmirror.com/-/binary/playwright"
|
||||
@@ -102,7 +102,7 @@ def install_browser():
|
||||
|
||||
# Step 1: Install playwright package
|
||||
click.echo(click.style("[1/3] Installing playwright Python package...", fg="yellow"))
|
||||
ret = _pip_install(f"playwright=={target_version}" if legacy_mode else f"playwright>={target_version}")
|
||||
ret = _pip_install(f"playwright=={target_version}")
|
||||
if ret != 0:
|
||||
click.echo(click.style("Failed to install playwright package.", fg="red"))
|
||||
raise SystemExit(1)
|
||||
@@ -143,11 +143,23 @@ def install_browser():
|
||||
|
||||
# Use China mirror if pip is configured with a domestic index
|
||||
env = os.environ.copy()
|
||||
if _is_china_network():
|
||||
use_mirror = _is_china_network()
|
||||
if use_mirror:
|
||||
env["PLAYWRIGHT_DOWNLOAD_HOST"] = CHINA_MIRROR
|
||||
click.echo(f" (using China mirror: {CHINA_MIRROR})")
|
||||
|
||||
ret = subprocess.call(cmd, env=env)
|
||||
|
||||
# Fallback: if mirror download failed, retry with official CDN
|
||||
if ret != 0 and use_mirror:
|
||||
click.echo(click.style(
|
||||
" Mirror download failed, retrying with official CDN...",
|
||||
fg="yellow",
|
||||
))
|
||||
env_no_mirror = os.environ.copy()
|
||||
env_no_mirror.pop("PLAYWRIGHT_DOWNLOAD_HOST", None)
|
||||
ret = subprocess.call(cmd, env=env_no_mirror)
|
||||
|
||||
if ret != 0:
|
||||
click.echo(click.style("Failed to install Chromium.", fg="red"))
|
||||
raise SystemExit(1)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import sys
|
||||
import io
|
||||
|
||||
|
||||
def _reset_logger(log):
|
||||
@@ -9,7 +10,10 @@ def _reset_logger(log):
|
||||
del handler
|
||||
log.handlers.clear()
|
||||
log.propagate = False
|
||||
console_handle = logging.StreamHandler(sys.stdout)
|
||||
stdout = sys.stdout
|
||||
if hasattr(stdout, "buffer"):
|
||||
stdout = io.TextIOWrapper(stdout.buffer, encoding="utf-8", errors="replace", line_buffering=True)
|
||||
console_handle = logging.StreamHandler(stdout)
|
||||
console_handle.setFormatter(
|
||||
logging.Formatter(
|
||||
"[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s",
|
||||
|
||||
@@ -408,7 +408,7 @@ def get_root():
|
||||
|
||||
|
||||
def read_file(path):
|
||||
with open(path, mode="r", encoding="utf-8") as f:
|
||||
with open(path, mode="r", encoding="utf-8-sig") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
|
||||
@@ -61,10 +61,16 @@ Full changelog: [Release Notes](https://docs.cowagent.ai/en/releases/overview)
|
||||
|
||||
The project provides a one-click script for installation, configuration, startup, and management:
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
|
||||
After running, the Web service starts by default. Access `http://localhost:9899/chat` to chat.
|
||||
|
||||
Script usage: [One-click Install](https://docs.cowagent.ai/en/guide/quick-start). After installation, you can also use `cow start`, `cow stop`, and other [CLI commands](https://docs.cowagent.ai/en/commands/index) to manage the service.
|
||||
|
||||
@@ -9,9 +9,18 @@ Supports Linux, macOS, and Windows. Requires Python 3.7-3.12 (3.9 recommended).
|
||||
|
||||
## Install Command
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Linux / macOS">
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows (PowerShell)">
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
The script automatically performs these steps:
|
||||
|
||||
@@ -36,9 +45,10 @@ After installation, use the `cow` command to manage the service:
|
||||
| `cow status` | Check run status |
|
||||
| `cow logs` | View real-time logs |
|
||||
| `cow update` | Update code and restart |
|
||||
| `cow install-browser` | Install browser tool dependencies |
|
||||
|
||||
See the [Commands documentation](/en/commands/index) for more details.
|
||||
|
||||
<Note>
|
||||
If the `cow` command is not available, you can use `./run.sh <command>` as a fallback (e.g., `./run.sh start`, `./run.sh stop`). Both are functionally equivalent.
|
||||
If the `cow` command is not available, you can use `./run.sh <command>` (Linux/macOS) or `.\scripts\run.ps1 <command>` (Windows) as a fallback. Both are functionally equivalent.
|
||||
</Note>
|
||||
|
||||
@@ -46,9 +46,18 @@ CowAgent can proactively think and plan tasks, operate computers and external re
|
||||
|
||||
Run the following command in your terminal for one-click install, configuration, and startup:
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Linux / macOS">
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows (PowerShell)">
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
By default, the Web service starts after running. Access `http://localhost:9899/chat` to chat in the web interface.
|
||||
|
||||
|
||||
@@ -9,9 +9,18 @@ description: 使用脚本一键安装和管理 CowAgent
|
||||
|
||||
## 安装命令
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Linux / macOS">
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows (PowerShell)">
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
脚本自动执行以下流程:
|
||||
|
||||
@@ -41,5 +50,5 @@ bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
更多命令和用法参考 [命令文档](/commands/index)。
|
||||
|
||||
<Note>
|
||||
如果 `cow` 命令不可用,也可以使用 `./run.sh <命令>` 作为替代(如 `./run.sh start`、`./run.sh stop`),二者功能等效。
|
||||
如果 `cow` 命令不可用,也可以使用 `./run.sh <命令>`(Linux/macOS)或 `.\scripts\run.ps1 <命令>`(Windows)作为替代,功能等效。
|
||||
</Note>
|
||||
|
||||
@@ -51,9 +51,18 @@ CowAgent 支持灵活切换多种模型,能处理文本、语音、图片、
|
||||
|
||||
在终端执行以下命令,即可一键安装、配置、启动 CowAgent:
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Linux / macOS">
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows (PowerShell)">
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
运行后默认会启动 Web 控制台,通过访问 `http://localhost:9899` 可以在网页端进行对话、配置、应用通道接入等操作。
|
||||
|
||||
|
||||
@@ -61,10 +61,16 @@
|
||||
|
||||
本プロジェクトは、インストール・設定・起動・管理をワンクリックで行えるスクリプトを提供しています:
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
|
||||
実行後、デフォルトでWebサービスが起動します。`http://localhost:9899/chat` にアクセスしてチャットを開始できます。
|
||||
|
||||
スクリプトの使い方: [ワンクリックインストール](https://docs.cowagent.ai/ja/guide/quick-start)。インストール後は `cow start`、`cow stop` などの [CLI コマンド](https://docs.cowagent.ai/ja/commands/index)でサービスを管理できます。
|
||||
|
||||
@@ -9,9 +9,18 @@ Linux、macOS、Windowsに対応しています。Python 3.7〜3.12が必要で
|
||||
|
||||
## インストールコマンド
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Linux / macOS">
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows (PowerShell)">
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
スクリプトは以下の手順を自動的に実行します:
|
||||
|
||||
@@ -36,9 +45,10 @@ bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
| `cow status` | 実行状態を確認 |
|
||||
| `cow logs` | リアルタイムログを表示 |
|
||||
| `cow update` | コードを更新して再起動 |
|
||||
| `cow install-browser` | ブラウザツールの依存をインストール |
|
||||
|
||||
詳細は[コマンドドキュメント](/ja/commands/index)を参照してください。
|
||||
|
||||
<Note>
|
||||
`cow` コマンドが利用できない場合は、`./run.sh <コマンド>`(例:`./run.sh start`、`./run.sh stop`)で代替できます。機能は同等です。
|
||||
`cow` コマンドが利用できない場合は、`./run.sh <コマンド>`(Linux/macOS)または `.\scripts\run.ps1 <コマンド>`(Windows)で代替できます。機能は同等です。
|
||||
</Note>
|
||||
|
||||
@@ -46,9 +46,18 @@ CowAgent は自ら思考しタスクを計画し、コンピュータや外部
|
||||
|
||||
ターミナルで以下のコマンドを実行すると、ワンクリックでインストール、設定、起動ができます:
|
||||
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Linux / macOS">
|
||||
```bash
|
||||
bash <(curl -fsSL https://cdn.link-ai.tech/code/cow/run.sh)
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows (PowerShell)">
|
||||
```powershell
|
||||
irm https://cdn.link-ai.tech/code/cow/run.ps1 | iex
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
デフォルトでは実行後に Web サービスが起動します。`http://localhost:9899/chat` にアクセスして Web インターフェースでチャットできます。
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ param(
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# ── ensure UTF-8 console encoding on Windows ─────────────────────
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$env:PYTHONIOENCODING = "utf-8"
|
||||
chcp 65001 | Out-Null
|
||||
|
||||
# ── colours ──────────────────────────────────────────────────────
|
||||
function Write-Cow { param([string]$M) Write-Host $M -ForegroundColor Green }
|
||||
function Write-Warn { param([string]$M) Write-Host $M -ForegroundColor Yellow }
|
||||
@@ -85,11 +90,17 @@ function Install-Project {
|
||||
}
|
||||
|
||||
Write-Cow "Cloning CowAgent project..."
|
||||
git clone https://github.com/zhayujie/chatgpt-on-wechat.git 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$prevEAP = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
git clone https://github.com/zhayujie/chatgpt-on-wechat.git 2>&1 | Out-Null
|
||||
$cloneExit = $LASTEXITCODE
|
||||
$ErrorActionPreference = $prevEAP
|
||||
if ($cloneExit -ne 0) {
|
||||
Write-Warn "GitHub failed, trying Gitee..."
|
||||
git clone https://gitee.com/zhayujie/chatgpt-on-wechat.git
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$ErrorActionPreference = "Continue"
|
||||
git clone https://gitee.com/zhayujie/chatgpt-on-wechat.git 2>&1 | Out-Null
|
||||
$cloneExit = $LASTEXITCODE
|
||||
$ErrorActionPreference = $prevEAP
|
||||
if ($cloneExit -ne 0) {
|
||||
Write-Err "Clone failed. Check your network."
|
||||
exit 1
|
||||
}
|
||||
@@ -105,20 +116,35 @@ function Install-Project {
|
||||
function Install-Dependencies {
|
||||
Write-Cow "Installing dependencies..."
|
||||
|
||||
& $PythonCmd -m pip install --upgrade pip setuptools wheel 2>$null | Out-Null
|
||||
$prevEAP = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
& $PythonCmd -m pip install --upgrade pip setuptools wheel 2>&1 | Out-Null
|
||||
|
||||
& $PythonCmd -m pip install -r "$BaseDir\requirements.txt" 2>&1 | ForEach-Object { Write-Host $_ }
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$pipExit = $LASTEXITCODE
|
||||
$ErrorActionPreference = $prevEAP
|
||||
if ($pipExit -ne 0) {
|
||||
Write-Warn "Some dependencies may have issues, but continuing..."
|
||||
}
|
||||
|
||||
Write-Cow "Registering cow CLI..."
|
||||
& $PythonCmd -m pip install -e $BaseDir 2>$null | Out-Null
|
||||
$prevEAP = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
& $PythonCmd -m pip install -e $BaseDir 2>&1 | Out-Null
|
||||
$ErrorActionPreference = $prevEAP
|
||||
|
||||
# Ensure Python Scripts dir is in PATH for this session
|
||||
$scriptsDir = & $PythonCmd -c "import sysconfig; print(sysconfig.get_path('scripts'))" 2>$null
|
||||
if ($scriptsDir -and (Test-Path $scriptsDir)) {
|
||||
if ($env:PATH -notlike "*$scriptsDir*") {
|
||||
$env:PATH = "$scriptsDir;$env:PATH"
|
||||
}
|
||||
}
|
||||
|
||||
$cowBin = Get-Command cow -ErrorAction SilentlyContinue
|
||||
if ($cowBin) {
|
||||
Write-Cow "cow CLI registered."
|
||||
Write-Cow "cow CLI registered: $($cowBin.Source)"
|
||||
} else {
|
||||
Write-Warn "cow CLI not in PATH. You can use: $PythonCmd -m cli.cli"
|
||||
Write-Warn "To fix permanently, add Python Scripts directory to your system PATH."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +328,8 @@ function New-ConfigFile {
|
||||
$config[$k] = $ChannelExtra[$k]
|
||||
}
|
||||
|
||||
$config | ConvertTo-Json -Depth 5 | Set-Content -Path "$BaseDir\config.json" -Encoding UTF8
|
||||
$jsonText = $config | ConvertTo-Json -Depth 5
|
||||
[System.IO.File]::WriteAllText("$BaseDir\config.json", $jsonText, (New-Object System.Text.UTF8Encoding $false))
|
||||
Write-Cow "Configuration file created."
|
||||
}
|
||||
|
||||
@@ -401,15 +428,24 @@ function Update-Project {
|
||||
|
||||
# Stop if running
|
||||
$cowBin = Get-Command cow -ErrorAction SilentlyContinue
|
||||
if ($cowBin) { & cow stop 2>$null }
|
||||
if ($cowBin) {
|
||||
$prevEAP = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
& cow stop 2>&1 | Out-Null
|
||||
$ErrorActionPreference = $prevEAP
|
||||
}
|
||||
|
||||
if (Test-Path "$BaseDir\.git") {
|
||||
Write-Cow "Pulling latest code..."
|
||||
git pull 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$prevEAP = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
git pull 2>&1 | Out-Null
|
||||
$pullExit = $LASTEXITCODE
|
||||
$ErrorActionPreference = $prevEAP
|
||||
if ($pullExit -ne 0) {
|
||||
Write-Warn "GitHub failed, trying Gitee..."
|
||||
git remote set-url origin https://gitee.com/zhayujie/chatgpt-on-wechat.git
|
||||
git pull
|
||||
$ErrorActionPreference = "Continue"
|
||||
git remote set-url origin https://gitee.com/zhayujie/chatgpt-on-wechat.git 2>&1 | Out-Null
|
||||
git pull 2>&1 | Out-Null
|
||||
$ErrorActionPreference = $prevEAP
|
||||
}
|
||||
} else {
|
||||
Write-Warn "Not a git repository, skipping code update."
|
||||
|
||||
Reference in New Issue
Block a user