@xenosystem/agent-cli 0.5.191 → 0.5.192
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/dist/cli.js +3 -3
- package/dist/index.js +2692 -2663
- package/dist/metafile-esm.json +1 -1
- package/dist/sdk-build-identity.json +12 -12
- package/native/xeno-pty/prebuilds/win32-x64/manifest.json +18 -18
- package/package.json +13 -6
- package/scripts/install-standalone.ps1 +326 -0
- package/scripts/install-standalone.sh +298 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# XENO Agent CLI — standalone installer
|
|
3
|
+
#
|
|
4
|
+
# curl -fsSL https://xenosystem.ai/install | sh
|
|
5
|
+
#
|
|
6
|
+
# Installs a self-contained `xeno` binary (embedded Node.js runtime + the audited
|
|
7
|
+
# native PTY addon). No Node.js, no npm, and no package registry are required on
|
|
8
|
+
# the target machine.
|
|
9
|
+
#
|
|
10
|
+
# ---------------------------------------------------------------------------
|
|
11
|
+
# TRUST MODEL — read before changing anything below.
|
|
12
|
+
#
|
|
13
|
+
# Piping a script into a shell makes XENO the trust anchor: there is no package
|
|
14
|
+
# manager review layer between this file and the user's machine. Therefore:
|
|
15
|
+
#
|
|
16
|
+
# 1. TLS to updates.xenostudio.ai authenticates the ORIGIN.
|
|
17
|
+
# 2. SHA256SUMS.txt (fetched from that same origin, per version) authenticates
|
|
18
|
+
# the ARTIFACT. It is also the release MANIFEST: an artifact absent from it
|
|
19
|
+
# is treated as "not published for this platform", never as "download and
|
|
20
|
+
# hope".
|
|
21
|
+
# 3. The checksum is verified BEFORE the archive is unpacked and BEFORE
|
|
22
|
+
# anything is made executable or moved into the install dir. A mismatch is
|
|
23
|
+
# a hard abort with a non-zero exit — never a warning.
|
|
24
|
+
#
|
|
25
|
+
# This is origin-trust, the same level rustup/uv ship with. It defends against a
|
|
26
|
+
# corrupted or truncated download and against a swapped object in the bucket; it
|
|
27
|
+
# does NOT defend against a compromise of the origin itself.
|
|
28
|
+
#
|
|
29
|
+
# >>> SIGNING PLUG-IN POINT <<<
|
|
30
|
+
# When code-signing certificates exist (see docs/INSTALL-SCRIPT.md §7), add a
|
|
31
|
+
# detached signature over SHA256SUMS.txt — `SHA256SUMS.txt.sig`, minisign/cosign
|
|
32
|
+
# or Ed25519, verified against a public key pinned in THIS file — and make that
|
|
33
|
+
# verification mandatory in `verify_checksum`. That upgrades the guarantee from
|
|
34
|
+
# "the origin served these bytes" to "XENO signed these bytes", which survives an
|
|
35
|
+
# origin compromise. The native PTY addon already ships an equivalent Ed25519
|
|
36
|
+
# manifest signature (native/xeno-pty/trusted-keys.json) — reuse that pattern.
|
|
37
|
+
# ---------------------------------------------------------------------------
|
|
38
|
+
#
|
|
39
|
+
# Environment overrides:
|
|
40
|
+
# XENO_VERSION Pin an exact version (e.g. 0.5.16). Default: latest stable
|
|
41
|
+
# from version.json.
|
|
42
|
+
# XENO_INSTALL_DIR Install directory. Default: $HOME/.local/bin
|
|
43
|
+
# XENO_BASE_URL Release root. Default: https://updates.xenostudio.ai/apps/agent-cli
|
|
44
|
+
# (used by CI and by local end-to-end tests)
|
|
45
|
+
#
|
|
46
|
+
# Exit codes: 0 ok · 1 usage/environment · 2 unsupported platform ·
|
|
47
|
+
# 3 download failure · 4 CHECKSUM MISMATCH · 5 install failure
|
|
48
|
+
|
|
49
|
+
set -eu
|
|
50
|
+
# pipefail is not in POSIX sh (dash lacks it). Enable it when the shell supports
|
|
51
|
+
# it; the script never relies on it — every fallible step is checked explicitly.
|
|
52
|
+
# shellcheck disable=SC3040
|
|
53
|
+
(set -o pipefail 2>/dev/null) && set -o pipefail || true
|
|
54
|
+
|
|
55
|
+
APP_SLUG="agent-cli"
|
|
56
|
+
BIN_NAME="xeno"
|
|
57
|
+
BASE_URL="${XENO_BASE_URL:-https://updates.xenostudio.ai/apps/${APP_SLUG}}"
|
|
58
|
+
INSTALL_DIR="${XENO_INSTALL_DIR:-${HOME}/.local/bin}"
|
|
59
|
+
|
|
60
|
+
TMPDIR_XENO=""
|
|
61
|
+
|
|
62
|
+
cleanup() {
|
|
63
|
+
[ -n "${TMPDIR_XENO}" ] && [ -d "${TMPDIR_XENO}" ] && rm -rf "${TMPDIR_XENO}"
|
|
64
|
+
return 0
|
|
65
|
+
}
|
|
66
|
+
trap cleanup EXIT INT TERM HUP
|
|
67
|
+
|
|
68
|
+
say() { printf '%s\n' "$*"; }
|
|
69
|
+
info() { printf ' %s\n' "$*"; }
|
|
70
|
+
die() { code="$1"; shift; printf '\nerror: %s\n' "$*" >&2; exit "${code}"; }
|
|
71
|
+
|
|
72
|
+
need_cmd() {
|
|
73
|
+
command -v "$1" >/dev/null 2>&1 || die 1 "required command not found: $1"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# --- download helpers -------------------------------------------------------
|
|
77
|
+
# One of curl/wget is required. `file://` is supported by both, which is what the
|
|
78
|
+
# offline end-to-end test uses.
|
|
79
|
+
DOWNLOADER=""
|
|
80
|
+
detect_downloader() {
|
|
81
|
+
if command -v curl >/dev/null 2>&1; then
|
|
82
|
+
DOWNLOADER="curl"
|
|
83
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
84
|
+
DOWNLOADER="wget"
|
|
85
|
+
else
|
|
86
|
+
die 1 "neither curl nor wget is available; cannot download the XENO CLI"
|
|
87
|
+
fi
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# fetch <url> <dest> — returns non-zero on any HTTP/transport error.
|
|
91
|
+
fetch() {
|
|
92
|
+
_url="$1"; _dest="$2"
|
|
93
|
+
case "${DOWNLOADER}" in
|
|
94
|
+
curl) curl -fsSL --proto '=https,file' --tlsv1.2 -o "${_dest}" "${_url}" 2>/dev/null ;;
|
|
95
|
+
wget) wget -q -O "${_dest}" "${_url}" 2>/dev/null ;;
|
|
96
|
+
esac
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# --- platform detection -----------------------------------------------------
|
|
100
|
+
# Fail loudly on anything not explicitly recognised. Installing "something close"
|
|
101
|
+
# is worse than not installing at all.
|
|
102
|
+
detect_target() {
|
|
103
|
+
_os="$(uname -s 2>/dev/null || echo unknown)"
|
|
104
|
+
_arch="$(uname -m 2>/dev/null || echo unknown)"
|
|
105
|
+
|
|
106
|
+
case "${_os}" in
|
|
107
|
+
Linux) _os_tag="linux" ;;
|
|
108
|
+
Darwin) _os_tag="macos" ;;
|
|
109
|
+
MINGW*|MSYS*|CYGWIN*|Windows_NT)
|
|
110
|
+
die 2 "Windows detected ($_os).
|
|
111
|
+
This script installs the POSIX build. On Windows use PowerShell:
|
|
112
|
+
|
|
113
|
+
irm https://xenosystem.ai/install.ps1 | iex
|
|
114
|
+
" ;;
|
|
115
|
+
*) die 2 "unsupported operating system: ${_os}
|
|
116
|
+
Supported: Linux, macOS. On Windows use install.ps1.
|
|
117
|
+
You can still install via npm: npm install -g @xenosystem/agent-cli" ;;
|
|
118
|
+
esac
|
|
119
|
+
|
|
120
|
+
case "${_arch}" in
|
|
121
|
+
x86_64|amd64) _arch_tag="x64" ;;
|
|
122
|
+
aarch64|arm64) _arch_tag="arm64" ;;
|
|
123
|
+
*) die 2 "unsupported CPU architecture: ${_arch}
|
|
124
|
+
Supported: x86_64/amd64, aarch64/arm64.
|
|
125
|
+
You can still install via npm: npm install -g @xenosystem/agent-cli" ;;
|
|
126
|
+
esac
|
|
127
|
+
|
|
128
|
+
TARGET="${_os_tag}-${_arch_tag}"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# --- version resolution -----------------------------------------------------
|
|
132
|
+
# TWO pointers, tried in order:
|
|
133
|
+
#
|
|
134
|
+
# standalone.json the BINARY channel pointer. Authoritative for this script.
|
|
135
|
+
# version.json the npm-derived CLI pointer (shape: version/date/npm/
|
|
136
|
+
# install/notes), written by publish-cli-releases.mjs.
|
|
137
|
+
#
|
|
138
|
+
# They are deliberately separate. version.json's version is derived from the npm
|
|
139
|
+
# registry, so it can only ever name a version that npm has. The whole point of
|
|
140
|
+
# the standalone channel is to ship WITHOUT a registry round-trip, so the binary
|
|
141
|
+
# channel keeps its own pointer and can move independently (and ahead) of npm.
|
|
142
|
+
# Falling back to version.json keeps this script working for a release that ships
|
|
143
|
+
# binaries at the same version npm already has.
|
|
144
|
+
resolve_version() {
|
|
145
|
+
if [ -n "${XENO_VERSION:-}" ]; then
|
|
146
|
+
VERSION="${XENO_VERSION#v}"
|
|
147
|
+
info "version: ${VERSION} (pinned via XENO_VERSION)"
|
|
148
|
+
return 0
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
_pj="${TMPDIR_XENO}/pointer.json"
|
|
152
|
+
_src=""
|
|
153
|
+
if fetch "${BASE_URL}/standalone.json" "${_pj}"; then
|
|
154
|
+
_src="standalone channel"
|
|
155
|
+
elif fetch "${BASE_URL}/version.json" "${_pj}"; then
|
|
156
|
+
_src="latest stable"
|
|
157
|
+
else
|
|
158
|
+
die 3 "could not fetch a release pointer from ${BASE_URL}
|
|
159
|
+
(tried standalone.json and version.json)
|
|
160
|
+
Check your network/proxy, or pin a known version with XENO_VERSION=x.y.z"
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
# Extract "version" without requiring jq.
|
|
164
|
+
VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${_pj}" | head -n 1)"
|
|
165
|
+
[ -n "${VERSION}" ] || die 3 "could not parse a version out of the ${_src} pointer at ${BASE_URL}"
|
|
166
|
+
info "version: ${VERSION} (${_src})"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
# --- checksum ---------------------------------------------------------------
|
|
170
|
+
sha256_of() {
|
|
171
|
+
_f="$1"
|
|
172
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
173
|
+
sha256sum "${_f}" | cut -d' ' -f1
|
|
174
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
175
|
+
shasum -a 256 "${_f}" | cut -d' ' -f1
|
|
176
|
+
elif command -v openssl >/dev/null 2>&1; then
|
|
177
|
+
openssl dgst -sha256 "${_f}" | sed 's/.*= *//'
|
|
178
|
+
else
|
|
179
|
+
die 1 "no SHA-256 tool found (need one of: sha256sum, shasum, openssl).
|
|
180
|
+
Refusing to install an unverified binary."
|
|
181
|
+
fi
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# verify_checksum <file> <expected-hex> — hard abort on mismatch.
|
|
185
|
+
verify_checksum() {
|
|
186
|
+
_file="$1"; _expected="$2"
|
|
187
|
+
_actual="$(sha256_of "${_file}")"
|
|
188
|
+
# Normalise case; hashes are compared as lowercase hex.
|
|
189
|
+
_expected="$(printf '%s' "${_expected}" | tr '[:upper:]' '[:lower:]')"
|
|
190
|
+
_actual="$(printf '%s' "${_actual}" | tr '[:upper:]' '[:lower:]')"
|
|
191
|
+
if [ "${_actual}" != "${_expected}" ]; then
|
|
192
|
+
die 4 "CHECKSUM MISMATCH — refusing to install.
|
|
193
|
+
|
|
194
|
+
artifact : $(basename "${_file}")
|
|
195
|
+
expected : ${_expected}
|
|
196
|
+
actual : ${_actual}
|
|
197
|
+
|
|
198
|
+
The download does not match the published SHA-256. This is either a corrupted
|
|
199
|
+
transfer or a tampered artifact. Nothing has been installed. Do not retry
|
|
200
|
+
blindly on an untrusted network; report this if it persists."
|
|
201
|
+
fi
|
|
202
|
+
info "sha256 verified: ${_actual}"
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
# --- main -------------------------------------------------------------------
|
|
206
|
+
main() {
|
|
207
|
+
say ""
|
|
208
|
+
say "XENO Agent CLI — standalone installer"
|
|
209
|
+
say ""
|
|
210
|
+
|
|
211
|
+
need_cmd uname
|
|
212
|
+
need_cmd tar
|
|
213
|
+
detect_downloader
|
|
214
|
+
detect_target
|
|
215
|
+
|
|
216
|
+
TMPDIR_XENO="$(mktemp -d 2>/dev/null || mktemp -d -t xeno-install)"
|
|
217
|
+
[ -d "${TMPDIR_XENO}" ] || die 1 "could not create a temporary directory"
|
|
218
|
+
|
|
219
|
+
info "platform: ${TARGET}"
|
|
220
|
+
resolve_version
|
|
221
|
+
|
|
222
|
+
ARCHIVE="${BIN_NAME}-${TARGET}.tar.gz"
|
|
223
|
+
PAYLOAD="${BIN_NAME}-${TARGET}"
|
|
224
|
+
REL_URL="${BASE_URL}/v${VERSION}"
|
|
225
|
+
|
|
226
|
+
# 1) SHA256SUMS.txt is both the checksum source AND the release manifest.
|
|
227
|
+
_sums="${TMPDIR_XENO}/SHA256SUMS.txt"
|
|
228
|
+
fetch "${REL_URL}/SHA256SUMS.txt" "${_sums}" \
|
|
229
|
+
|| die 3 "could not fetch the checksum manifest: ${REL_URL}/SHA256SUMS.txt
|
|
230
|
+
Version ${VERSION} may not publish standalone binaries.
|
|
231
|
+
Fallback: npm install -g @xenosystem/agent-cli"
|
|
232
|
+
|
|
233
|
+
# 2) Is THIS platform published in THIS release? Data-driven, so the script
|
|
234
|
+
# never goes stale as the build matrix grows.
|
|
235
|
+
EXPECTED="$(awk -v want="${ARCHIVE}" '$2 == want || $2 == "*" want { print $1; exit }' "${_sums}")"
|
|
236
|
+
if [ -z "${EXPECTED}" ]; then
|
|
237
|
+
say ""
|
|
238
|
+
say " Published artifacts for v${VERSION}:"
|
|
239
|
+
awk '{ printf " %s\n", $2 }' "${_sums}" >&2 || true
|
|
240
|
+
die 2 "no standalone binary for ${TARGET} in release v${VERSION}.
|
|
241
|
+
|
|
242
|
+
This platform has not been built yet (see docs/INSTALL-SCRIPT.md, platform matrix).
|
|
243
|
+
Install via npm instead: npm install -g @xenosystem/agent-cli"
|
|
244
|
+
fi
|
|
245
|
+
|
|
246
|
+
# 3) Download the artifact.
|
|
247
|
+
_archive="${TMPDIR_XENO}/${ARCHIVE}"
|
|
248
|
+
info "downloading ${ARCHIVE}"
|
|
249
|
+
fetch "${REL_URL}/${ARCHIVE}" "${_archive}" \
|
|
250
|
+
|| die 3 "download failed: ${REL_URL}/${ARCHIVE}"
|
|
251
|
+
|
|
252
|
+
# 4) Verify BEFORE unpacking. Nothing is executed or installed until this passes.
|
|
253
|
+
verify_checksum "${_archive}" "${EXPECTED}"
|
|
254
|
+
|
|
255
|
+
# 5) Unpack into the temp dir only.
|
|
256
|
+
tar -xzf "${_archive}" -C "${TMPDIR_XENO}" \
|
|
257
|
+
|| die 5 "could not unpack ${ARCHIVE}"
|
|
258
|
+
[ -f "${TMPDIR_XENO}/${PAYLOAD}" ] \
|
|
259
|
+
|| die 5 "archive did not contain the expected payload '${PAYLOAD}'"
|
|
260
|
+
|
|
261
|
+
# 6) Install. Per-user only — no sudo, nothing written outside INSTALL_DIR.
|
|
262
|
+
mkdir -p "${INSTALL_DIR}" || die 5 "could not create ${INSTALL_DIR}"
|
|
263
|
+
[ -w "${INSTALL_DIR}" ] || die 5 "${INSTALL_DIR} is not writable.
|
|
264
|
+
Set a different location: XENO_INSTALL_DIR=\"\$HOME/bin\" ...
|
|
265
|
+
(This installer never uses sudo and never writes outside its install dir.)"
|
|
266
|
+
|
|
267
|
+
chmod 755 "${TMPDIR_XENO}/${PAYLOAD}" || die 5 "could not mark the binary executable"
|
|
268
|
+
# Atomic-ish replace: mv over an existing binary that may be running.
|
|
269
|
+
_dest="${INSTALL_DIR}/${BIN_NAME}"
|
|
270
|
+
rm -f "${_dest}.new"
|
|
271
|
+
cp "${TMPDIR_XENO}/${PAYLOAD}" "${_dest}.new" || die 5 "could not stage ${_dest}.new"
|
|
272
|
+
chmod 755 "${_dest}.new"
|
|
273
|
+
mv -f "${_dest}.new" "${_dest}" || die 5 "could not install ${_dest}"
|
|
274
|
+
|
|
275
|
+
say ""
|
|
276
|
+
say " installed: ${_dest}"
|
|
277
|
+
|
|
278
|
+
# 7) PATH guidance — print it only when it is actually missing.
|
|
279
|
+
case ":${PATH}:" in
|
|
280
|
+
*":${INSTALL_DIR}:"*)
|
|
281
|
+
say " ${INSTALL_DIR} is already on your PATH."
|
|
282
|
+
;;
|
|
283
|
+
*)
|
|
284
|
+
say ""
|
|
285
|
+
say " ${INSTALL_DIR} is NOT on your PATH. Add it:"
|
|
286
|
+
say ""
|
|
287
|
+
say " export PATH=\"${INSTALL_DIR}:\$PATH\""
|
|
288
|
+
say ""
|
|
289
|
+
say " (append that line to ~/.bashrc, ~/.zshrc, or ~/.profile to persist it)"
|
|
290
|
+
;;
|
|
291
|
+
esac
|
|
292
|
+
|
|
293
|
+
say ""
|
|
294
|
+
say " Run: ${BIN_NAME} --help"
|
|
295
|
+
say ""
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
main "$@"
|