# Mozart Email installer (Windows PowerShell) - https://mozartemail.com - key + skill, nothing else. $ErrorActionPreference = "Stop" try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch {} $B = if ($env:MOZART_BASE) { $env:MOZART_BASE } else { "https://mozartemail.com" } $D = Join-Path $HOME ".mozart"; $F = Join-Path $D "key" $Agent = if ($env:CLAUDECODE) { "claude-code" } elseif ($env:CODEX_SANDBOX -or $env:CODEX_SANDBOX_NETWORK_DISABLED) { "codex" } elseif ($env:CURSOR_TRACE_ID) { "cursor" } else { "install-windows" } New-Item -ItemType Directory -Force -Path $D | Out-Null $Key = $env:MOZART_KEY if ($Key) { [IO.File]::WriteAllText($F, $Key.Trim()) } elseif (-not (Test-Path $F) -or ((Get-Item $F).Length -eq 0)) { try { $k = Invoke-RestMethod -Method Post -Uri "$B/api/agent/key" -Body @{ agent = $Agent } [IO.File]::WriteAllText($F, ([string]$k).Trim()) } catch { Write-Output "MOZART_ERROR could not get a free key: network blocked, or free keys sold out for today. Create a free account (also 50 credits) at $B/signup and use the sentence from its Commands screen." exit 1 } } $Key = ([IO.File]::ReadAllText($F)).Trim() try { $Skill = [string](Invoke-RestMethod -Uri "$B/skill.md"); $SkillMcp = [string](Invoke-RestMethod -Uri "$B/skill-mcp.md") } catch { Write-Output "MOZART_ERROR could not download the skill ($B/skill.md)"; exit 1 } $Installed = @() foreach ($Tool in @(".claude", ".codex", ".cursor")) { $P = Join-Path $HOME $Tool if (Test-Path $P) { $S = Join-Path (Join-Path $P "skills") "mozart-email" New-Item -ItemType Directory -Force -Path $S | Out-Null [IO.File]::WriteAllText((Join-Path $S "SKILL.md"), $(if ($Tool -eq ".codex") { $SkillMcp } else { $Skill })) $Installed += $Tool.TrimStart(".") } } $C = Join-Path (Join-Path $HOME ".codex") "config.toml" if ((Test-Path (Join-Path $HOME ".codex")) -and -not ((Test-Path $C) -and (Select-String -Path $C -Pattern "mcp_servers.mozart-email" -Quiet))) { Add-Content -Path $C -Value "" Add-Content -Path $C -Value "[mcp_servers.mozart-email]" Add-Content -Path $C -Value ('url = "' + $B + '/api/mcp?key=' + $Key + '"') } $Bal = "?" try { $St = Invoke-RestMethod -Uri "$B/api/agent/status" -Headers @{ Authorization = "Bearer $Key" }; if ($St.balance -ne $null) { $Bal = $St.balance } } catch {} $List = if ($Installed.Count -gt 0) { $Installed -join "," } else { "none (no .claude, .codex or .cursor folder found)" } Write-Output "MOZART_READY credits=$Bal key=~/.mozart/key skill_installed_for: $List" Write-Output "AGENT: done, do not re-check. Read $B/agent.txt for the tools, then answer the user in their language: one line saying Mozart Email is ready with the credits left, the tools as a short list (one line each), then ask what they want to do with their credits."