fix(codex): исправлен запуск через системный идентификатор

- Зачем:
  - обновлённое приложение запрещает прямой запуск ChatGPT.exe из WindowsApps.
- Что:
  - запуск переведён на активацию пакета по AUMID.
  - добавлены параметры Chromium для подключения к hproxy.local.
  - описание ярлыка обновлено в README.
- Проверка:
  - установленный скрипт завершился с кодом 0.
  - сетевой процесс Codex подключился к 127.0.0.1:12334.
This commit is contained in:
Dmitry Dementiev committed 2026-07-23 22:19:55 +03:00
1 parent 5286859533
commit 559c1caf75
2 files changed
+82 -6

No files matched your search

+78 -4
View File
@@ -5,6 +5,7 @@ $ProxyPort = 12334
$HttpProxy = "http://${ProxyHostName}:${ProxyPort}"
$SocksProxy = "socks5://${ProxyHostName}:${ProxyPort}"
$NoProxy = "${ProxyHostName},localhost,127.0.0.1,::1,[::1],.concept-software.ru"
$ProxyBypassList = "${ProxyHostName};localhost;127.0.0.1;[::1];*.concept-software.ru"
function Set-ProxyEnvironment {
$env:HTTP_PROXY = $HttpProxy
@@ -48,7 +49,7 @@ function Add-WslEnvEntries {
$env:WSLENV = [string]::Join(':', $Entries)
}
function Get-CodexExecutable {
function Get-CodexApplication {
$Package = Get-AppxPackage -Name 'OpenAI.Codex' -ErrorAction SilentlyContinue |
Select-Object -First 1
@@ -67,11 +68,84 @@ function Get-CodexExecutable {
throw "Codex Windows App executable was not found: $Executable"
}
return $Executable
[PSCustomObject]@{
AppUserModelId = "$($Package.PackageFamilyName)!$([string]$Application.Id)"
Executable = $Executable
}
}
function Start-CodexApplication {
param(
[Parameter(Mandatory)]
[string]$AppUserModelId,
[Parameter(Mandatory)]
[string]$Arguments
)
if (-not ('CodexProxyLauncher.ApplicationActivationManager' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
namespace CodexProxyLauncher
{
[Flags]
public enum ActivateOptions : uint
{
None = 0
}
[ComImport]
[Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IApplicationActivationManager
{
[PreserveSig]
int ActivateApplication(
[MarshalAs(UnmanagedType.LPWStr)] string appUserModelId,
[MarshalAs(UnmanagedType.LPWStr)] string arguments,
ActivateOptions options,
out uint processId);
}
[ComImport]
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
public class ApplicationActivationManager
{
}
public static class ApplicationActivator
{
public static uint Activate(string appUserModelId, string arguments)
{
IApplicationActivationManager manager =
(IApplicationActivationManager)new ApplicationActivationManager();
uint processId;
int hResult = manager.ActivateApplication(
appUserModelId,
arguments,
ActivateOptions.None,
out processId);
Marshal.ThrowExceptionForHR(hResult);
return processId;
}
}
}
'@
}
[void][CodexProxyLauncher.ApplicationActivator]::Activate(
$AppUserModelId,
$Arguments
)
}
Set-ProxyEnvironment
Add-WslEnvEntries
$CodexExecutable = Get-CodexExecutable
Start-Process -FilePath $CodexExecutable
$CodexApplication = Get-CodexApplication
$CodexArguments = "--proxy-server=${HttpProxy} --proxy-bypass-list=${ProxyBypassList}"
Start-CodexApplication -AppUserModelId $CodexApplication.AppUserModelId -Arguments $CodexArguments