fix(claude): добавлена поддержка пакетного приложения
- Зачем: - Claude Proxy не запускался при установке Claude из Microsoft Store. - Что: - сохранён прежний запуск обычного claude.exe. - добавлена активация пакетного приложения по AUMID с параметрами прокси. - генератор ярлыка получил поддержку значка из пакета Claude. - Проверка: - обе ветки запуска завершились с кодом 0. - сетевой процесс Claude подключился к 127.0.0.1:12334.
This commit is contained in:
1 parent
559c1caf75
commit
0e283daad8
3 files changed
+154
-17
No files matched your search
@@ -109,10 +109,12 @@ Linux/Bash-интерфейс `proxy-client` поддерживает внешн
|
|||||||
приложение через системный идентификатор и передаёт ему параметры Chromium
|
приложение через системный идентификатор и передаёт ему параметры Chromium
|
||||||
`--proxy-server` и `--proxy-bypass-list`.
|
`--proxy-server` и `--proxy-bypass-list`.
|
||||||
|
|
||||||
`Claude Proxy` передаёт переменные прокси и параметры Electron
|
`Claude Proxy` поддерживает как обычную установку в
|
||||||
`--proxy-server` и `--proxy-bypass-list`, чтобы прокси применялся ко всему
|
`%LOCALAPPDATA%\AnthropicClaude`, так и пакет из Microsoft Store. В обоих
|
||||||
трафику Claude Desktop. Если Claude уже запущен обычным способом, его нужно
|
случаях он передаёт параметры Electron `--proxy-server` и
|
||||||
полностью закрыть перед запуском через `Claude Proxy`.
|
`--proxy-bypass-list`, чтобы прокси применялся ко всему трафику Claude Desktop.
|
||||||
|
Если Claude уже запущен обычным способом, его нужно полностью закрыть перед
|
||||||
|
запуском через `Claude Proxy`.
|
||||||
|
|
||||||
### Git baseline
|
### Git baseline
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,40 @@ if (Test-Path -LiteralPath $PwshAliasPath) {
|
|||||||
|
|
||||||
$Arguments = "-NoLogo -NoProfile -ExecutionPolicy Bypass -File `"$LauncherPath`""
|
$Arguments = "-NoLogo -NoProfile -ExecutionPolicy Bypass -File `"$LauncherPath`""
|
||||||
$WorkingDirectory = $env:USERPROFILE
|
$WorkingDirectory = $env:USERPROFILE
|
||||||
$ClaudeExecutable = Join-Path $env:LOCALAPPDATA 'AnthropicClaude\claude.exe'
|
|
||||||
if (Test-Path -LiteralPath $ClaudeExecutable) {
|
function Get-ClaudeIconExecutable {
|
||||||
|
$LegacyExecutable = Join-Path $env:LOCALAPPDATA 'AnthropicClaude\claude.exe'
|
||||||
|
if (Test-Path -LiteralPath $LegacyExecutable) {
|
||||||
|
return $LegacyExecutable
|
||||||
|
}
|
||||||
|
|
||||||
|
$Package = Get-AppxPackage -Name 'Claude' -ErrorAction SilentlyContinue |
|
||||||
|
Select-Object -First 1
|
||||||
|
if ($null -eq $Package) {
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$Manifest = Get-AppxPackageManifest $Package
|
||||||
|
$Application = @($Manifest.Package.Applications.Application) | Select-Object -First 1
|
||||||
|
if ($null -eq $Application -or [string]::IsNullOrWhiteSpace($Application.Executable)) {
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
$Executable = Join-Path $Package.InstallLocation ([string]$Application.Executable)
|
||||||
|
if (Test-Path -LiteralPath $Executable) {
|
||||||
|
return $Executable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
$ClaudeExecutable = Get-ClaudeIconExecutable
|
||||||
|
if ($null -ne $ClaudeExecutable) {
|
||||||
$IconLocation = "$ClaudeExecutable,0"
|
$IconLocation = "$ClaudeExecutable,0"
|
||||||
} else {
|
} else {
|
||||||
$IconLocation = "$TargetPath,0"
|
$IconLocation = "$TargetPath,0"
|
||||||
|
|||||||
@@ -49,22 +49,125 @@ function Add-WslEnvEntries {
|
|||||||
$env:WSLENV = [string]::Join(':', $Entries)
|
$env:WSLENV = [string]::Join(':', $Entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-ClaudeExecutable {
|
function Get-ClaudeApplication {
|
||||||
$Executable = Join-Path $env:LOCALAPPDATA 'AnthropicClaude\claude.exe'
|
$LegacyExecutable = Join-Path $env:LOCALAPPDATA 'AnthropicClaude\claude.exe'
|
||||||
if (-not (Test-Path -LiteralPath $Executable)) {
|
if (Test-Path -LiteralPath $LegacyExecutable) {
|
||||||
throw "Claude Desktop executable was not found: $Executable"
|
return [PSCustomObject]@{
|
||||||
|
Mode = 'Legacy'
|
||||||
|
Executable = $LegacyExecutable
|
||||||
|
AppUserModelId = $null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $Executable
|
$Package = Get-AppxPackage -Name 'Claude' -ErrorAction SilentlyContinue |
|
||||||
|
Select-Object -First 1
|
||||||
|
|
||||||
|
if ($null -eq $Package) {
|
||||||
|
throw "Claude Desktop не найден: проверены файл '$LegacyExecutable' и пакет 'Claude'."
|
||||||
|
}
|
||||||
|
|
||||||
|
$Manifest = Get-AppxPackageManifest $Package
|
||||||
|
$Application = @($Manifest.Package.Applications.Application) | Select-Object -First 1
|
||||||
|
if ($null -eq $Application -or [string]::IsNullOrWhiteSpace($Application.Executable)) {
|
||||||
|
throw "Манифест пакета Claude не содержит исполняемого файла."
|
||||||
|
}
|
||||||
|
|
||||||
|
$Executable = Join-Path $Package.InstallLocation ([string]$Application.Executable)
|
||||||
|
if (-not (Test-Path -LiteralPath $Executable)) {
|
||||||
|
throw "Исполняемый файл пакета Claude не найден: $Executable"
|
||||||
|
}
|
||||||
|
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
Mode = 'Packaged'
|
||||||
|
Executable = $Executable
|
||||||
|
AppUserModelId = "$($Package.PackageFamilyName)!$([string]$Application.Id)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Start-ClaudePackagedApplication {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$AppUserModelId,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not ('ClaudeProxyLauncher.ApplicationActivationManager' -as [type])) {
|
||||||
|
Add-Type -TypeDefinition @'
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace ClaudeProxyLauncher
|
||||||
|
{
|
||||||
|
[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][ClaudeProxyLauncher.ApplicationActivator]::Activate(
|
||||||
|
$AppUserModelId,
|
||||||
|
$Arguments
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Set-ProxyEnvironment
|
Set-ProxyEnvironment
|
||||||
Add-WslEnvEntries
|
Add-WslEnvEntries
|
||||||
|
|
||||||
$ClaudeExecutable = Get-ClaudeExecutable
|
$ClaudeApplication = Get-ClaudeApplication
|
||||||
$ClaudeArguments = @(
|
$ProxyServerArgument = "--proxy-server=${HttpProxy}"
|
||||||
"--proxy-server=${HttpProxy}",
|
$ProxyBypassArgument = "--proxy-bypass-list=${ProxyBypassList}"
|
||||||
"--proxy-bypass-list=${ProxyBypassList}"
|
|
||||||
)
|
|
||||||
|
|
||||||
Start-Process -FilePath $ClaudeExecutable -ArgumentList $ClaudeArguments
|
if ($ClaudeApplication.Mode -eq 'Legacy') {
|
||||||
|
Start-Process -FilePath $ClaudeApplication.Executable -ArgumentList @(
|
||||||
|
$ProxyServerArgument,
|
||||||
|
$ProxyBypassArgument
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
$ClaudeArguments = "${ProxyServerArgument} ${ProxyBypassArgument}"
|
||||||
|
Start-ClaudePackagedApplication `
|
||||||
|
-AppUserModelId $ClaudeApplication.AppUserModelId `
|
||||||
|
-Arguments $ClaudeArguments
|
||||||
|
}
|
||||||
Reference in new issue
Block a user