




















@@ -45,7 +45,7 @@ TIMEOUT_UPDATE_S=300
4545TIMEOUT_UPDATE_POLL_GRACE_S=60
4646TIMEOUT_VERIFY_S=120
4747TIMEOUT_ONBOARD_S=240
48-TIMEOUT_ONBOARD_PHASE_S=$((TIMEOUT_ONBOARD_S + 60))
48+TIMEOUT_ONBOARD_PHASE_S=$((TIMEOUT_ONBOARD_S + 120))
4949# verify_gateway_reachable runs six 30s probes plus short retry sleeps.
5050TIMEOUT_GATEWAY_S=240
5151TIMEOUT_AGENT_S=180
@@ -1997,8 +1997,10 @@ param(
1997199719981998try {
19991999 \$openclaw = Join-Path \$env:APPDATA 'npm\openclaw.cmd'
2000- \$cmdLine = ('"{0}" onboard --non-interactive --mode local --auth-choice ${AUTH_CHOICE} --secret-input-mode ref --gateway-port 18789 --gateway-bind loopback --install-daemon --skip-skills --skip-health --accept-risk --json > "{1}" 2>&1' -f \$openclaw, \$LogPath)
2000+ Set-Content -Path \$LogPath -Value 'onboard.start'
2001+ \$cmdLine = ('"{0}" onboard --non-interactive --mode local --auth-choice ${AUTH_CHOICE} --secret-input-mode ref --gateway-port 18789 --gateway-bind loopback --install-daemon --skip-skills --skip-health --accept-risk --json >> "{1}" 2>&1' -f \$openclaw, \$LogPath)
20012002 & cmd.exe /d /s /c \$cmdLine
2003+ Add-Content -Path \$LogPath -Value ('onboard.exit={0}' -f \$LASTEXITCODE)
20022004 Set-Content -Path \$DonePath -Value ([string]\$LASTEXITCODE)
20032005} catch {
20042006 if (Test-Path \$LogPath) {
@@ -2015,6 +2017,7 @@ run_ref_onboard() {
20152017local api_key_env_q api_key_value_q script_url
20162018local runner_name log_name done_name done_status launcher_state
20172019local poll_rc state_rc log_rc start_seconds poll_deadline startup_checked
2020+local guest_log log_state_path
20182021 api_key_env_q="$(ps_single_quote "$API_KEY_ENV")"
20192022 api_key_value_q="$(ps_single_quote "$API_KEY_VALUE")"
20202023 write_onboard_runner_script
@@ -2025,6 +2028,8 @@ run_ref_onboard() {
20252028 start_seconds="$SECONDS"
20262029 poll_deadline=$((SECONDS + TIMEOUT_ONBOARD_S + 60))
20272030 startup_checked=0
2031+ log_state_path="$(mktemp "${TMPDIR:-/tmp}/openclaw-onboard-log-state.XXXXXX")"
2032+: >"$log_state_path"
2028203320292034 guest_powershell "$(cat <<EOF
20302035\$runner = Join-Path \$env:TEMP '$runner_name'
@@ -2037,6 +2042,34 @@ Start-Process powershell.exe -ArgumentList @('-NoProfile', '-ExecutionPolicy', '
20372042EOF
20382043)"
203920442045+stream_windows_onboard_log() {
2046+set +e
2047+ guest_log="$(
2048+ guest_powershell_poll 20 "\$log = Join-Path \$env:TEMP '$log_name'; if (Test-Path \$log) { Get-Content \$log }"
2049+ )"
2050+ log_rc=$?
2051+set -e
2052+if [[ $log_rc -ne 0 ]] || [[ -z "$guest_log" ]]; then
2053+return "$log_rc"
2054+fi
2055+ GUEST_LOG="$guest_log" python3 - "$log_state_path" <<'PY'
2056+import os
2057+import pathlib
2058+import sys
2059+2060+state_path = pathlib.Path(sys.argv[1])
2061+previous = state_path.read_text(encoding="utf-8", errors="replace")
2062+current = os.environ["GUEST_LOG"].replace("\r\n", "\n").replace("\r", "\n")
2063+2064+if current.startswith(previous):
2065+ sys.stdout.write(current[len(previous):])
2066+else:
2067+ sys.stdout.write(current)
2068+2069+state_path.write_text(current, encoding="utf-8")
2070+PY
2071+ }
2072+20402073while :; do
20412074set +e
20422075 done_status="$(
@@ -2049,19 +2082,24 @@ EOF
20492082 warn "windows onboard helper poll failed; retrying"
20502083if (( SECONDS >= poll_deadline )); then
20512084 warn "windows onboard helper timed out while polling done file"
2085+ rm -f "$log_state_path"
20522086return 1
20532087fi
20542088 sleep 2
20552089continue
20562090fi
2091+set +e
2092+ stream_windows_onboard_log
2093+ log_rc=$?
2094+set -e
2095+if [[ $log_rc -ne 0 ]]; then
2096+ warn "windows onboard helper live log poll failed; retrying"
2097+fi
20572098if [[ -n "$done_status" ]]; then
2058-set +e
2059- guest_powershell_poll 20 "\$log = Join-Path \$env:TEMP '$log_name'; if (Test-Path \$log) { Get-Content \$log }"
2060- log_rc=$?
2061-set -e
2062-if [[ $log_rc -ne 0 ]]; then
2099+if ! stream_windows_onboard_log; then
20632100 warn "windows onboard helper log drain failed after completion"
20642101fi
2102+ rm -f "$log_state_path"
20652103 [[ "$done_status" == "0" ]]
20662104return $?
20672105fi
@@ -2076,18 +2114,16 @@ EOF
20762114 startup_checked=1
20772115if [[ $state_rc -eq 0 && "$launcher_state" == *"runner=False"* && "$launcher_state" == *"log=False"* && "$launcher_state" == *"done=False"* ]]; then
20782116 warn "windows onboard helper failed to materialize guest files"
2117+ rm -f "$log_state_path"
20792118return 1
20802119fi
20812120fi
20822121if (( SECONDS >= poll_deadline )); then
2083-set +e
2084- guest_powershell_poll 20 "\$log = Join-Path \$env:TEMP '$log_name'; if (Test-Path \$log) { Get-Content \$log }"
2085- log_rc=$?
2086-set -e
2087-if [[ $log_rc -ne 0 ]]; then
2122+if ! stream_windows_onboard_log; then
20882123 warn "windows onboard helper log drain failed after timeout"
20892124fi
20902125 warn "windows onboard helper timed out waiting for done file"
2126+ rm -f "$log_state_path"
20912127return 1
20922128fi
20932129 sleep 2
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。