Files
magpie/internal/agent/desktopapp_windows.go
T
尤贺雨 4697ff2324 agent: the Agents page shows the Windows Codex app's version, read from the Microsoft Store package registered for the user (#1334, laacmilan)
On Windows the Codex app is the Store package OpenAI.Codex
(C:\Program Files\WindowsApps\OpenAI.Codex_26.1002.7124.0_x64__2p2nqsd0c76g0
in the report), which magpie didn't read: only %LOCALAPPDATA%\Programs was
looked in. The version now comes from the package full names under the
current user's AppX repository key (HKCU\...\AppModel\Repository\Packages),
which needs no access to the protected WindowsApps folder and starts no
PowerShell. The newest OpenAI.Codex package with publisher id 2p2nqsd0c76g0
wins.

Test: TestCodexWindowsStoreAppVersion (picks the newest, skips a bad
version and another publisher, and a WSL twin shows none).

[Message rewritten at review to say what and why; the code is AwadYoo's. The
conflict with 2221b63f9 (macAppFolders) was resolved by keeping both.]
2026-10-13 05:48:39 +08:00

21 lines
660 B
Go

//go:build windows
package agent
import "golang.org/x/sys/windows/registry"
const appxPackagesKey = `Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages`
// installedWindowsStorePackages returns package full names registered for the
// current user. Reading this key needs no access to the protected WindowsApps
// folder and does not start PowerShell.
func installedWindowsStorePackages() []string {
key, err := registry.OpenKey(registry.CURRENT_USER, appxPackagesKey, registry.ENUMERATE_SUB_KEYS)
if err != nil {
return nil
}
defer key.Close()
names, _ := key.ReadSubKeyNames(-1)
return names
}