2026-07-27 13:03:21 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory = $true, Position = 0)]
|
|
|
|
|
[ValidateSet("memory", "companion", "both")]
|
|
|
|
|
[string]$Target,
|
|
|
|
|
|
|
|
|
|
[Parameter(Position = 1, ValueFromRemainingArguments = $true)]
|
|
|
|
|
[string[]]$Files = @(),
|
|
|
|
|
|
|
|
|
|
[string]$VmHost = "192.168.31.215",
|
|
|
|
|
[string]$VmUser = "agent",
|
|
|
|
|
[ValidateRange(1, 65535)]
|
|
|
|
|
[int]$SshPort = 22,
|
|
|
|
|
[string]$SshKey = (Join-Path $env:USERPROFILE ".codex\ssh\astrbot_vm_ed25519"),
|
|
|
|
|
[string]$PythonBin = "C:\Users\Administrator\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe",
|
2026-07-27 13:14:23 +08:00
|
|
|
[switch]$SkipLocalTests,
|
|
|
|
|
[switch]$EnableDetailEnhancement
|
2026-07-27 13:03:21 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
|
|
|
|
$bashCandidates = @(
|
|
|
|
|
"C:\Program Files\Git\bin\bash.exe",
|
|
|
|
|
"C:\Program Files\Git\usr\bin\bash.exe"
|
|
|
|
|
)
|
|
|
|
|
$bash = $bashCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
|
|
|
|
|
if (-not $bash) {
|
|
|
|
|
throw "Git Bash is required. Install Git for Windows or invoke ops/deploy-plugin.sh from Bash."
|
|
|
|
|
}
|
|
|
|
|
if (-not (Test-Path $SshKey)) { throw "SSH private key not found: $SshKey" }
|
|
|
|
|
if (-not $SkipLocalTests -and -not (Test-Path $PythonBin)) { throw "Python interpreter not found: $PythonBin" }
|
|
|
|
|
|
|
|
|
|
function Convert-ToGitBashPath([string]$Path) {
|
|
|
|
|
$converted = & $bash -lc 'cygpath -u "$1"' -- $Path
|
|
|
|
|
if ($LASTEXITCODE -ne 0 -or -not $converted) { throw "Could not convert path for Git Bash: $Path" }
|
|
|
|
|
return $converted.Trim()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$env:VM = "$VmUser@$VmHost"
|
|
|
|
|
$env:SSH_PORT = "$SshPort"
|
|
|
|
|
$env:SSH_KEY = Convert-ToGitBashPath $SshKey
|
|
|
|
|
$env:PYTHON_BIN = if ($SkipLocalTests) { "python" } else { Convert-ToGitBashPath $PythonBin }
|
|
|
|
|
$env:SKIP_LOCAL_TESTS = if ($SkipLocalTests) { "1" } else { "0" }
|
2026-07-27 13:14:23 +08:00
|
|
|
$env:DETAIL_ENHANCEMENT_ENABLED = if ($EnableDetailEnhancement) { "1" } else { "" }
|
2026-07-27 13:03:21 +08:00
|
|
|
|
|
|
|
|
$script = Join-Path $PSScriptRoot "deploy-plugin.sh"
|
|
|
|
|
& $bash $script $Target @Files
|
|
|
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|