mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-21 05:54:46 +00:00
* refactor: remove stale file-backed shims * fix: harden sqlite state ci boundaries * refactor: store matrix idb snapshots in sqlite * fix: satisfy rebased CI guardrails * refactor: store current conversation bindings in sqlite table * refactor: store tui last sessions in sqlite table * refactor: reset sqlite schema history * refactor: drop unshipped sqlite table migration * refactor: remove plugin index file rollback * refactor: drop unshipped sqlite sidecar migrations * refactor: remove runtime commitments kv migration * refactor: preserve kysely sync result types * refactor: drop unshipped sqlite schema migration table * test: keep session usage coverage sqlite-backed * refactor: keep sqlite migration doctor-only * refactor: isolate device legacy imports * refactor: isolate push voicewake legacy imports * refactor: isolate remaining runtime legacy imports * refactor: tighten sqlite migration guardrails * test: cover sqlite persisted enum parsing * refactor: isolate legacy update and tui imports * refactor: tighten sqlite state ownership * refactor: move legacy imports behind doctor * refactor: remove legacy session row lookup * refactor: canonicalize memory transcript locators * refactor: drop transcript path scope fallbacks * refactor: drop runtime legacy session delivery pruning * refactor: store tts prefs only in sqlite * refactor: remove cron store path runtime * refactor: use cron sqlite store keys * refactor: rename telegram message cache scope * refactor: read memory dreaming status from sqlite * refactor: rename cron status store key * refactor: stop remembering transcript file paths * test: use sqlite locators in agent fixtures * refactor: remove file-shaped commitments and cron store surfaces * refactor: keep compaction transcript handles out of session rows * refactor: derive transcript handles from session identity * refactor: derive runtime transcript handles * refactor: remove gateway session locator reads * refactor: remove transcript locator from session rows * refactor: store raw stream diagnostics in sqlite * refactor: remove file-shaped transcript rotation * refactor: hide legacy trajectory paths from runtime * refactor: remove runtime transcript file bridges * refactor: repair database-first rebase fallout * refactor: align tests with database-first state * refactor: remove transcript file handoffs * refactor: sync post-compaction memory by transcript scope * refactor: run codex app-server sessions by id * refactor: bind codex runtime state by session id * refactor: pass memory transcripts by sqlite scope * refactor: remove transcript locator cleanup leftovers * test: remove stale transcript file fixtures * refactor: remove transcript locator test helper * test: make cron sqlite keys explicit * test: remove cron runtime store paths * test: remove stale session file fixtures * test: use sqlite cron keys in diagnostics * refactor: remove runtime delivery queue backfill * test: drop fake export session file mocks * refactor: rename acp session read failure flag * refactor: rename acp row session key * refactor: remove session store test seams * refactor: move legacy session parser tests to doctor * refactor: reindex managed memory in place * refactor: drop stale session store wording * refactor: rename session row helpers * refactor: rename sqlite session entry modules * refactor: remove transcript locator leftovers * refactor: trim file-era audit wording * refactor: clean managed media through sqlite * fix: prefer explicit agent for exports * fix: use prepared agent for session resets * fix: canonicalize legacy codex binding import * test: rename state cleanup helper * docs: align backup docs with sqlite state * refactor: drop legacy Pi usage auth fallback * refactor: move legacy auth profile imports to doctor * refactor: keep Pi model discovery auth in memory * refactor: remove MSTeams legacy learning key fallback * refactor: store model catalog config in sqlite * refactor: use sqlite model catalog at runtime * refactor: remove model json compatibility aliases * refactor: store auth profiles in sqlite * refactor: seed copied auth profiles in sqlite * refactor: make auth profile runtime sqlite-addressed * refactor: migrate hermes secrets into sqlite auth store * refactor: move plugin install config migration to doctor * refactor: rename plugin index audit checks * test: drop auth file assumptions * test: remove legacy transcript file assertions * refactor: drop legacy cli session aliases * refactor: store skill uploads in sqlite * refactor: keep subagent attachments in sqlite vfs * refactor: drop subagent attachment cleanup state * refactor: move legacy session aliases to doctor * refactor: require node 24 for sqlite state runtime * refactor: move provider caches into sqlite state * fix: harden virtual agent filesystem * refactor: enforce database-first runtime state * refactor: rename compaction transcript rotation setting * test: clean sqlite refactor test types * refactor: consolidate sqlite runtime state * refactor: model session conversations in sqlite * refactor: stop deriving cron delivery from session keys * refactor: stop classifying sessions from key shape * refactor: hydrate announce targets from typed delivery * refactor: route heartbeat delivery from typed sqlite context * refactor: tighten typed sqlite session routing * refactor: remove session origin routing shadow * refactor: drop session origin shadow fixtures * perf: query sqlite vfs paths by prefix * refactor: use typed conversation metadata for sessions * refactor: prefer typed session routing metadata * refactor: require typed session routing metadata * refactor: resolve group tool policy from typed sessions * refactor: delete dead session thread info bridge * Show Codex subscription reset times in channel errors (#80456) * feat(plugin-sdk): consolidate session workflow APIs * fix(agents): allow read-only agent mount reads * [codex] refresh plugin regression fixtures * fix(agents): restore compaction gateway logs * test: tighten gateway startup assertions * Redact persisted secret-shaped payloads [AI] (#79006) * test: tighten device pair notify assertions * test: tighten hermes secret assertions * test: assert matrix client error shapes * test: assert config compat warnings * fix(heartbeat): remap cron-run exec events to session keys (#80214) * fix(codex): route btw through native side threads * fix(auth): accept friendly OpenAI order for Codex profiles * fix(codex): rotate auth profiles inside harness * fix: keep browser status page probe within timeout * test: assert agents add outputs * test: pin cron read status * fix(agents): avoid Pi resource discovery stalls Co-authored-by: dataCenter430 <titan032000@gmail.com> * fix: retire timed-out codex app-server clients * test: tighten qa lab runtime assertions * test: check security fix outputs * test: verify extension runtime messages * feat(wake): expose typed sessionKey on wake protocol + system event CLI * fix(gateway): await session_end during shutdown drain and track channel + compaction lifecycle paths (#57790) * test: guard talk consult call helper * fix(codex): scale context engine projection (#80761) * fix(codex): scale context engine projection * fix: document Codex context projection scaling * fix: document Codex context projection scaling * fix: document Codex context projection scaling * fix: document Codex context projection scaling * chore: align Codex projection changelog * chore: realign Codex projection changelog * fix: isolate Codex projection patch --------- Co-authored-by: Eva (agent) <eva+agent-78055@100yen.org> Co-authored-by: Josh Lehman <josh@martian.engineering> * refactor: move agent runtime state toward piless * refactor: remove cron session reaper * refactor: move session management to sqlite * refactor: finish database-first state migration * chore: refresh generated sqlite db types * refactor: remove stale file-backed shims * test: harden kysely type coverage # Conflicts: # .agents/skills/kysely-database-access/SKILL.md # src/infra/kysely-sync.types.test.ts # src/proxy-capture/store.sqlite.test.ts # src/state/openclaw-agent-db.test.ts # src/state/openclaw-state-db.test.ts * refactor: remove cron store path runtime * refactor: keep compaction transcript handles out of session rows * refactor: derive embedded transcripts from sqlite identity * refactor: remove embedded transcript locator handoff * refactor: remove runtime transcript file bridges * refactor: remove transcript file handoffs * refactor: remove MSTeams legacy learning key fallback * refactor: store model catalog config in sqlite * refactor: use sqlite model catalog at runtime # Conflicts: # docs/cli/secrets.md # docs/gateway/authentication.md # docs/gateway/secrets.md * fix: keep oauth sibling sync sqlite-local # Conflicts: # src/commands/onboard-auth.test.ts * refactor: remove task session store maintenance # Conflicts: # src/commands/tasks.ts * refactor: keep diagnostics in state sqlite * refactor: enforce database-first runtime state * refactor: consolidate sqlite runtime state * Show Codex subscription reset times in channel errors (#80456) * fix(codex): refresh subscription limit resets * fix(codex): format reset times for channels * Update CHANGELOG with latest changes and fixes Updated CHANGELOG with recent fixes and improvements. * fix(codex): keep command load failures on codex surface * fix(codex): format account rate limits as rows * fix(codex): summarize account limits as usage status * fix(codex): simplify account limit status * test: tighten subagent announce queue assertion * test: tighten session delete lifecycle assertions * test: tighten cron ops assertions * fix: track cron execution milestones * test: tighten hermes secret assertions * test: assert matrix sync store payloads * test: assert config compat warnings * fix(codex): align btw side thread semantics * fix(codex): honor codex fallback blocking * fix(agents): avoid Pi resource discovery stalls * test: tighten codex event assertions * test: tighten cron assertions * Fix Codex app-server OAuth harness auth * refactor: move agent runtime state toward piless * refactor: move device and push state to sqlite * refactor: move runtime json state imports to doctor * refactor: finish database-first state migration * chore: refresh generated sqlite db types * refactor: clarify cron sqlite store keys * refactor: remove stale file-backed shims * refactor: bind codex runtime state by session id * test: expect sqlite trajectory branch export * refactor: rename session row helpers * fix: keep legacy device identity import in doctor * refactor: enforce database-first runtime state * refactor: consolidate sqlite runtime state * build: align pi contract wrappers * chore: repair database-first rebase * refactor: remove session file test contracts * test: update gateway session expectations * refactor: stop routing from session compatibility shadows * refactor: stop persisting session route shadows * refactor: use typed delivery context in clients * refactor: stop echoing session route shadows * refactor: repair embedded runner rebase imports # Conflicts: # src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts * refactor: align pi contract imports * refactor: satisfy kysely sync helper guard * refactor: remove file transcript bridge remnants * refactor: remove session locator compatibility * refactor: remove session file test contracts * refactor: keep rebase database-first clean * refactor: remove session file assumptions from e2e * docs: clarify database-first goal state * test: remove legacy store markers from sqlite runtime tests * refactor: remove legacy store assumptions from runtime seams * refactor: align sqlite runtime helper seams * test: update memory recall sqlite audit mock * refactor: align database-first runtime type seams * test: clarify doctor cron legacy store names * fix: preserve sqlite session route projections * test: fix copilot token cache test syntax * docs: update database-first proof status * test: align database-first test fixtures * docs: update database-first proof status * refactor: clean extension database-first drift * test: align agent session route proof * test: clarify doctor legacy path fixtures * chore: clean database-first changed checks * chore: repair database-first rebase markers * build: allow baileys git subdependency * chore: repair exp-vfs rebase drift * chore: finish exp-vfs rebase cleanup * chore: satisfy rebase lint drift * chore: fix qqbot rebase type seam * chore: fix rebase drift leftovers * fix: keep auth profile oauth secrets out of sqlite * fix: repair rebase drift tests * test: stabilize pairing request ordering * test: use source manifests in plugin contract checks * fix: restore gateway session metadata after rebase * fix: repair database-first rebase drift * fix: clean up database-first rebase fallout * test: stabilize line quick reply receipt time * fix: repair extension rebase drift * test: keep transcript redaction tests sqlite-backed * fix: carry injected transcript redaction through sqlite * chore: clean database branch rebase residue * fix: repair database branch CI drift * fix: repair database branch CI guard drift * fix: stabilize oauth tls preflight test * test: align database branch fast guards * test: repair build artifact boundary guards * chore: clean changelog rebase markers --------- Co-authored-by: pashpashpash <nik@vault77.ai> Co-authored-by: Eva <eva@100yen.org> Co-authored-by: stainlu <stainlu@newtype-ai.org> Co-authored-by: Jason Zhou <jason.zhou.design@gmail.com> Co-authored-by: Ruben Cuevas <hi@rubencu.com> Co-authored-by: Pavan Kumar Gondhi <pavangondhi@gmail.com> Co-authored-by: Shakker <shakkerdroid@gmail.com> Co-authored-by: Kaspre <36520309+Kaspre@users.noreply.github.com> Co-authored-by: dataCenter430 <titan032000@gmail.com> Co-authored-by: Kaspre <kaspre@gmail.com> Co-authored-by: pandadev66 <nova.full.stack@outlook.com> Co-authored-by: Eva <admin@100yen.org> Co-authored-by: Eva (agent) <eva+agent-78055@100yen.org> Co-authored-by: Josh Lehman <josh@martian.engineering> Co-authored-by: jeffjhunter <support@aipersonamethod.com>
383 lines
14 KiB
TypeScript
383 lines
14 KiB
TypeScript
import { posixAgentWorkspaceScript, windowsAgentWorkspaceScript } from "./agent-workspace.ts";
|
|
import { shellQuote } from "./host-command.ts";
|
|
import {
|
|
psSingleQuote,
|
|
windowsAgentTurnConfigPatchScript,
|
|
windowsOpenClawResolver,
|
|
windowsScopedEnvFunction,
|
|
} from "./powershell.ts";
|
|
import {
|
|
modelProviderConfigBatchJson,
|
|
resolveParallelsModelTimeoutSeconds,
|
|
} from "./provider-auth.ts";
|
|
import type { Platform, ProviderAuth } from "./types.ts";
|
|
|
|
export interface NpmUpdateScriptInput {
|
|
auth: ProviderAuth;
|
|
expectedNeedle: string;
|
|
updateTarget: string;
|
|
}
|
|
|
|
const windowsStalePostSwapImportRegex = String.raw`node_modules\\openclaw\\dist\\[^\\]+-[A-Za-z0-9_-]+\.js`;
|
|
|
|
function posixModelProviderConfigCommands(
|
|
command: string,
|
|
modelId: string,
|
|
platform: Platform,
|
|
): string {
|
|
const batchJson = modelProviderConfigBatchJson(modelId, platform);
|
|
if (!batchJson) {
|
|
return "";
|
|
}
|
|
return `provider_config_batch="$(mktemp)"
|
|
cat >"$provider_config_batch" <<'JSON'
|
|
${batchJson}
|
|
JSON
|
|
set +e
|
|
${command} config set --batch-file "$provider_config_batch" --strict-json
|
|
provider_config_exit=$?
|
|
set -e
|
|
rm -f "$provider_config_batch"
|
|
if [ "$provider_config_exit" -ne 0 ]; then exit "$provider_config_exit"; fi`;
|
|
}
|
|
|
|
function posixAssertAgentOkScript(command: string, input: NpmUpdateScriptInput, sessionId: string) {
|
|
return `agent_ok=false
|
|
for attempt in 1 2; do
|
|
session_id=${shellQuote(sessionId)}
|
|
if [ "$attempt" -gt 1 ]; then session_id=${shellQuote(`${sessionId}-retry`)}"-$attempt"; fi
|
|
output_file="$(mktemp)"
|
|
set +e
|
|
OPENCLAW_ALLOW_ROOT="\${OPENCLAW_ALLOW_ROOT:-}" ${input.auth.apiKeyEnv}=${shellQuote(input.auth.apiKeyValue)} ${command} agent --local --agent main --session-id "$session_id" --message 'Reply with exact ASCII text OK only.' --thinking minimal --json >"$output_file" 2>&1
|
|
rc=$?
|
|
set -e
|
|
cat "$output_file"
|
|
if [ "$rc" -ne 0 ]; then
|
|
rm -f "$output_file"
|
|
exit "$rc"
|
|
fi
|
|
if grep -Eq '"finalAssistant(Raw|Visible)Text"[[:space:]]*:[[:space:]]*"OK"' "$output_file"; then
|
|
agent_ok=true
|
|
rm -f "$output_file"
|
|
break
|
|
fi
|
|
rm -f "$output_file"
|
|
if [ "$attempt" -lt 2 ]; then
|
|
echo "agent turn attempt $attempt finished without OK response; retrying"
|
|
sleep 3
|
|
fi
|
|
done
|
|
if [ "$agent_ok" != true ]; then
|
|
echo "openclaw agent finished without OK response" >&2
|
|
exit 1
|
|
fi`;
|
|
}
|
|
|
|
function windowsUpdateWithBundledPluginsDisabled(input: NpmUpdateScriptInput): string {
|
|
return `$script:OpenClawUpdateExit = 0
|
|
$updateOutput = Invoke-WithScopedEnv @{ OPENCLAW_DISABLE_BUNDLED_PLUGINS = '1'; OPENCLAW_ALLOW_OLDER_BINARY_DESTRUCTIVE_ACTIONS = '1' } {
|
|
Invoke-OpenClaw update --tag ${psSingleQuote(input.updateTarget)} --yes --json --no-restart 2>&1
|
|
$script:OpenClawUpdateExit = $LASTEXITCODE
|
|
}
|
|
$updateExit = $script:OpenClawUpdateExit
|
|
$updateOutput`;
|
|
}
|
|
|
|
function windowsGatewayReadyScript(): string {
|
|
return `function Wait-OpenClawGateway {
|
|
$deadline = (Get-Date).AddSeconds(180)
|
|
$attempt = 0
|
|
while ((Get-Date) -lt $deadline) {
|
|
Invoke-OpenClaw gateway status --deep --require-rpc --timeout 15000
|
|
if ($LASTEXITCODE -eq 0) { return }
|
|
$attempt += 1
|
|
if ($attempt -eq 4) {
|
|
Invoke-OpenClaw gateway start *>&1 | Out-Host
|
|
}
|
|
Start-Sleep -Seconds 5
|
|
}
|
|
throw "gateway did not become ready after update"
|
|
}
|
|
Invoke-OpenClaw gateway restart *>&1 | Out-Host
|
|
if ($LASTEXITCODE -ne 0) {
|
|
"gateway restart exited with code $LASTEXITCODE; probing readiness before failing" | Out-Host
|
|
}
|
|
Wait-OpenClawGateway`;
|
|
}
|
|
|
|
function windowsAssertAgentOkScript(input: NpmUpdateScriptInput): string {
|
|
return `${windowsAgentTurnConfigPatchScript(input.auth.modelId)}
|
|
${windowsAgentWorkspaceScript("Parallels npm update smoke test assistant.")}
|
|
Set-Item -Path ('Env:' + ${psSingleQuote(input.auth.apiKeyEnv)}) -Value ${psSingleQuote(input.auth.apiKeyValue)}
|
|
$agentOk = $false
|
|
for ($attempt = 1; $attempt -le 2; $attempt++) {
|
|
$sessionId = if ($attempt -eq 1) { 'parallels-npm-update-windows' } else { "parallels-npm-update-windows-retry-$attempt" }
|
|
$output = Invoke-OpenClaw agent --local --agent main --session-id $sessionId --model ${psSingleQuote(input.auth.modelId)} --message 'Reply with exact ASCII text OK only.' --thinking minimal --timeout ${resolveParallelsModelTimeoutSeconds("windows")} --json 2>&1
|
|
if ($null -ne $output) { $output | ForEach-Object { $_ } }
|
|
if ($LASTEXITCODE -ne 0) { throw "agent failed with exit code $LASTEXITCODE" }
|
|
if (($output | Out-String) -match '"finalAssistant(Raw|Visible)Text":\\s*"OK"') {
|
|
$agentOk = $true
|
|
break
|
|
}
|
|
if ($attempt -lt 2) {
|
|
Write-Host "agent turn attempt $attempt finished without OK response; retrying"
|
|
Start-Sleep -Seconds 3
|
|
}
|
|
}
|
|
if (-not $agentOk) { throw 'openclaw agent finished without OK response' }`;
|
|
}
|
|
|
|
export function macosUpdateScript(input: NpmUpdateScriptInput): string {
|
|
return String.raw`set -euo pipefail
|
|
export PATH=/opt/homebrew/bin:/opt/homebrew/opt/node/bin:/opt/homebrew/sbin:/usr/bin:/bin:/usr/sbin:/sbin
|
|
scrub_future_plugin_entries() {
|
|
python3 - <<'PY'
|
|
import json
|
|
from pathlib import Path
|
|
path = Path.home() / ".openclaw" / "openclaw.json"
|
|
if not path.exists():
|
|
raise SystemExit(0)
|
|
try:
|
|
config = json.loads(path.read_text())
|
|
except Exception:
|
|
raise SystemExit(0)
|
|
plugins = config.get("plugins")
|
|
if not isinstance(plugins, dict):
|
|
raise SystemExit(0)
|
|
entries = plugins.get("entries")
|
|
if isinstance(entries, dict):
|
|
entries.pop("feishu", None)
|
|
entries.pop("whatsapp", None)
|
|
entries.pop("openai", None)
|
|
allow = plugins.get("allow")
|
|
if isinstance(allow, list):
|
|
plugins["allow"] = [item for item in allow if item not in {"feishu", "whatsapp", "openai"}]
|
|
path.write_text(json.dumps(config, indent=2) + "\n")
|
|
PY
|
|
}
|
|
stop_openclaw_gateway_processes() {
|
|
OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 /opt/homebrew/bin/openclaw gateway stop || true
|
|
pkill -f 'openclaw.*gateway' >/dev/null 2>&1 || true
|
|
if command -v lsof >/dev/null 2>&1; then
|
|
pids="$(lsof -tiTCP:18789 -sTCP:LISTEN 2>/dev/null || true)"
|
|
if [ -n "$pids" ]; then
|
|
kill $pids >/dev/null 2>&1 || true
|
|
sleep 2
|
|
kill -9 $pids >/dev/null 2>&1 || true
|
|
fi
|
|
fi
|
|
}
|
|
start_openclaw_gateway() {
|
|
stop_openclaw_gateway_processes
|
|
rm -f /tmp/openclaw-parallels-macos-gateway.log
|
|
trap '' HUP
|
|
/usr/bin/env OPENCLAW_HOME="$HOME" OPENCLAW_STATE_DIR="$HOME/.openclaw" OPENCLAW_CONFIG_PATH="$HOME/.openclaw/openclaw.json" ${input.auth.apiKeyEnv}=${shellQuote(
|
|
input.auth.apiKeyValue,
|
|
)} /opt/homebrew/bin/openclaw gateway run --bind loopback --port 18789 --force >/tmp/openclaw-parallels-macos-gateway.log 2>&1 </dev/null &
|
|
sleep 1
|
|
}
|
|
wait_for_gateway() {
|
|
deadline=$((SECONDS + 240))
|
|
while [ "$SECONDS" -lt "$deadline" ]; do
|
|
if /opt/homebrew/bin/openclaw gateway status --deep --require-rpc --timeout 15000; then
|
|
return
|
|
fi
|
|
sleep 2
|
|
done
|
|
cat /tmp/openclaw-parallels-macos-gateway.log >&2 || true
|
|
echo "gateway did not become ready after update" >&2
|
|
exit 1
|
|
}
|
|
scrub_future_plugin_entries
|
|
stop_openclaw_gateway_processes
|
|
OPENCLAW_ALLOW_OLDER_BINARY_DESTRUCTIVE_ACTIONS=1 OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 /opt/homebrew/bin/openclaw update --tag ${shellQuote(input.updateTarget)} --yes --json --no-restart
|
|
${posixVersionCheck("/opt/homebrew/bin/openclaw", input.expectedNeedle)}
|
|
start_openclaw_gateway
|
|
wait_for_gateway
|
|
/opt/homebrew/bin/openclaw models set ${shellQuote(input.auth.modelId)}
|
|
${posixModelProviderConfigCommands("/opt/homebrew/bin/openclaw", input.auth.modelId, "macos")}
|
|
/opt/homebrew/bin/openclaw config set agents.defaults.skipBootstrap true --strict-json
|
|
/opt/homebrew/bin/openclaw config set tools.profile minimal
|
|
${posixAgentWorkspaceScript("Parallels npm update smoke test assistant.")}
|
|
${posixAssertAgentOkScript("/opt/homebrew/bin/openclaw", input, "parallels-npm-update-macos")}`;
|
|
}
|
|
|
|
export function windowsUpdateScript(input: NpmUpdateScriptInput): string {
|
|
return `$ErrorActionPreference = 'Stop'
|
|
$PSNativeCommandUseErrorActionPreference = $false
|
|
${windowsOpenClawResolver}
|
|
${windowsScopedEnvFunction}
|
|
function Remove-FuturePluginEntries {
|
|
$configPath = Join-Path $env:USERPROFILE '.openclaw\\openclaw.json'
|
|
if (-not (Test-Path $configPath)) { return }
|
|
try { $config = Get-Content $configPath -Raw | ConvertFrom-Json -AsHashtable } catch { return }
|
|
$plugins = $config['plugins']
|
|
if (-not ($plugins -is [hashtable])) { return }
|
|
$entries = $plugins['entries']
|
|
if ($entries -is [hashtable]) {
|
|
foreach ($pluginId in @('feishu', 'whatsapp', 'openai')) {
|
|
if ($entries.ContainsKey($pluginId)) { $entries.Remove($pluginId) }
|
|
}
|
|
}
|
|
$allow = $plugins['allow']
|
|
if ($allow -is [array]) {
|
|
$plugins['allow'] = @($allow | Where-Object { $_ -notin @('feishu', 'whatsapp', 'openai') })
|
|
}
|
|
$config | ConvertTo-Json -Depth 100 | Set-Content -Path $configPath -Encoding UTF8
|
|
}
|
|
function Stop-OpenClawGatewayProcesses {
|
|
Invoke-OpenClaw gateway stop *>&1 | Out-Host
|
|
Get-CimInstance Win32_Process -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.CommandLine -match 'openclaw.*gateway' } |
|
|
ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }
|
|
Get-NetTCPConnection -LocalPort 18789 -State Listen -ErrorAction SilentlyContinue |
|
|
Select-Object -ExpandProperty OwningProcess -Unique |
|
|
ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
Remove-FuturePluginEntries
|
|
Stop-OpenClawGatewayProcesses
|
|
${windowsUpdateWithBundledPluginsDisabled(input)}
|
|
if ($updateExit -ne 0) {
|
|
$updateText = $updateOutput | Out-String
|
|
$stalePostSwapImport = $updateText -match 'ERR_MODULE_NOT_FOUND' -and $updateText -match ${psSingleQuote(windowsStalePostSwapImportRegex)}
|
|
if (-not $stalePostSwapImport) { throw "openclaw update failed with exit code $updateExit" }
|
|
Write-Host "openclaw update returned a stale post-swap module import; continuing to post-update health checks"
|
|
}
|
|
${windowsVersionCheck(input.expectedNeedle)}
|
|
${windowsGatewayReadyScript()}
|
|
${windowsAssertAgentOkScript(input)}`;
|
|
}
|
|
|
|
export function linuxUpdateScript(input: NpmUpdateScriptInput): string {
|
|
return String.raw`set -euo pipefail
|
|
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/snap/bin
|
|
export OPENCLAW_ALLOW_ROOT=1
|
|
scrub_future_plugin_entries() {
|
|
node - <<'JS'
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
const configPath = path.join(process.env.HOME || "/root", ".openclaw", "openclaw.json");
|
|
if (!fs.existsSync(configPath)) process.exit(0);
|
|
let config;
|
|
try { config = JSON.parse(fs.readFileSync(configPath, "utf8")); } catch { process.exit(0); }
|
|
const plugins = config.plugins;
|
|
if (!plugins || typeof plugins !== "object") process.exit(0);
|
|
if (plugins.entries && typeof plugins.entries === "object") {
|
|
delete plugins.entries.feishu;
|
|
delete plugins.entries.whatsapp;
|
|
delete plugins.entries.openai;
|
|
}
|
|
if (Array.isArray(plugins.allow)) {
|
|
plugins.allow = plugins.allow.filter((id) => id !== "feishu" && id !== "whatsapp" && id !== "openai");
|
|
}
|
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
JS
|
|
}
|
|
stop_openclaw_gateway_processes() {
|
|
OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 OPENCLAW_ALLOW_ROOT=1 openclaw gateway stop || true
|
|
pkill -f 'openclaw.*gateway' >/dev/null 2>&1 || true
|
|
}
|
|
start_openclaw_gateway() {
|
|
pkill -f "openclaw gateway run" >/dev/null 2>&1 || true
|
|
rm -f /tmp/openclaw-parallels-linux-gateway.log
|
|
setsid sh -lc ${shellQuote(
|
|
`exec env OPENCLAW_HOME=/root OPENCLAW_STATE_DIR=/root/.openclaw OPENCLAW_CONFIG_PATH=/root/.openclaw/openclaw.json OPENCLAW_DISABLE_BONJOUR=1 OPENCLAW_ALLOW_ROOT=1 ${input.auth.apiKeyEnv}=${shellQuote(
|
|
input.auth.apiKeyValue,
|
|
)} openclaw gateway run --bind loopback --port 18789 --force >/tmp/openclaw-parallels-linux-gateway.log 2>&1`,
|
|
)} >/dev/null 2>&1 < /dev/null &
|
|
}
|
|
wait_for_gateway() {
|
|
deadline=$((SECONDS + 240))
|
|
while [ "$SECONDS" -lt "$deadline" ]; do
|
|
if openclaw gateway status --deep --require-rpc --timeout 15000; then
|
|
return
|
|
fi
|
|
sleep 2
|
|
done
|
|
cat /tmp/openclaw-parallels-linux-gateway.log >&2 || true
|
|
echo "gateway did not become ready after update" >&2
|
|
exit 1
|
|
}
|
|
scrub_future_plugin_entries
|
|
stop_openclaw_gateway_processes
|
|
OPENCLAW_ALLOW_OLDER_BINARY_DESTRUCTIVE_ACTIONS=1 OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 openclaw update --tag ${shellQuote(input.updateTarget)} --yes --json --no-restart
|
|
${posixVersionCheck("openclaw", input.expectedNeedle)}
|
|
start_openclaw_gateway
|
|
wait_for_gateway
|
|
openclaw models set ${shellQuote(input.auth.modelId)}
|
|
${posixModelProviderConfigCommands("openclaw", input.auth.modelId, "linux")}
|
|
openclaw config set agents.defaults.skipBootstrap true --strict-json
|
|
openclaw config set tools.profile minimal
|
|
${posixAgentWorkspaceScript("Parallels npm update smoke test assistant.")}
|
|
${posixAssertAgentOkScript("openclaw", input, "parallels-npm-update-linux")}`;
|
|
}
|
|
|
|
function posixVersionCheck(command: string, expectedNeedle: string): string {
|
|
const quotedNeedle = shellQuote(expectedNeedle);
|
|
if (!expectedNeedle) {
|
|
return `hash -r || true
|
|
version_deadline=$((SECONDS + 60))
|
|
while true; do
|
|
if version="$(${command} --version 2>&1)"; then
|
|
version_status=0
|
|
printf '%s\\n' "$version"
|
|
break
|
|
else
|
|
version_status=$?
|
|
printf '%s\\n' "$version"
|
|
fi
|
|
if [ "$SECONDS" -ge "$version_deadline" ]; then
|
|
exit "$version_status"
|
|
fi
|
|
sleep 2
|
|
done`;
|
|
}
|
|
return `hash -r || true
|
|
version_deadline=$((SECONDS + 60))
|
|
while true; do
|
|
if version="$(${command} --version 2>&1)"; then
|
|
version_status=0
|
|
printf '%s\\n' "$version"
|
|
case "$version" in *${quotedNeedle}*) break ;; esac
|
|
else
|
|
version_status=$?
|
|
printf '%s\\n' "$version"
|
|
fi
|
|
if [ "$SECONDS" -ge "$version_deadline" ]; then
|
|
if [ "$version_status" -ne 0 ]; then
|
|
exit "$version_status"
|
|
fi
|
|
echo "version mismatch: expected ${expectedNeedle}" >&2
|
|
exit 1
|
|
fi
|
|
sleep 2
|
|
done`;
|
|
}
|
|
|
|
function windowsVersionCheck(expectedNeedle: string): string {
|
|
if (!expectedNeedle) {
|
|
return `$versionDeadline = (Get-Date).AddSeconds(60)
|
|
while ($true) {
|
|
$version = Invoke-OpenClaw --version
|
|
$version
|
|
if ($LASTEXITCODE -eq 0) { break }
|
|
if ((Get-Date) -ge $versionDeadline) { throw "openclaw --version failed with exit code $LASTEXITCODE" }
|
|
Start-Sleep -Seconds 2
|
|
}`;
|
|
}
|
|
const expectedPattern = psSingleQuote(`*${expectedNeedle}*`);
|
|
const mismatch = psSingleQuote(`version mismatch: expected ${expectedNeedle}`);
|
|
return `$versionDeadline = (Get-Date).AddSeconds(60)
|
|
while ($true) {
|
|
$version = Invoke-OpenClaw --version
|
|
$version
|
|
if ($LASTEXITCODE -eq 0 -and (($version | Out-String) -like ${expectedPattern})) { break }
|
|
if ((Get-Date) -ge $versionDeadline) {
|
|
if ($LASTEXITCODE -ne 0) { throw "openclaw --version failed with exit code $LASTEXITCODE" }
|
|
throw ${mismatch}
|
|
}
|
|
Start-Sleep -Seconds 2
|
|
}`;
|
|
}
|