diff --git a/A2A_node/scripts/a2a.py b/A2A_node/scripts/a2a.py index f3c56b9..047a7b5 100644 --- a/A2A_node/scripts/a2a.py +++ b/A2A_node/scripts/a2a.py @@ -855,7 +855,8 @@ def cmd_bmem(a): line = "A2A-NODE %s %s" % (cfg["node_id"], " ".join(urls)) print("bmem add --global", line) if not a.dry_run: - subprocess.run(["bmem", "add", "--global", line]) + # which() honours PATHEXT, so a bmem.cmd shim is found too (CreateProcess alone is not) + subprocess.run([shutil.which("bmem") or "bmem", "add", "--global", line], check=True) def main(): diff --git a/A2A_node/scripts/manage.ps1 b/A2A_node/scripts/manage.ps1 index f02364a..47c108d 100644 --- a/A2A_node/scripts/manage.ps1 +++ b/A2A_node/scripts/manage.ps1 @@ -54,13 +54,20 @@ switch ($Action) { Copy-Item (Join-Path $PSScriptRoot 'claude-a2a.cmd') $dst -Force $mcp = (Get-Content (Join-Path $ch 'mcp.json') -Raw) -replace 'C:/Users/bowei', $env:USERPROFILE.Replace('\', '/') Set-Content (Join-Path $ch 'mcp.json') $mcp -Encoding ascii - Push-Location $ch; npm install --no-audit --no-fund 2>&1 | Out-Null; Pop-Location + # via cmd: under PS 5.1 + ErrorActionPreference=Stop, npm.ps1's stderr "npm notice" lines abort the install + Push-Location $ch; cmd /c "npm install --no-audit --no-fund >nul 2>&1"; $npmRc = $LASTEXITCODE; Pop-Location + if ($npmRc -ne 0) { throw "npm install failed in $ch (exit $npmRc)" } # cmd shim so sessions can just call `a2a` "@python `"$script`" %*" | Set-Content (Join-Path $dst 'a2a.cmd') -Encoding ascii $act = New-ScheduledTaskAction -Execute $py -Argument "`"$script`" serve" $trg = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME $set = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit ([TimeSpan]::Zero) - Register-ScheduledTask -TaskName $task -Action $act -Trigger $trg -Settings $set -Force | Out-Null + # AtLogOn tasks need admin on some machines; fall back to the per-user Run key (no admin, no auto-restart) + try { Register-ScheduledTask -TaskName $task -Action $act -Trigger $trg -Settings $set -Force -ErrorAction Stop | Out-Null; "autostart: scheduled task '$task'" } + catch { + Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name $task -Value "`"$py`" `"$script`" serve" + "autostart: scheduled task denied ($($_.Exception.Message.Trim())); registered HKCU Run '$task' instead" + } Ensure-Firewall Start-Node Start-Sleep 2 @@ -69,5 +76,6 @@ switch ($Action) { 'start' { Start-Node; Start-Sleep 2; & python.exe $script status } 'stop' { Stop-Node; 'stopped' } 'status' { & python.exe $script status; & python.exe $script ls; & python.exe $script peers } - 'uninstall' { Stop-Node; Unregister-ScheduledTask -TaskName $task -Confirm:$false -ErrorAction SilentlyContinue; 'removed (config kept in ~/.a2a)' } + 'uninstall' { Stop-Node; Unregister-ScheduledTask -TaskName $task -Confirm:$false -ErrorAction SilentlyContinue + Remove-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name $task -ErrorAction SilentlyContinue; 'removed (config kept in ~/.a2a)' } }