-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_codex_api.ps1
More file actions
52 lines (46 loc) · 2.12 KB
/
Copy pathsetup_codex_api.ps1
File metadata and controls
52 lines (46 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
param(
[string]$MsixPath,
[string]$Provider = "custom",
[string]$Model = "",
[string]$BaseUrl = "",
[ValidateSet("responses", "chat")][string]$WireApi = "responses",
[switch]$ApiKeyStdin,
[switch]$UseDeepSeekRelay,
[string]$DeepSeekBase = "",
[switch]$SkipApiConfiguration,
[switch]$ClearWebProfile,
[switch]$SkipInstall,
[switch]$KeepOriginalCodex
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
function Invoke-CheckedScript {
param([string]$Name, [string[]]$Arguments = @(), [string]$StdinText = "")
$script = Join-Path $root $Name
if (-not (Test-Path $script)) { throw "Missing helper script: $script" }
if ($StdinText) {
$StdinText | & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $script @Arguments
} else {
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $script @Arguments
}
if ($LASTEXITCODE -ne 0) { throw "$Name failed with exit code $LASTEXITCODE" }
}
$apiKey = if ($ApiKeyStdin) { [Console]::In.ReadToEnd().Trim() } else { "" }
if (-not $SkipInstall) {
if (-not $MsixPath) { throw "MsixPath is required unless SkipInstall is used." }
Invoke-CheckedScript "install_codex_msix.ps1" @($MsixPath)
}
if (-not $SkipApiConfiguration) {
if (-not $apiKey) { throw "API Key is required." }
if ($UseDeepSeekRelay) {
Invoke-CheckedScript "install_deepseek_relay.ps1" @("-ApiKeyStdin", "-DeepSeekModel", $Model, "-DeepSeekBase", $DeepSeekBase) $apiKey
$args = @("-ApiKeyStdin", "-Provider", $Provider, "-Model", $Model, "-BaseUrl", "http://127.0.0.1:8787", "-WireApi", "responses")
if ($ClearWebProfile) { $args += "-ClearWebProfile" }
Invoke-CheckedScript "prepare_codex_external_api.ps1" $args $apiKey
} else {
$args = @("-ApiKeyStdin", "-Provider", $Provider, "-Model", $Model, "-BaseUrl", $BaseUrl, "-WireApi", $WireApi)
if ($ClearWebProfile) { $args += "-ClearWebProfile" }
Invoke-CheckedScript "prepare_codex_external_api.ps1" $args $apiKey
}
}
Start-Process explorer.exe "shell:AppsFolder\OpenAI.Codex_2p2nqsd0c76g0!App"