Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
144 lines (124 loc) · 5.56 KB
/
Copy pathinstall.ps1
File metadata and controls
144 lines (124 loc) · 5.56 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# AiNxt OS prebuilt installer for Windows PowerShell 5.1+ / PowerShell 7+.
# Usage:
# irm https://raw.githubusercontent.com/npci/ainxt-os/main/install.ps1 | iex
# & ([scriptblock]::Create((irm https://raw.githubusercontent.com/npci/ainxt-os/main/install.ps1))) 0.2.0
[CmdletBinding()]
param(
[string]$Version = "latest"
)
$ErrorActionPreference = "Stop"
$Repo = "npci/ainxt-os"
$InstallRoot = if ($env:AINXT_HOME) { $env:AINXT_HOME } else { Join-Path $HOME ".ainxt-os" }
$BinDir = Join-Path $InstallRoot "bin"
$Config = Join-Path $InstallRoot "runtimed.toml"
function Fail([string]$Message) {
throw "ainxt-os installer: $Message"
}
try {
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()
switch ($arch) {
"X64" { $ArchName = "x86_64" }
"Arm64" { $ArchName = "arm64" }
default { Fail "unsupported architecture: $arch. Supported architectures are x86_64 and arm64." }
}
if ($Version -eq "latest") {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers @{ Accept = "application/vnd.github+json" }
$Version = [string]$release.tag_name
if ([string]::IsNullOrWhiteSpace($Version)) { Fail "could not determine the latest release from GitHub." }
}
if (-not $Version.StartsWith("v")) { $Version = "v$Version" }
$asset = "ainxt-os-windows-$ArchName.zip"
$url = "https://github.com/$Repo/releases/download/$Version/$asset"
$temp = Join-Path ([System.IO.Path]::GetTempPath()) ("ainxt-os-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $temp | Out-Null
try {
Write-Host "ainxt-os installer: installing $Version for Windows/$ArchName"
New-Item -ItemType Directory -Force -Path $BinDir | Out-Null
$archive = Join-Path $temp $asset
Invoke-WebRequest -Uri $url -OutFile $archive -UseBasicParsing
Expand-Archive -Path $archive -DestinationPath $temp -Force
$console = Get-ChildItem -Path $temp -Recurse -File -Filter "ainxt-os.exe" | Select-Object -First 1
$runtime = Get-ChildItem -Path $temp -Recurse -File -Filter "ainxt-runtimed.exe" | Select-Object -First 1
if (-not $console) { Fail "release archive does not contain ainxt-os.exe" }
if (-not $runtime) { Fail "release archive does not contain ainxt-runtimed.exe" }
Copy-Item $console.FullName (Join-Path $BinDir "ainxt-os.bin.exe") -Force
Copy-Item $runtime.FullName (Join-Path $BinDir "ainxt-runtimed.exe") -Force
if (-not (Test-Path $Config)) {
@'
# Generated by the AiNxt OS installer. Edit in Console Settings or this file.
version = 1
[server]
host = "127.0.0.1"
port = 8080
event_log_dir = "logs"
chat_sessions_dir = "sessions"
[session]
max_sessions = 4096
inbox_capacity = 8
idle_ttl_ms = 300000
turn_timeout_ms = 300000
[limits]
max_agent_iters = 4
[guardrails]
jailbreak = "audit"
groundedness = "audit"
toxicity = "audit"
system_prompt_leak = "audit"
citation = "audit"
[injection]
mode = "enforce"
[[models.providers]]
id = "local"
kind = "local"
base_url = ""
eligible = ["public", "internal", "confidential", "regulated-payment"]
'@ | Set-Content -Path $Config -Encoding UTF8
Write-Host "ainxt-os installer: created $Config (offline/local default; no API key required)"
} else {
Write-Host "ainxt-os installer: keeping existing $Config"
}
# PowerShell launcher. It passes an absolute config path so the installed Console works
# regardless of the caller's current directory. The .cmd launcher gives cmd.exe the same
# behaviour. The real Rust executable remains beside ainxt-runtimed for daemon discovery.
@"
`$ErrorActionPreference = 'Stop'
`$root = Split-Path -Parent (Split-Path -Parent `$MyInvocation.MyCommand.Path)
& (Join-Path `$root 'bin\ainxt-os.bin.exe') --config (Join-Path `$root 'runtimed.toml') `$args
exit `$LASTEXITCODE
"@ | Set-Content -Path (Join-Path $BinDir "ainxt-os.ps1") -Encoding UTF8
@"
@echo off
set "ROOT=%~dp0.."
"%ROOT%\bin\ainxt-os.bin.exe" --config "%ROOT%\runtimed.toml" %*
exit /b %ERRORLEVEL%
"@ | Set-Content -Path (Join-Path $BinDir "ainxt-os.cmd") -Encoding ASCII
# Prefer the launcher when invoked as `ainxt-os` in PowerShell. PowerShell resolves .ps1
# only when script execution policy permits it; the installer therefore also adds the
# directory to the user's PATH and provides the .cmd fallback for cmd.exe.
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$parts = @()
if ($userPath) { $parts = $userPath -split ';' | Where-Object { $_ -ne '' } }
if ($parts -notcontains $BinDir) {
[Environment]::SetEnvironmentVariable("Path", (($parts + $BinDir) -join ';'), "User")
$env:Path = "$BinDir;$env:Path"
Write-Host "ainxt-os installer: added $BinDir to the user PATH."
}
Write-Host ""
Write-Host "AiNxt OS $Version installed."
Write-Host " Install directory: $InstallRoot"
Write-Host " Console launcher: $BinDir\ainxt-os.ps1 / $BinDir\ainxt-os.cmd"
Write-Host " Runtime binary: $BinDir\ainxt-runtimed.exe"
Write-Host " Config: $Config"
Write-Host ""
Write-Host "Start it with: ainxt-os"
Write-Host "Then open: http://127.0.0.1:8081"
Write-Host "The first reply is expected to be: offline mode: no model configured."
Write-Host ""
}
finally {
if (Test-Path $temp) { Remove-Item -Recurse -Force $temp }
}
}
catch {
Fail $_.Exception.Message
}