@muthuishere/aos 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/install.cmd CHANGED
@@ -1,144 +1,200 @@
1
- @echo off
2
- rem Install aos on Windows from a GitHub release, a local folder, a mirror URL,
3
- rem or a single aos.exe. No Go toolchain, no administrator.
4
- rem
5
- rem curl -fsSL -o install.cmd https://raw.githubusercontent.com/muthuishere/aos/main/install.cmd && install.cmd
6
- rem install.cmd /version v0.6.0
7
- rem install.cmd /from C:\path\to\release-folder (goreleaser archives + checksums.txt)
8
- rem install.cmd /from https://mirror.example/aos/v0.6.0/
9
- rem install.cmd /from .\aos_0.5.0_windows_arm64.zip (one release archive: unpacked)
10
- rem install.cmd /from .\aos.exe (copied in as-is)
11
- rem install.cmd /dir %USERPROFILE%\bin
12
- rem
13
- rem --from / --version / --dir work too. Environment equivalents: AOS_FROM,
14
- rem AOS_VERSION, AOS_INSTALL_DIR. Default dir: %LOCALAPPDATA%\Programs\aos,
15
- rem added to your user PATH (/no-path or AOS_NO_PATH=1 leaves PATH alone).
16
- rem
17
- rem A .cmd rather than a .ps1 on purpose: PowerShell's execution policy blocks
18
- rem unsigned script FILES by default, but not -Command, so the PowerShell below
19
- rem is read out of this file and run that way.
20
- setlocal
21
- set "AOS_INSTALL_ARGS=%*"
22
- set "AOS_INSTALL_SELF=%~f0"
23
- powershell -NoProfile -ExecutionPolicy Bypass -Command "$s = Get-Content -Raw -LiteralPath $env:AOS_INSTALL_SELF; $m = '#' + '#AOS-POWERSHELL##'; Invoke-Expression ($s.Substring($s.IndexOf($m) + $m.Length))"
24
- exit /b %ERRORLEVEL%
25
-
26
- ##AOS-POWERSHELL##
27
- $ErrorActionPreference = 'Stop'
28
- $ProgressPreference = 'SilentlyContinue'
29
- $repo = 'muthuishere/aos'
30
- $from = if ($env:AOS_FROM) { $env:AOS_FROM } else { $env:AOS_DOWNLOAD_BASE }
31
- $version = $env:AOS_VERSION
32
- $dir = if ($env:AOS_INSTALL_DIR) { $env:AOS_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\aos' }
33
- $noPath = [bool]$env:AOS_NO_PATH
34
-
35
- function Fail($msg) { [Console]::Error.WriteLine("install: $msg"); exit 1 }
36
-
37
- # Split the argument string the way cmd passed it, honouring quotes.
38
- $argv = @([regex]::Matches("$env:AOS_INSTALL_ARGS", '"([^"]*)"|(\S+)') | ForEach-Object {
39
- if ($_.Groups[1].Success) { $_.Groups[1].Value } else { $_.Groups[2].Value } })
40
- for ($i = 0; $i -lt $argv.Count; $i++) {
41
- $a = $argv[$i]
42
- $name = $a -replace '^(--|/)', ''
43
- $val = $null
44
- if ($name -match '^(\w+)[=:](.*)$') { $name = $Matches[1]; $val = $Matches[2] }
45
- if ($name -in @('from', 'version', 'dir')) {
46
- if ($null -eq $val) { $i++; if ($i -ge $argv.Count) { Fail "$a needs a value" }; $val = $argv[$i] }
47
- Set-Variable -Name $name -Value $val
48
- } elseif ($name -eq 'no-path') {
49
- $noPath = $true
50
- } elseif ($name -in @('h', 'help', '?')) {
51
- Write-Host 'install.cmd [/from <folder|url|aos.exe>] [/version vX.Y.Z] [/dir <path>] [/no-path]'; exit 0
52
- } else { Fail "unknown argument: $a" }
53
- }
54
-
55
- $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'ARM64') { 'arm64' } else { 'amd64' }
56
- $tmp = Join-Path ([IO.Path]::GetTempPath()) ('aos-install-' + [guid]::NewGuid())
57
- New-Item -ItemType Directory -Force -Path $tmp | Out-Null
58
- New-Item -ItemType Directory -Force -Path $dir | Out-Null
59
- $target = Join-Path $dir 'aos.exe'
60
-
61
- try {
62
- if ($from -and (Test-Path -LiteralPath $from -PathType Leaf) -and $from -like '*.zip') {
63
- Write-Host "==> Installing from the archive $from"
64
- $tmpa = Join-Path ([IO.Path]::GetTempPath()) ("aos-" + [guid]::NewGuid())
65
- Expand-Archive -LiteralPath $from -DestinationPath $tmpa -Force
66
- $exe = Join-Path $tmpa 'aos.exe'
67
- if (-not (Test-Path -LiteralPath $exe)) { Fail "$from does not contain aos.exe" }
68
- Copy-Item -LiteralPath $exe -Destination $target -Force
69
- Remove-Item -Recurse -Force $tmpa
70
- } elseif ($from -and (Test-Path -LiteralPath $from -PathType Leaf)) {
71
- Write-Host "==> Installing the executable $from"
72
- Copy-Item -LiteralPath $from -Destination $target -Force
73
- } else {
74
- $isUrl = $false
75
- if (-not $from) {
76
- if (-not $version) {
77
- $version = (Invoke-RestMethod -UseBasicParsing "https://api.github.com/repos/$repo/releases/latest").tag_name
78
- if (-not $version) { Fail "could not resolve the latest release of $repo" }
79
- }
80
- if ($version -notmatch '^v') { $version = "v$version" }
81
- $base = "https://github.com/$repo/releases/download/$version"; $isUrl = $true
82
- } else {
83
- $base = $from.TrimEnd('/', '\')
84
- $isUrl = $base -match '^https?://'
85
- if (-not $isUrl -and -not (Test-Path -LiteralPath $base -PathType Container)) {
86
- Fail "/from $from is not a folder, an executable, or an http(s) URL"
87
- }
88
- }
89
- Write-Host "==> Installing aos for windows/$arch from $base"
90
-
91
- function Fetch($name, $dest) {
92
- try {
93
- if ($isUrl) { Invoke-WebRequest -UseBasicParsing -Uri "$base/$name" -OutFile $dest }
94
- else { Copy-Item -LiteralPath (Join-Path $base $name) -Destination $dest -ErrorAction Stop }
95
- return $true
96
- } catch { return $false }
97
- }
98
-
99
- $sumsFile = Join-Path $tmp 'checksums.txt'
100
- $sums = @{}
101
- if (Fetch 'checksums.txt' $sumsFile) {
102
- Get-Content $sumsFile | ForEach-Object { $p = $_ -split '\s+', 2; if ($p.Count -eq 2) { $sums[$p[1].Trim()] = $p[0] } }
103
- }
104
- $pattern = "^aos_.*_windows_$arch\.zip$"
105
- $archive = $null
106
- if ($sums.Count -gt 0) {
107
- $names = @($sums.Keys | Where-Object { $_ -match $pattern })
108
- if ($version) { $names = @($names | Where-Object { $_ -like "*_$($version.TrimStart('v'))_*" }) }
109
- $archive = $names | Select-Object -First 1
110
- } elseif ($version) {
111
- $archive = "aos_$($version.TrimStart('v'))_windows_$arch.zip"
112
- } elseif (-not $isUrl) {
113
- $archive = Get-ChildItem -LiteralPath $base -File | Where-Object { $_.Name -match $pattern } | Select-Object -First 1 -ExpandProperty Name
114
- } else { Fail "$base has no checksums.txt to find the archive by; pass /version" }
115
- if (-not $archive) { Fail "no aos archive for windows/$arch at $base" }
116
-
117
- $zip = Join-Path $tmp $archive
118
- if (-not (Fetch $archive $zip)) { Fail "download failed: $base/$archive" }
119
- if ($sums.Count -gt 0) {
120
- $got = (Get-FileHash -Algorithm SHA256 -LiteralPath $zip).Hash.ToLower()
121
- if ($sums[$archive] -ne $got) { Fail "checksum mismatch for $archive -- refusing to install" }
122
- Write-Host ' sha256 verified'
123
- } else {
124
- Write-Warning "$base has no checksums.txt -- installing $archive WITHOUT verifying it"
125
- }
126
- Expand-Archive -LiteralPath $zip -DestinationPath (Join-Path $tmp 'x') -Force
127
- $exe = Join-Path $tmp 'x\aos.exe'
128
- if (-not (Test-Path -LiteralPath $exe)) { Fail "$archive does not contain aos.exe" }
129
- Copy-Item -LiteralPath $exe -Destination $target -Force
130
- }
131
- } finally {
132
- if ($tmp -and (Test-Path -LiteralPath $tmp)) { Remove-Item -LiteralPath $tmp -Recurse -Force }
133
- }
134
-
135
- Write-Host " $target"
136
- $userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
137
- if (-not $noPath -and -not (($userPath -split ';') -contains $dir)) {
138
- [Environment]::SetEnvironmentVariable('Path', ($(if ($userPath) { "$userPath;$dir" } else { $dir })), 'User')
139
- Write-Host " added $dir to your user PATH (open a new terminal to pick it up)"
140
- }
141
- $env:Path = "$dir;$env:Path"
142
- # Running it once also installs the bundled agent skill.
143
- & $target --version
144
- exit $LASTEXITCODE
1
+ @echo off
2
+ rem Install aos on Windows from a GitHub release, a local folder, a mirror URL,
3
+ rem or a single aos.exe. No Go toolchain, no administrator.
4
+ rem
5
+ rem curl -fsSL -o install.cmd https://raw.githubusercontent.com/muthuishere/aos/main/install.cmd && install.cmd
6
+ rem install.cmd /version v0.6.0
7
+ rem install.cmd /from C:\path\to\release-folder (goreleaser archives + checksums.txt)
8
+ rem install.cmd /from https://mirror.example/aos/v0.6.0/
9
+ rem install.cmd /from .\aos_0.5.0_windows_arm64.zip (one release archive: unpacked)
10
+ rem install.cmd /from .\aos.exe (copied in as-is)
11
+ rem install.cmd /dir %USERPROFILE%\bin
12
+ rem
13
+ rem --from / --version / --dir work too. Environment equivalents: AOS_FROM,
14
+ rem AOS_VERSION, AOS_INSTALL_DIR. Default dir: %LOCALAPPDATA%\Programs\aos,
15
+ rem added to your user PATH (/no-path or AOS_NO_PATH=1 leaves PATH alone).
16
+ rem
17
+ rem Plain cmd.exe only (no PowerShell): curl.exe, tar.exe and certutil ship
18
+ rem with Windows 10 1803+ and Windows 11.
19
+ setlocal EnableExtensions DisableDelayedExpansion
20
+
21
+ set "REPO=muthuishere/aos"
22
+ set "FROM=%AOS_FROM%"
23
+ if not defined FROM set "FROM=%AOS_DOWNLOAD_BASE%"
24
+ set "VERSION=%AOS_VERSION%"
25
+ set "DIR=%AOS_INSTALL_DIR%"
26
+ if not defined DIR set "DIR=%LOCALAPPDATA%\Programs\aos"
27
+ set "NOPATH=%AOS_NO_PATH%"
28
+
29
+ rem ---- arguments ("/from=X" arrives as two words: cmd splits on '=') ----
30
+ :args
31
+ if "%~1"=="" goto args_done
32
+ set "A=%~1"
33
+ if /i "%A%"=="/from" (set "FROM=%~2" & shift & shift & goto args)
34
+ if /i "%A%"=="--from" (set "FROM=%~2" & shift & shift & goto args)
35
+ if /i "%A%"=="/version" (set "VERSION=%~2" & shift & shift & goto args)
36
+ if /i "%A%"=="--version" (set "VERSION=%~2" & shift & shift & goto args)
37
+ if /i "%A%"=="/dir" (set "DIR=%~2" & shift & shift & goto args)
38
+ if /i "%A%"=="--dir" (set "DIR=%~2" & shift & shift & goto args)
39
+ if /i "%A%"=="/no-path" (set "NOPATH=1" & shift & goto args)
40
+ if /i "%A%"=="--no-path" (set "NOPATH=1" & shift & goto args)
41
+ if /i "%A%"=="/?" goto usage
42
+ if /i "%A%"=="/h" goto usage
43
+ if /i "%A%"=="--help" goto usage
44
+ call :fail "unknown argument: %A%"
45
+ exit /b 1
46
+ :usage
47
+ echo install.cmd [/from ^<folder^|url^|aos.exe^|archive.zip^>] [/version vX.Y.Z] [/dir ^<path^>] [/no-path]
48
+ exit /b 0
49
+ :args_done
50
+
51
+ for %%T in (curl.exe tar.exe certutil.exe) do (
52
+ where %%T >nul 2>nul || (call :fail "%%T is missing; it ships with Windows 10 1803+ and Windows 11" & exit /b 1)
53
+ )
54
+
55
+ set "ARCH=amd64"
56
+ if /i "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "ARCH=arm64"
57
+ if /i "%PROCESSOR_ARCHITEW6432%"=="ARM64" set "ARCH=arm64"
58
+
59
+ set "TMPD=%TEMP%\aos-install-%RANDOM%%RANDOM%"
60
+ mkdir "%TMPD%" >nul 2>nul
61
+ if not exist "%DIR%" mkdir "%DIR%"
62
+ if not exist "%DIR%" (call :fail "could not create %DIR%" & goto cleanup_fail)
63
+ set "TARGET=%DIR%\aos.exe"
64
+
65
+ rem ---- a single local file: an archive or the executable ----
66
+ if defined FROM if exist "%FROM%" if not exist "%FROM%\*" goto from_file
67
+ goto from_release
68
+
69
+ :from_file
70
+ for %%F in ("%FROM%") do set "FEXT=%%~xF"
71
+ if /i "%FEXT%"==".zip" (
72
+ echo ==^> Installing from the archive %FROM%
73
+ mkdir "%TMPD%\x" >nul 2>nul
74
+ tar -xf "%FROM%" -C "%TMPD%\x" || (call :fail "could not unpack %FROM%" & goto cleanup_fail)
75
+ if not exist "%TMPD%\x\aos.exe" (call :fail "%FROM% does not contain aos.exe" & goto cleanup_fail)
76
+ copy /y "%TMPD%\x\aos.exe" "%TARGET%" >nul || (call :fail "could not write %TARGET%" & goto cleanup_fail)
77
+ ) else (
78
+ echo ==^> Installing the executable %FROM%
79
+ copy /y "%FROM%" "%TARGET%" >nul || (call :fail "could not write %TARGET%" & goto cleanup_fail)
80
+ )
81
+ goto installed
82
+
83
+ rem ---- a release: GitHub, a mirror URL or a local folder ----
84
+ :from_release
85
+ set "ISURL=0"
86
+ if defined FROM goto have_base
87
+ if not defined VERSION (
88
+ for /f "delims=" %%U in ('curl -fsSL -o nul -w "%%{url_effective}" "https://github.com/%REPO%/releases/latest"') do set "LATEST=%%U"
89
+ )
90
+ if not defined VERSION (
91
+ if not defined LATEST (call :fail "could not resolve the latest release of %REPO%" & goto cleanup_fail)
92
+ for %%V in ("%LATEST:/=" "%") do set "VERSION=%%~V"
93
+ )
94
+ if not "%VERSION:~0,1%"=="v" set "VERSION=v%VERSION%"
95
+ set "BASE=https://github.com/%REPO%/releases/download/%VERSION%"
96
+ set "ISURL=1"
97
+ goto base_ready
98
+ :have_base
99
+ set "BASE=%FROM%"
100
+ if "%BASE:~-1%"=="/" set "BASE=%BASE:~0,-1%"
101
+ if "%BASE:~-1%"=="\" set "BASE=%BASE:~0,-1%"
102
+ if /i "%BASE:~0,7%"=="http://" set "ISURL=1"
103
+ if /i "%BASE:~0,8%"=="https://" set "ISURL=1"
104
+ if "%ISURL%"=="0" if not exist "%BASE%\*" (call :fail "/from %FROM% is not a folder, an executable, or an http(s) URL" & goto cleanup_fail)
105
+ :base_ready
106
+ echo ==^> Installing aos for windows/%ARCH% from %BASE%
107
+
108
+ set "VNUM="
109
+ if defined VERSION set "VNUM=%VERSION:v=%"
110
+ set "ARCHIVE="
111
+ set "SUMS=%TMPD%\checksums.txt"
112
+ call :fetch checksums.txt "%SUMS%"
113
+ if errorlevel 1 goto no_sums
114
+ for /f "usebackq tokens=1,2" %%a in ("%SUMS%") do call :pick "%%b"
115
+ if not defined ARCHIVE (call :fail "no aos archive for windows/%ARCH% at %BASE%" & goto cleanup_fail)
116
+ goto have_archive
117
+ :no_sums
118
+ del "%SUMS%" >nul 2>nul
119
+ if defined VNUM (
120
+ set "ARCHIVE=aos_%VNUM%_windows_%ARCH%.zip"
121
+ goto have_archive
122
+ )
123
+ if "%ISURL%"=="1" (call :fail "%BASE% has no checksums.txt to find the archive by; pass /version" & goto cleanup_fail)
124
+ for /f "delims=" %%n in ('dir /b /a-d "%BASE%\aos_*_windows_%ARCH%.zip" 2^>nul') do if not defined ARCHIVE set "ARCHIVE=%%n"
125
+ if not defined ARCHIVE (call :fail "no aos archive for windows/%ARCH% at %BASE%" & goto cleanup_fail)
126
+ :have_archive
127
+
128
+ set "ZIP=%TMPD%\%ARCHIVE%"
129
+ call :fetch "%ARCHIVE%" "%ZIP%"
130
+ if errorlevel 1 (call :fail "download failed: %BASE%/%ARCHIVE%" & goto cleanup_fail)
131
+ if exist "%SUMS%" (
132
+ call :verify
133
+ if errorlevel 1 goto cleanup_fail
134
+ echo sha256 verified
135
+ ) else (
136
+ echo WARNING: %BASE% has no checksums.txt -- installing %ARCHIVE% WITHOUT verifying it 1>&2
137
+ )
138
+ mkdir "%TMPD%\x" >nul 2>nul
139
+ tar -xf "%ZIP%" -C "%TMPD%\x" || (call :fail "could not unpack %ARCHIVE%" & goto cleanup_fail)
140
+ if not exist "%TMPD%\x\aos.exe" (call :fail "%ARCHIVE% does not contain aos.exe" & goto cleanup_fail)
141
+ copy /y "%TMPD%\x\aos.exe" "%TARGET%" >nul || (call :fail "could not write %TARGET%" & goto cleanup_fail)
142
+
143
+ :installed
144
+ rd /s /q "%TMPD%" >nul 2>nul
145
+ echo %TARGET%
146
+ if defined NOPATH goto run_once
147
+ set "UPATH="
148
+ for /f "skip=2 tokens=2,*" %%a in ('reg query HKCU\Environment /v Path 2^>nul') do set "UPATH=%%b"
149
+ echo ;%UPATH%; | find /i ";%DIR%;" >nul && goto run_once
150
+ if defined UPATH (set "NEWPATH=%UPATH%;%DIR%") else (set "NEWPATH=%DIR%")
151
+ rem reg, not setx: setx truncates PATH at 1024 characters.
152
+ reg add HKCU\Environment /v Path /t REG_EXPAND_SZ /d "%NEWPATH%" /f >nul || (call :fail "could not update your user PATH" & exit /b 1)
153
+ rem setx broadcasts the environment change so new terminals see the PATH.
154
+ setx AOS_INSTALLED 1 >nul 2>nul
155
+ reg delete HKCU\Environment /v AOS_INSTALLED /f >nul 2>nul
156
+ echo added %DIR% to your user PATH (open a new terminal to pick it up)
157
+ :run_once
158
+ rem Running it once also installs the bundled agent skill.
159
+ endlocal & set "PATH=%DIR%;%PATH%" & "%DIR%\aos.exe" --version
160
+ exit /b %ERRORLEVEL%
161
+
162
+ rem ---- helpers ----------------------------------------------------------------
163
+
164
+ :fetch
165
+ rem :fetch <name> <dest> -- download or copy one release file; errorlevel 1 on failure
166
+ if "%ISURL%"=="1" (
167
+ curl -fsSL -o "%~2" "%BASE%/%~1" 2>nul || exit /b 1
168
+ ) else (
169
+ copy /y "%BASE%\%~1" "%~2" >nul 2>nul || exit /b 1
170
+ )
171
+ exit /b 0
172
+
173
+ :pick
174
+ rem :pick <name> -- the first checksums entry that is this arch's archive (and version)
175
+ if defined ARCHIVE exit /b 0
176
+ set "N=%~1"
177
+ echo %N%| findstr /r /i /c:"^aos_.*_windows_%ARCH%\.zip$" >nul || exit /b 0
178
+ if defined VNUM (
179
+ echo %N%| find "_%VNUM%_" >nul || exit /b 0
180
+ )
181
+ set "ARCHIVE=%N%"
182
+ exit /b 0
183
+
184
+ :verify
185
+ set "WANT="
186
+ for /f "usebackq tokens=1,2" %%a in ("%SUMS%") do if /i "%%b"=="%ARCHIVE%" set "WANT=%%a"
187
+ set "GOT="
188
+ for /f "skip=1 delims=" %%h in ('certutil -hashfile "%ZIP%" SHA256') do if not defined GOT set "GOT=%%h"
189
+ if defined GOT set "GOT=%GOT: =%"
190
+ if not defined WANT (call :fail "%ARCHIVE% is not listed in checksums.txt -- refusing to install" & exit /b 1)
191
+ if /i not "%WANT%"=="%GOT%" (call :fail "checksum mismatch for %ARCHIVE% -- refusing to install" & exit /b 1)
192
+ exit /b 0
193
+
194
+ :fail
195
+ echo install: %~1 1>&2
196
+ exit /b 1
197
+
198
+ :cleanup_fail
199
+ if defined TMPD rd /s /q "%TMPD%" >nul 2>nul
200
+ exit /b 1
package/install.sh CHANGED
@@ -184,7 +184,8 @@ install_windows_host() {
184
184
  if command -v unzip >/dev/null 2>&1; then
185
185
  unzip -oq "$tmp/$zip" -d "$tmp/w"
186
186
  else
187
- powershell.exe -NoProfile -Command "Expand-Archive -Force -LiteralPath '$(wslpath -w "$tmp/$zip")' -DestinationPath '$(wslpath -w "$tmp/w")'" >/dev/null
187
+ # Windows' own tar.exe reads zip archives (no PowerShell).
188
+ tar.exe -xf "$(wslpath -w "$tmp/$zip")" -C "$(wslpath -w "$tmp/w")" >/dev/null
188
189
  fi
189
190
  [ -f "$tmp/w/aos.exe" ] || die "$zip does not contain aos.exe"
190
191
  cp "$tmp/w/aos.exe" "$win_dir/aos.exe"
package/lib/install.js CHANGED
@@ -35,7 +35,7 @@ function install() {
35
35
  });
36
36
  // 0.0.0 is the unpublished in-repo version: take the latest release.
37
37
  if (version && version !== '0.0.0' && !env.AOS_VERSION) env.AOS_VERSION = 'v' + version;
38
- // npm's proxy config reaches scripts as npm_config_*; curl and PowerShell read
38
+ // npm's proxy config reaches scripts as npm_config_*; curl reads
39
39
  // the conventional variables.
40
40
  const proxy = env.npm_config_https_proxy || env.npm_config_proxy;
41
41
  if (proxy) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muthuishere/aos",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Hands for your AI agent: one CLI to drive macOS, Windows and Linux (windows, mouse, keyboard, screenshots, files, processes, services).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://muthuishere.github.io/aos/",