YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(windows): validate Vulkan target import library
screenpipe Windows autonomous worker182de55b5541
diff --git a/.github/scripts/setup-vulkan-windows.ps1 b/.github/scripts/setup-vulkan-windows.ps1index b8454395c..71d1f9d3e 100644--- a/.github/scripts/setup-vulkan-windows.ps1+++ b/.github/scripts/setup-vulkan-windows.ps1@@ -6,43 +6,105 @@ param([ValidateSet('x64', 'arm64')][string]$Architecture = 'x64',[switch]$InstallSdk,- [string]$StageRuntimeDirectory+ [string]$StageRuntimeDirectory,+ [string]$SdkDirectory)$ErrorActionPreference = 'Stop'$version = '1.4.357.0'$isArm64 = $Architecture -eq 'arm64'+$sdk = if ($SdkDirectory) { $SdkDirectory } else { "C:\VulkanSDK\$version" }-if ($InstallSdk) {- $sdk = "C:\VulkanSDK\$version"- if (Test-Path -LiteralPath "$sdk\Include\vulkan\vulkan.h") {- "VULKAN_SDK=$sdk" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8- "$sdk\Bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8- } else {- $sdkUri = if ($isArm64) {- "https://sdk.lunarg.com/sdk/download/$version/warm/vulkan_sdk.exe"- } else {- "https://sdk.lunarg.com/sdk/download/$version/windows/vulkan_sdk.exe"+function Test-CoffLibraryMachine {+ param(+ [Parameter(Mandatory)] [string]$Path,+ [Parameter(Mandatory)] [UInt16]$ExpectedMachine+ )++ $bytes = [System.IO.File]::ReadAllBytes($Path)+ $archiveMagic = [System.Text.Encoding]::ASCII.GetBytes("!<arch>`n")+ if ($bytes.Length -lt $archiveMagic.Length) { return $false }+ for ($i = 0; $i -lt $archiveMagic.Length; $i++) {+ if ($bytes[$i] -ne $archiveMagic[$i]) { return $false }}- $sdkSha = if ($isArm64) {- 'c10f18a9085018f66e1f50bd60623f17b7081faca165248de54f78728120f334'- } else {- '81f474711e9042f4cd22b31b2f7a8870db2e428b21586fb43dd80150be97310d'++ $offset = 8+ while ($offset + 60 -le $bytes.Length) {+ $sizeText = [System.Text.Encoding]::ASCII.GetString($bytes, $offset + 48, 10).Trim()+ [UInt64]$memberSize = 0+ if (-not [UInt64]::TryParse($sizeText, [ref]$memberSize)) { return $false }+ if ($memberSize -gt [int]::MaxValue) { return $false }+ $dataOffset = $offset + 60+ if ($memberSize -ge 8 -and $dataOffset + $memberSize -le $bytes.Length) {+ # Import objects use 0000 FFFF followed by version and machine.+ if ($bytes[$dataOffset] -eq 0 -and $bytes[$dataOffset + 1] -eq 0 -and+ $bytes[$dataOffset + 2] -eq 0xff -and $bytes[$dataOffset + 3] -eq 0xff) {+ $machine = [BitConverter]::ToUInt16($bytes, $dataOffset + 6)+ if ($machine -eq $ExpectedMachine) { return $true }+ }+ }+ $offset = $dataOffset + [int]$memberSize + ([int]$memberSize % 2)}- if (-not (Test-Path -LiteralPath vulkan_sdk.exe)) {- Invoke-WebRequest -Uri $sdkUri -OutFile vulkan_sdk.exe+ return $false+}++function Get-VulkanLibraryDirectory {+ param(+ [Parameter(Mandatory)] [string]$Sdk,+ [Parameter(Mandatory)] [string]$TargetArchitecture+ )++ [UInt16]$expectedMachine = if ($TargetArchitecture -eq 'arm64') { 0xaa64 } else { 0x8664 }+ $expectedName = if ($TargetArchitecture -eq 'arm64') { 'ARM64 (0xAA64)' } else { 'x64 (0x8664)' }+ $directories = if ($TargetArchitecture -eq 'arm64') { @('Lib', 'Lib-ARM64') } else { @('Lib') }+ $wrongMachine = @()+ foreach ($directory in $directories) {+ $library = Join-Path $Sdk "$directory\vulkan-1.lib"+ if (Test-Path -LiteralPath $library) {+ if (Test-CoffLibraryMachine -Path $library -ExpectedMachine $expectedMachine) {+ return (Split-Path -Parent $library)+ }+ $wrongMachine += $library+ }}- if ((Get-FileHash vulkan_sdk.exe -Algorithm SHA256).Hash.ToLowerInvariant() -ne $sdkSha) {- throw 'Vulkan SDK installer hash mismatch'+ if ($wrongMachine.Count -gt 0) {+ throw "Vulkan SDK has no $expectedName vulkan-1.lib; wrong-architecture library found at: $($wrongMachine -join ', ')"}- & .\vulkan_sdk.exe --accept-licenses --default-answer --confirm-command install copy_only=1- if ($LASTEXITCODE -ne 0) { throw "Vulkan SDK install failed: $LASTEXITCODE" }+ $checked = $directories | ForEach-Object { Join-Path (Join-Path $Sdk $_) 'vulkan-1.lib' }+ throw "Vulkan SDK $expectedName import library missing; checked: $($checked -join ', ')"+}++if ($InstallSdk) {if (-not (Test-Path -LiteralPath "$sdk\Include\vulkan\vulkan.h")) {- throw "Vulkan SDK headers missing at $sdk"+ $sdkUri = if ($isArm64) {+ "https://sdk.lunarg.com/sdk/download/$version/warm/vulkan_sdk.exe"+ } else {+ "https://sdk.lunarg.com/sdk/download/$version/windows/vulkan_sdk.exe"+ }+ $sdkSha = if ($isArm64) {+ 'c10f18a9085018f66e1f50bd60623f17b7081faca165248de54f78728120f334'+ } else {+ '81f474711e9042f4cd22b31b2f7a8870db2e428b21586fb43dd80150be97310d'+ }+ if (-not (Test-Path -LiteralPath vulkan_sdk.exe)) {+ Invoke-WebRequest -Uri $sdkUri -OutFile vulkan_sdk.exe+ }+ if ((Get-FileHash vulkan_sdk.exe -Algorithm SHA256).Hash.ToLowerInvariant() -ne $sdkSha) {+ throw 'Vulkan SDK installer hash mismatch'+ }+ & .\vulkan_sdk.exe --accept-licenses --default-answer --confirm-command install copy_only=1+ if ($LASTEXITCODE -ne 0) { throw "Vulkan SDK install failed: $LASTEXITCODE" }+ if (-not (Test-Path -LiteralPath "$sdk\Include\vulkan\vulkan.h")) {+ throw "Vulkan SDK headers missing at $sdk"+ }}++ $vulkanLibraryDirectory = Get-VulkanLibraryDirectory -Sdk $sdk -TargetArchitecture $Architecture+ $updatedLib = if ($env:LIB) { "$vulkanLibraryDirectory;$env:LIB" } else { $vulkanLibraryDirectory }"VULKAN_SDK=$sdk" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8+ "LIB=$updatedLib" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8"$sdk\Bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8- }+ Write-Host "Validated $Architecture Vulkan import library and added to LIB: $vulkanLibraryDirectory"}if ($StageRuntimeDirectory) {diff --git a/.github/scripts/tests/setup-vulkan-windows.Tests.ps1 b/.github/scripts/tests/setup-vulkan-windows.Tests.ps1new file mode 100644index 000000000..f96c99c4d--- /dev/null+++ b/.github/scripts/tests/setup-vulkan-windows.Tests.ps1@@ -0,0 +1,54 @@+# screenpipe — AI that knows everything you've seen, said, or heard+# https://screenpipe.com++$ErrorActionPreference = 'Stop'+$script = (Resolve-Path "$PSScriptRoot\..\setup-vulkan-windows.ps1").Path+$kits = 'C:\Program Files (x86)\Windows Kits\10\Lib'+$version = Get-ChildItem -LiteralPath $kits -Directory | Sort-Object Name -Descending | Select-Object -First 1+$armLibrary = Join-Path $version.FullName 'um\arm64\kernel32.lib'+$x64Library = Join-Path $version.FullName 'um\x64\kernel32.lib'+if (-not (Test-Path $armLibrary) -or -not (Test-Path $x64Library)) {+ throw 'Windows SDK ARM64 and x64 import libraries are required for this test'+}++$root = Join-Path $env:TEMP "screenpipe-vulkan-test-$PID"+New-Item -ItemType Directory -Path $root | Out-Null+try {+ function Invoke-Case {+ param([string]$Name, [string]$Architecture, [hashtable]$Libraries, [string]$ExpectedDirectory, [string]$ExpectedError)+ $sdk = Join-Path $root $Name+ New-Item -ItemType Directory -Path "$sdk\Include\vulkan", "$sdk\Bin" -Force | Out-Null+ Set-Content -LiteralPath "$sdk\Include\vulkan\vulkan.h" -Value '// test fixture'+ foreach ($entry in $Libraries.GetEnumerator()) {+ New-Item -ItemType Directory -Path "$sdk\$($entry.Key)" -Force | Out-Null+ Copy-Item -LiteralPath $entry.Value -Destination "$sdk\$($entry.Key)\vulkan-1.lib"+ }+ $githubEnv = Join-Path $sdk 'github.env'+ $githubPath = Join-Path $sdk 'github.path'+ $oldLib = $env:LIB+ $env:LIB = 'C:\preserved-lib'+ $env:GITHUB_ENV = $githubEnv+ $env:GITHUB_PATH = $githubPath+ try {+ & $script -Architecture $Architecture -InstallSdk -SdkDirectory $sdk 2>&1 | Out-Null+ if ($ExpectedError) { throw "$Name unexpectedly succeeded" }+ $expected = "LIB=$sdk\$ExpectedDirectory;C:\preserved-lib"+ if ((Get-Content -LiteralPath $githubEnv) -notcontains $expected) {+ throw "$Name did not export expected LIB value: $expected"+ }+ } catch {+ if (-not $ExpectedError -or $_.Exception.Message -notmatch $ExpectedError) { throw }+ } finally {+ $env:LIB = $oldLib+ }+ Write-Host "PASS $Name"+ }++ Invoke-Case native-arm arm64 @{ Lib = $armLibrary } Lib+ Invoke-Case cross-arm arm64 @{ Lib = $x64Library; 'Lib-ARM64' = $armLibrary } 'Lib-ARM64'+ Invoke-Case native-x64 x64 @{ Lib = $x64Library } Lib+ Invoke-Case wrong-arm arm64 @{ Lib = $x64Library } '' 'wrong-architecture'+ Invoke-Case missing-arm arm64 @{} '' 'import library missing'+} finally {+ if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force }+}