リリースと署名の確かめ方
安全にインストール、更新、削除します。
インストール
curl -fsSL https://agi-labo.com/wings/install.sh | sh
インストーラーは、CLI 本体とリリース情報の署名を確かめてから配置します。
確認には、インストーラーに入っている公開鍵を使います。
最新版の番号は、Console で公開している情報とも HTTPS で照合します。
Windows は Git Bash・MSYS2・Cygwin で同じコマンドを使えます。
Git for Windows には、署名確認に必要な ssh-keygen と sha256sum が含まれます。
不足している場合は、検証を省略せずインストールを止めます。
PowerShell 5.1 / 7 では、次の PowerShell 用コマンドを使えます。
irm https://agi-labo.com/wings/install.ps1 | iex
Windows OpenSSH クライアントの ssh-keygen.exe が必要です。見つからない場合は停止し、Git Bash のコマンドを案内します。署名の確認は省略しません。
WSL では Linux 版を使う想定ですが、実動作は未確認です。
この1行の方法では、インストーラーと公開鍵を配る HTTPS のサイトを信頼します。 インストーラー自体の署名は、実行前に確かめません。 先に署名を検証したい場合は、次の手順を使ってください。
curl | sh では、ダウンロードの失敗が sh に伝わりません。
ただし、ダウンロードが途中で切れた場合は、末尾の呼び出しまで届かなければ処理を始めない構造です。
署名を確かめてから実行する(上級)
版を指定してインストーラーと署名を取得します。 次の手順は、固定した公開鍵で検証が成功したときだけ実行します。
(
set -eu
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' 0 HUP INT TERM
curl -fsSLo "$tmp_dir/install.sh" https://releases.agi-labo.com/wings/v1.4.24/install.sh
curl -fsSLo "$tmp_dir/install.sh.sshsig" https://releases.agi-labo.com/wings/v1.4.24/install.sh.sshsig
printf '%s\n' 'agi-wings-release ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP0F1UbSUyGSbSD6+Gb1TKPiWgokOw5fFW7bmdWaTdro' > "$tmp_dir/allowed-signers"
ssh-keygen -Y verify -f "$tmp_dir/allowed-signers" -I agi-wings-release -n agi-wings-release -s "$tmp_dir/install.sh.sshsig" < "$tmp_dir/install.sh"
sh "$tmp_dir/install.sh"
)
PowerShell で署名を確かめる
Windows PowerShell 5.1 / PowerShell 7 では、次を使ってください。
TEMP は %USERPROFILE% の中にあり、そこまでのフォルダーを本人以外が書き換えられない必要があります。SYSTEM と Administrators は信頼される主体として扱います。安全でない所有者・権限・リンクがあれば、権限を変更せずに停止します。OS が管理するユーザープロファイルより上のフォルダーは権限確認の対象外ですが、リンクは拒否します。作業フォルダーを本人だけが使えるようにしてからダウンロードし、検証した同じバイト列を実行します。
& {
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
function Get-WingsVerificationSshKeygen {
$windows = [Environment]::GetFolderPath('Windows')
foreach ($candidate in @("$windows\Sysnative\OpenSSH\ssh-keygen.exe", "$windows\System32\OpenSSH\ssh-keygen.exe")) {
if (Test-Path -LiteralPath $candidate -PathType Leaf) { return $candidate }
}
throw 'OpenSSH is required. Use the Git Bash installer if it is unavailable.'
}
function New-WingsVerificationDirectory {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$fileSystem = New-Object -ComObject Scripting.FileSystemObject
$profileFolder = $null
$tempFolder = $null
try {
$profileFolder = $fileSystem.GetFolder($env:USERPROFILE)
$tempFolder = $fileSystem.GetFolder([IO.Path]::GetTempPath())
$profile = $profileFolder.ShortPath.TrimEnd('\')
$temporary = $tempFolder.ShortPath.TrimEnd('\')
if ($profile -notmatch '^[a-zA-Z]:\\' -or (-not $temporary.Equals($profile, [StringComparison]::OrdinalIgnoreCase) -and -not $temporary.StartsWith($profile + '\', [StringComparison]::OrdinalIgnoreCase))) {
throw 'TEMP must be inside the current user profile.'
}
$owners = @($identity.User, $identity.Owner, (New-Object Security.Principal.SecurityIdentifier('S-1-5-18')), (New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')))
$ownerRights = New-Object Security.Principal.SecurityIdentifier('S-1-3-4')
$creatorOwner = New-Object Security.Principal.SecurityIdentifier('S-1-3-0')
$paths = @()
for ($current = $temporary; $current; $current = [IO.Path]::GetDirectoryName($current)) { $paths = @($current) + $paths }
$insideProfile = $false
foreach ($path in $paths) {
$item = Get-Item -LiteralPath $path -Force
if (-not $item.PSIsContainer -or (([int]$item.Attributes -band 1024) -ne 0)) { throw 'TEMP ancestors must be real directories without links or reparse points.' }
if ($path.Equals($profile, [StringComparison]::OrdinalIgnoreCase)) { $insideProfile = $true }
if (-not $insideProfile) { continue }
$acl = Get-Acl -LiteralPath $path
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
if (@($owners | Where-Object { $_.Equals($owner) }).Count -eq 0) { throw 'TEMP ancestors must have a trusted owner.' }
$descriptor = New-Object Security.AccessControl.RawSecurityDescriptor($acl.GetSecurityDescriptorBinaryForm(), 0)
if ($null -eq $descriptor.DiscretionaryAcl) { throw 'TEMP ancestors must not have a null DACL.' }
foreach ($ace in $descriptor.DiscretionaryAcl) {
if ([int]$ace.AceType -eq 1) { continue }
if ([int]$ace.AceType -ne 0) { throw 'TEMP ancestors contain an unsupported ACL entry.' }
$trustee = $ace.SecurityIdentifier
if (@($owners | Where-Object { $_.Equals($trustee) }).Count -gt 0 -or $ownerRights.Equals($trustee)) { continue }
if ($creatorOwner.Equals($trustee) -and (([int]$ace.AceFlags -band 8) -ne 0)) { continue }
$mask = [long]$ace.AccessMask -band 0xffffffffL
if ($mask -band (0xffffffffL -bxor 0xa01200a9L)) { throw 'TEMP ancestors must not grant write access to another user.' }
}
}
$path = Join-Path $temporary ('wings-verify-' + [guid]::NewGuid().ToString('N'))
$private = New-Object Security.AccessControl.DirectorySecurity
$private.SetOwner($identity.User)
$private.SetAccessRuleProtection($true, $false)
$private.AddAccessRule((New-Object Security.AccessControl.FileSystemAccessRule($identity.User, 'FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow')))
New-Item -ItemType Directory -Path $path | Out-Null
try { Set-Acl -LiteralPath $path -AclObject $private }
catch { Remove-Item -LiteralPath $path -Force; throw }
return $path
} finally {
foreach ($folder in @($profileFolder, $tempFolder, $fileSystem)) {
if ($folder) { [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($folder) }
}
$identity.Dispose()
}
}
$verifier = Get-WingsVerificationSshKeygen
$tmpDir = New-WingsVerificationDirectory
$tls = [Net.ServicePointManager]::SecurityProtocol
$process = $null
try {
[Net.ServicePointManager]::SecurityProtocol = $tls -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -Uri 'https://releases.agi-labo.com/wings/v1.4.24/install.ps1' -OutFile "$tmpDir\install.ps1"
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -Uri 'https://releases.agi-labo.com/wings/v1.4.24/install.ps1.sshsig' -OutFile "$tmpDir\install.ps1.sshsig"
[IO.File]::WriteAllText("$tmpDir\allowed-signers", "agi-wings-release ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP0F1UbSUyGSbSD6+Gb1TKPiWgokOw5fFW7bmdWaTdro`n", (New-Object Text.UTF8Encoding($false)))
$installerBytes = [IO.File]::ReadAllBytes("$tmpDir\install.ps1")
$start = New-Object Diagnostics.ProcessStartInfo
$start.FileName = $verifier
$start.Arguments = '-Y verify -f "{0}\allowed-signers" -I agi-wings-release -n agi-wings-release -s "{0}\install.ps1.sshsig"' -f $tmpDir
$start.UseShellExecute = $false
$start.CreateNoWindow = $true
$start.RedirectStandardInput = $true
$start.RedirectStandardOutput = $true
$start.RedirectStandardError = $true
$process = New-Object Diagnostics.Process
$process.StartInfo = $start
$inputEncoding = [Console]::InputEncoding
$restoreInputEncoding = $false
try {
if ($start.PSObject.Properties['StandardInputEncoding']) { $start.StandardInputEncoding = New-Object Text.UTF8Encoding($false) }
elseif ($inputEncoding.GetPreamble().Length -gt 0) {
[Console]::InputEncoding = New-Object Text.UTF8Encoding($false)
$restoreInputEncoding = $true
}
[void]$process.Start()
} finally { if ($restoreInputEncoding) { [Console]::InputEncoding = $inputEncoding } }
$stdout = $process.StandardOutput.ReadToEndAsync()
$stderr = $process.StandardError.ReadToEndAsync()
$process.StandardInput.BaseStream.Write($installerBytes, 0, $installerBytes.Length)
$process.StandardInput.Close()
if (-not $process.WaitForExit(60000)) { $process.Kill(); throw 'Installer signature verification timed out.' }
$null = $stdout.GetAwaiter().GetResult()
$diagnostic = $stderr.GetAwaiter().GetResult()
if ($process.ExitCode -ne 0) { throw "Installer signature verification failed (ssh-keygen exit code $($process.ExitCode)): $diagnostic" }
Invoke-Expression ([Text.Encoding]::UTF8.GetString($installerBytes))
} finally {
if ($process) { $process.Dispose() }
[Net.ServicePointManager]::SecurityProtocol = $tls
Remove-Item -LiteralPath $tmpDir -Recurse -Force
}
}
更新する
wings update --check
wings update
wings version
通常の更新では、最新版を示す情報、ファイル一覧、チェックサム、本体の署名を検証します。 最新版を示す署名には、短い有効期限があります。 手元に更新の記録がない初回は、Console の current-release 情報も HTTPS で確認します。 検証に失敗した場合は、今の CLI を置き換えません。
Windows の更新は、検証済みの新しい exe を用意し、動作中の旧 exe を同じディレクトリへ退避してから置き換えます。 退避したファイルは、次に CLI を起動したときに削除します。使用中なら後の起動で再試行します。 Windows Authenticode 署名は提供していません。署名検証は他の OS と同じ sshsig-ed25519 です。
版を指定する
wings update --base-url https://releases.agi-labo.com/wings/vX.Y.Z
版を指定するときは、--base-url を明示してください。
更新コマンドは、AGI_WINGS_INSTALL_BASE_URL と AGI_WINGS_CURRENT_RELEASE_URL を参照しません。
通常は、古い版への更新を拒否します。 運営が短期の署名付きで許可した場合だけ、通常の更新手順で戻せます。
macOS の notarization と Gatekeeper による許可は保証していません。 OS が実行を止めた場合は、署名の検証結果を確認してサポートへ問い合わせてください。 警告だけを無条件に回避しないでください。
アンインストール
wings logout
wings skill uninstall --target all --yes
rm "$HOME/.agi-tools/bin/wings"
--yes は削除の確認を省きます。端末以外から実行するときは必須です。
サーバー側のログアウトに失敗した場合は、表示された案内に従ってください。 アンインストールしても、クラウドの Handler などは消えません。 データ削除は、別に行います。
Windows の CLI を削除する場合は rm "$(cygpath -u -- "$USERPROFILE")/.agi-tools/bin/wings.exe" を使ってください。
PowerShell で CLI を削除する場合は Remove-Item -LiteralPath "$env:USERPROFILE\.agi-tools\bin\wings.exe" を使ってください。