mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 10:20:45 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -1,4 +1,4 @@
|
|||
param(
|
||||
param(
|
||||
[string]$Python = "python",
|
||||
[switch]$Recreate = $false
|
||||
)
|
||||
|
|
@ -14,10 +14,10 @@ function Fail([string]$msg) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
Set-Location $repoRoot
|
||||
|
||||
$venvDir = Join-Path $repoRoot "oclaw/.venv"
|
||||
$venvDir = Join-Path $repoRoot ".venv"
|
||||
$venvPython = Join-Path $venvDir "Scripts/python.exe"
|
||||
|
||||
$py = Get-Command $Python -ErrorAction SilentlyContinue
|
||||
|
|
@ -49,3 +49,5 @@ Write-Host ""
|
|||
Write-Host "OK. Next:" -ForegroundColor Green
|
||||
Write-Host " powershell -ExecutionPolicy Bypass -File .\\oclaw\\scripts\\start_gateway.ps1"
|
||||
Write-Host ""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ _PS1_FORWARDERS: dict[str, str] = {
|
|||
"bootstrap_venv.ps1": "& $real @args",
|
||||
"start_web.ps1": "& $real @args",
|
||||
"status_all.ps1": "& $real @args",
|
||||
"status_desktop.ps1": "& $real @args",
|
||||
"status_ops.ps1": "& $real @args",
|
||||
"status_wiki_worker.ps1": "& $real @args",
|
||||
"stop_all.ps1": "& $real @args",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
param(
|
||||
param(
|
||||
[string]$BindHost = "127.0.0.1",
|
||||
[int]$Port = 8787,
|
||||
[switch]$SkipInstall = $false,
|
||||
[switch]$Background = $false,
|
||||
[switch]$WithWeixin = $false,
|
||||
[switch]$WithWikiWorker = $false,
|
||||
[bool]$WithWikiWorker = $true,
|
||||
[string]$WeixinChannelId = "oclaw-weixin",
|
||||
[string]$WeixinGatewayBaseUrl = ""
|
||||
)
|
||||
|
|
@ -15,12 +15,13 @@ function Write-Step([string]$msg) {
|
|||
Write-Host "==> $msg" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Set-Location $repoRoot
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
|
||||
Write-Step "Starting gateway + desktop"
|
||||
|
||||
& "$PSScriptRoot/start_gateway.ps1" -BindHost $BindHost -Port $Port -SkipInstall:$SkipInstall -Background:$Background
|
||||
& "$PSScriptRoot/start_gateway.ps1" -BindHost $BindHost -Port $Port -SkipInstall:$SkipInstall -Background:$Background -WithWikiWorker:$WithWikiWorker
|
||||
|
||||
# When gateway is started in foreground, the call above blocks; desktop won't start.
|
||||
if (-not $Background) {
|
||||
|
|
@ -29,7 +30,7 @@ if (-not $Background) {
|
|||
exit 0
|
||||
}
|
||||
|
||||
& "$PSScriptRoot/start_desktop.ps1" -SkipInstall:$SkipInstall -Background
|
||||
& "$PSScriptRoot/start_desktop.ps1" -SkipInstall:$SkipInstall -Background -WithWikiWorker:$WithWikiWorker
|
||||
|
||||
if ($WithWeixin) {
|
||||
$gwBase = ($WeixinGatewayBaseUrl | ForEach-Object { "$_".Trim() })
|
||||
|
|
@ -39,11 +40,7 @@ if ($WithWeixin) {
|
|||
Write-Step "Starting weixin sidecar"
|
||||
& "$PSScriptRoot/weixin_start.ps1" -ChannelId $WeixinChannelId -GatewayBaseUrl $gwBase
|
||||
}
|
||||
if ($WithWikiWorker) {
|
||||
Write-Step "Starting wiki worker"
|
||||
& "$PSScriptRoot/start_wiki_worker.ps1" -Background
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "All started." -ForegroundColor Green
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
param(
|
||||
param(
|
||||
[switch]$SkipInstall = $false,
|
||||
[switch]$Background = $false,
|
||||
[switch]$KeepExistingGateway = $false
|
||||
[switch]$KeepExistingGateway = $false,
|
||||
[bool]$WithWikiWorker = $true
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$desktopDir = Join-Path $repoRoot "oclaw\\desktop"
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
$desktopDir = Join-Path $repoRoot "desktop"
|
||||
$runDir = Join-Path $PSScriptRoot ".run"
|
||||
New-Item -ItemType Directory -Force -Path $runDir | Out-Null
|
||||
$pidFile = Join-Path $runDir "desktop.pid"
|
||||
|
|
@ -19,6 +21,7 @@ if (-not (Test-Path $desktopDir)) {
|
|||
}
|
||||
|
||||
Set-Location $desktopDir
|
||||
$env:PYTHONPATH = $repoParent
|
||||
|
||||
if (-not $KeepExistingGateway) {
|
||||
Write-Host "==> Cleaning previous gateway listener" -ForegroundColor Cyan
|
||||
|
|
@ -34,6 +37,11 @@ if (-not $SkipInstall) {
|
|||
npm install
|
||||
}
|
||||
|
||||
if ($WithWikiWorker) {
|
||||
Write-Host "==> Ensuring wiki worker is running" -ForegroundColor Cyan
|
||||
& "$PSScriptRoot/start_wiki_worker.ps1" -Background
|
||||
}
|
||||
|
||||
Write-Host "==> Launching desktop app" -ForegroundColor Cyan
|
||||
if ($Background) {
|
||||
# Avoid launching npm.ps1 directly (can be file-associated and open in Notepad on some setups).
|
||||
|
|
@ -47,3 +55,5 @@ if ($Background) {
|
|||
exit 0
|
||||
}
|
||||
& "npm.cmd" "run" "dev"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
param(
|
||||
param(
|
||||
[string]$BindHost = "127.0.0.1",
|
||||
[int]$Port = 8787,
|
||||
[switch]$SkipInstall = $false,
|
||||
[switch]$Background = $false
|
||||
[switch]$Background = $false,
|
||||
[bool]$WithWikiWorker = $true
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -16,16 +17,20 @@ function Fail([string]$msg) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Set-Location $repoRoot
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
|
||||
$runDir = Join-Path $PSScriptRoot ".run"
|
||||
New-Item -ItemType Directory -Force -Path $runDir | Out-Null
|
||||
$pidFile = Join-Path $runDir "gateway.pid"
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
|
||||
$venvPython = Join-Path $repoRoot "oclaw/.venv/Scripts/python.exe"
|
||||
$env:PYTHONPATH = $repoParent
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
Write-Step "Using venv python: $venvPython"
|
||||
$pythonExe = $venvPython
|
||||
|
|
@ -40,7 +45,7 @@ if (Test-Path $venvPython) {
|
|||
|
||||
if (-not $SkipInstall) {
|
||||
Write-Step "Installing dependencies (pip install -r requirements.txt)"
|
||||
& $pythonExe -m pip install -r "requirements.txt"
|
||||
& $pythonExe -m pip install -r (Join-Path $repoRoot "requirements.txt")
|
||||
} else {
|
||||
Write-Step "Skip dependency install"
|
||||
}
|
||||
|
|
@ -52,15 +57,20 @@ Write-Host "Chat: http://$BindHost`:$Port/chat"
|
|||
Write-Host "WS: ws://$BindHost`:$Port/ws"
|
||||
Write-Host ""
|
||||
|
||||
$configPath = Join-Path $repoRoot "oclaw\oclaw.json"
|
||||
$configPath = Join-Path $repoRoot "oclaw.json"
|
||||
if (Test-Path $configPath) {
|
||||
$env:OCLAW_CONFIG_PATH = $configPath
|
||||
Write-Step "Using OCLAW_CONFIG_PATH: $configPath"
|
||||
}
|
||||
|
||||
if ($WithWikiWorker) {
|
||||
Write-Step "Ensuring wiki worker is running"
|
||||
& "$PSScriptRoot/start_wiki_worker.ps1" -Background
|
||||
}
|
||||
|
||||
if ($Background) {
|
||||
Write-Step "Starting gateway in background"
|
||||
$p = Start-Process -FilePath $pythonExe -ArgumentList @("-m","oclaw.runtime.operations","gateway","start","--host",$BindHost,"--port",$Port) -WorkingDirectory $repoRoot -PassThru -WindowStyle Hidden
|
||||
$p = Start-Process -FilePath $pythonExe -ArgumentList @("-m","oclaw.runtime.operations","gateway","start","--host",$BindHost,"--port",$Port) -WorkingDirectory $repoParent -PassThru -WindowStyle Hidden
|
||||
Set-Content -Path $pidFile -Value "$($p.Id)" -Encoding ascii
|
||||
Write-Host "gateway.pid = $pidFile" -ForegroundColor DarkGray
|
||||
Write-Host "PID = $($p.Id)" -ForegroundColor Green
|
||||
|
|
@ -70,3 +80,5 @@ if ($Background) {
|
|||
Write-Step "Starting gateway (foreground)"
|
||||
& $pythonExe -m oclaw.runtime.operations gateway start --host $BindHost --port $Port
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,16 @@ function Fail([string]$msg) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Set-Location $repoRoot
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
|
||||
$venvPython = Join-Path $repoRoot "oclaw/.venv/Scripts/python.exe"
|
||||
$env:PYTHONPATH = $repoParent
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
Write-Step "Using venv python: $venvPython"
|
||||
$pythonExe = $venvPython
|
||||
|
|
@ -35,7 +39,7 @@ if (Test-Path $venvPython) {
|
|||
|
||||
if (-not $SkipInstall) {
|
||||
Write-Step "Installing dependencies (pip install -r requirements.txt)"
|
||||
& $pythonExe -m pip install -r "requirements.txt"
|
||||
& $pythonExe -m pip install -r (Join-Path $repoRoot "requirements.txt")
|
||||
} else {
|
||||
Write-Step "Skip dependency install"
|
||||
}
|
||||
|
|
@ -43,7 +47,7 @@ if (-not $SkipInstall) {
|
|||
if (-not $SkipConfigHint) {
|
||||
Write-Step "Current WeCom status"
|
||||
try {
|
||||
python -m oclaw.runtime.operations channel wecom status
|
||||
& $pythonExe -m oclaw.runtime.operations channel wecom status
|
||||
} catch {
|
||||
Write-Host "[WARN] Unable to read WeCom status yet." -ForegroundColor Yellow
|
||||
}
|
||||
|
|
@ -68,3 +72,5 @@ Write-Host "Useful commands:"
|
|||
Write-Host " python -m oclaw.runtime.operations stack status"
|
||||
Write-Host " python -m oclaw.runtime.operations stack down"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
param(
|
||||
param(
|
||||
[switch]$Background = $true
|
||||
)
|
||||
|
||||
|
|
@ -16,7 +16,16 @@ $pidFile = Join-Path $runDir "wiki_worker.pid"
|
|||
$outLog = Join-Path $runDir "wiki_worker.out.log"
|
||||
$errLog = Join-Path $runDir "wiki_worker.err.log"
|
||||
|
||||
$venvPython = Join-Path $repoRoot "oclaw/.venv/Scripts/python.exe"
|
||||
function Test-AlivePid([int]$procId) {
|
||||
try {
|
||||
$p = Get-Process -Id $procId -ErrorAction Stop
|
||||
return $null -ne $p
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
$pythonExe = $venvPython
|
||||
} else {
|
||||
|
|
@ -32,6 +41,17 @@ if (-not $Background) {
|
|||
exit 0
|
||||
}
|
||||
|
||||
if (Test-Path $pidFile) {
|
||||
$raw = (Get-Content $pidFile -ErrorAction SilentlyContinue | Select-Object -First 1)
|
||||
$existing = 0
|
||||
[void][int]::TryParse([string]$raw, [ref]$existing)
|
||||
if ($existing -gt 0 -and (Test-AlivePid $existing)) {
|
||||
Write-Host "[ok] wiki worker already running pid=$existing"
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
$p = Start-Process -FilePath $pythonExe -ArgumentList @("-m", "oclaw.runtime.workers.wiki.main") -WorkingDirectory $repoRoot -PassThru -WindowStyle Hidden -RedirectStandardOutput $outLog -RedirectStandardError $errLog
|
||||
Set-Content -Path $pidFile -Value $p.Id -Encoding ascii
|
||||
Write-Host "[ok] started wiki worker pid=$($p.Id) out=$outLog err=$errLog"
|
||||
|
||||
|
|
|
|||
39
runtime/operations/scripts/status_desktop.ps1
Normal file
39
runtime/operations/scripts/status_desktop.ps1
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Warn([string]$msg) {
|
||||
Write-Host "[WARN] $msg" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
$runDir = Join-Path $PSScriptRoot ".run"
|
||||
$pidFile = Join-Path $runDir "desktop.pid"
|
||||
$outLog = Join-Path $runDir "desktop.out.log"
|
||||
$errLog = Join-Path $runDir "desktop.err.log"
|
||||
|
||||
if (-not (Test-Path $pidFile)) {
|
||||
Warn "desktop.pid not found: $pidFile"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$raw = (Get-Content $pidFile -ErrorAction SilentlyContinue | Select-Object -First 1)
|
||||
$procId = 0
|
||||
[void][int]::TryParse([string]$raw, [ref]$procId)
|
||||
if ($procId -le 0) {
|
||||
Warn "Invalid PID in $pidFile"
|
||||
exit 1
|
||||
}
|
||||
|
||||
try {
|
||||
$p = Get-Process -Id $procId -ErrorAction Stop
|
||||
Write-Host "desktop_running=1" -ForegroundColor Green
|
||||
Write-Host "pid=$procId"
|
||||
Write-Host "name=$($p.ProcessName)"
|
||||
if (Test-Path $outLog) { Write-Host "out_log=$outLog" }
|
||||
if (Test-Path $errLog) { Write-Host "err_log=$errLog" }
|
||||
exit 0
|
||||
} catch {
|
||||
Warn "desktop process not found: PID=$procId"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
@ -4,18 +4,29 @@ function Write-Step([string]$msg) {
|
|||
Write-Host "==> $msg" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Set-Location $repoRoot
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
$env:PYTHONPATH = $repoParent
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
$pythonExe = $venvPython
|
||||
} else {
|
||||
$pythonExe = "python"
|
||||
}
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
Write-Step "Stack status"
|
||||
python -m oclaw.runtime.operations stack status
|
||||
& $pythonExe -m oclaw.runtime.operations stack status
|
||||
|
||||
Write-Host ""
|
||||
Write-Step "WeCom status"
|
||||
python -m oclaw.runtime.operations channel wecom status
|
||||
& $pythonExe -m oclaw.runtime.operations channel wecom status
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Admin: http://127.0.0.1:8787/admin"
|
||||
Write-Host "Chat: http://127.0.0.1:8787/chat"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,24 @@ function Write-Step([string]$msg) {
|
|||
Write-Host "==> $msg" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Set-Location $repoRoot
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot))
|
||||
$repoParent = Split-Path -Parent $repoRoot
|
||||
Set-Location $repoParent
|
||||
$env:PYTHONPATH = $repoParent
|
||||
|
||||
$venvPython = Join-Path $repoRoot ".venv/Scripts/python.exe"
|
||||
if (Test-Path $venvPython) {
|
||||
$pythonExe = $venvPython
|
||||
} else {
|
||||
$pythonExe = "python"
|
||||
}
|
||||
|
||||
Write-Step "Project root: $repoRoot"
|
||||
Write-Step "Working directory: $repoParent"
|
||||
Write-Step "Stopping stack services..."
|
||||
|
||||
try {
|
||||
python -m oclaw.runtime.operations stack down
|
||||
& $pythonExe -m oclaw.runtime.operations stack down
|
||||
Write-Host "Stack stopped." -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "[WARN] stack down failed: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
|
|
@ -26,8 +36,9 @@ try {
|
|||
|
||||
Write-Step "Current status"
|
||||
try {
|
||||
python -m oclaw.runtime.operations stack status
|
||||
& $pythonExe -m oclaw.runtime.operations stack status
|
||||
} catch {
|
||||
Write-Host "[WARN] Unable to read status after stop." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue