@beeos-ai/cli 1.0.12 → 1.0.14
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/index.js +1752 -315
- package/package.json +2 -2
- package/scripts/_existing_install_actions.json +40 -0
- package/scripts/install.Tests.ps1 +169 -0
- package/scripts/install.ps1 +252 -9
- package/scripts/install.sh +61 -9
package/scripts/install.sh
CHANGED
|
@@ -99,9 +99,11 @@ success() { printf "${BOLD}${GREEN}[beeos]${RESET} %s\n" "$*"; }
|
|
|
99
99
|
|
|
100
100
|
# ── Telemetry (script-level, pre-CLI) ────────────────────────
|
|
101
101
|
#
|
|
102
|
-
# Mirrors `web/packages/cli/src/telemetry.ts`
|
|
102
|
+
# Mirrors `web/packages/cli/src/telemetry.ts` (the Node-side single
|
|
103
|
+
# source of truth for event names + payload shape) so we can capture
|
|
103
104
|
# failures that happen BEFORE the Node CLI even starts (e.g. Node
|
|
104
|
-
# install failure, unsupported arch).
|
|
105
|
+
# install failure, unsupported arch). Add a new event in BOTH places
|
|
106
|
+
# or the dashboard query and the script will silently disagree. Fire-and-forget with a 2 s cap —
|
|
105
107
|
# we must never block a real install on a flaky telemetry endpoint.
|
|
106
108
|
#
|
|
107
109
|
# Event names used here:
|
|
@@ -230,7 +232,10 @@ detect_platform() {
|
|
|
230
232
|
# let them override when they know what they're doing.
|
|
231
233
|
local interactive=0
|
|
232
234
|
if [[ -t 0 ]] || [[ -t 1 ]]; then interactive=1; fi
|
|
233
|
-
local
|
|
235
|
+
# Inner helper functions — `local` doesn't apply to function
|
|
236
|
+
# declarations in bash, so these are scoped via the closure-style
|
|
237
|
+
# convention of "only callers inside this function see them" plus a
|
|
238
|
+
# naming prefix so they don't collide with outer scope.
|
|
234
239
|
arch_bail() {
|
|
235
240
|
local reason="$1"
|
|
236
241
|
error "$reason"
|
|
@@ -426,22 +431,41 @@ beeos_current_version() {
|
|
|
426
431
|
}
|
|
427
432
|
|
|
428
433
|
prompt_existing_install_action() {
|
|
434
|
+
# The labels here are anchored against the equivalents in
|
|
435
|
+
# install.ps1 (Read-ExistingInstallAction) and `init.ts`'s
|
|
436
|
+
# `decideAction` menu by
|
|
437
|
+
# `web/packages/cli/scripts/_existing_install_actions.json` and the
|
|
438
|
+
# vitest grep lint at
|
|
439
|
+
# `web/packages/cli/src/__tests__/existing-install-actions.test.ts`
|
|
440
|
+
# (P1-E of the install-link review). Keep at least one keyword from
|
|
441
|
+
# the manifest's `keywords[action]` array per option so the lint
|
|
442
|
+
# doesn't break.
|
|
443
|
+
#
|
|
429
444
|
# Only prompt on an interactive TTY. When the script is piped without a
|
|
430
445
|
# TTY attached (e.g. one-liner with no tty allocated), default to
|
|
431
|
-
# "
|
|
446
|
+
# "reinstall + re-run init" which is the safest non-destructive choice.
|
|
432
447
|
if [[ ! -t 0 ]] && [[ ! -t 1 ]]; then
|
|
433
|
-
info "Non-interactive shell detected — defaulting to
|
|
448
|
+
info "Non-interactive shell detected — defaulting to reinstall."
|
|
434
449
|
echo "upgrade"
|
|
435
450
|
return 0
|
|
436
451
|
fi
|
|
437
452
|
|
|
453
|
+
# Note on naming: the option below is labelled "Reinstall + upgrade
|
|
454
|
+
# CLI" deliberately. `beeos init`'s own menu has an item called
|
|
455
|
+
# "Upgrade CLI & agents" — it does (now) call `npm i -g` for the
|
|
456
|
+
# three-piece suite and re-runs `beeos start openclaw`. The script
|
|
457
|
+
# action here is broader: it also re-bootstraps Node / pnpm if
|
|
458
|
+
# missing, re-applies env vars from this shell, and *exec*s the
|
|
459
|
+
# newly-installed binary. Different verb avoids the user thinking
|
|
460
|
+
# they're picking the same code path twice. (See `init.ts`'s own
|
|
461
|
+
# upgrade branch for the in-CLI behavior.)
|
|
438
462
|
local ver
|
|
439
463
|
ver=$(beeos_current_version || true)
|
|
440
464
|
ver="${ver:-unknown}"
|
|
441
465
|
warn "BeeOS CLI is already installed (v${ver})."
|
|
442
466
|
echo ""
|
|
443
|
-
echo " [1]
|
|
444
|
-
echo " [2] Re-run ${BOLD}beeos init${RESET} without
|
|
467
|
+
echo " [1] Reinstall + upgrade CLI to the latest version, then run ${BOLD}beeos init${RESET}"
|
|
468
|
+
echo " [2] Re-run ${BOLD}beeos init${RESET} without reinstalling"
|
|
445
469
|
echo " [3] Skip (do nothing)"
|
|
446
470
|
echo ""
|
|
447
471
|
|
|
@@ -529,6 +553,11 @@ run_cli() {
|
|
|
529
553
|
|
|
530
554
|
info "Installing ${CLI_PACKAGE} globally..."
|
|
531
555
|
if ! npm install -g "$CLI_PACKAGE"; then
|
|
556
|
+
# P0-A of the install-link review: separate "Node ready" from
|
|
557
|
+
# "CLI is actually on PATH" so the dashboard never reports a
|
|
558
|
+
# success that the user can't reproduce. `install.bootstrap.npm_fail`
|
|
559
|
+
# is the canonical fail-after-bootstrap marker.
|
|
560
|
+
send_telemetry "install.bootstrap.npm_fail" "npm_install_cli_failed" false
|
|
532
561
|
error "npm install -g ${CLI_PACKAGE} failed."
|
|
533
562
|
error ""
|
|
534
563
|
error "Common fixes:"
|
|
@@ -539,10 +568,26 @@ run_cli() {
|
|
|
539
568
|
exit 1
|
|
540
569
|
fi
|
|
541
570
|
install_device_agent_suite
|
|
571
|
+
# NPM succeeded AND device-agent suite either installed or skipped
|
|
572
|
+
# with a warning. Fire the "CLI is reachable on PATH" event before
|
|
573
|
+
# exec — exec replaces our process so this is the last chance.
|
|
574
|
+
send_telemetry "install.bootstrap.cli_installed"
|
|
542
575
|
exec beeos "$subcmd" "$@" <"$stdin_src"
|
|
543
576
|
}
|
|
544
577
|
|
|
545
578
|
main() {
|
|
579
|
+
# P1-F of the install-link review: dry-run hook for bats / CI smoke
|
|
580
|
+
# tests. Mirrors `install.ps1`'s `BEEOS_INSTALL_DRY_RUN=1` early
|
|
581
|
+
# exit. When set, every helper has been parsed and `main` was
|
|
582
|
+
# entered — the script is "loadable" — but no telemetry, no Node
|
|
583
|
+
# install, no `npm install -g`, no exec. This lets shellcheck +
|
|
584
|
+
# bats catch parse-time and helper-availability regressions
|
|
585
|
+
# without spawning a real Node bootstrap.
|
|
586
|
+
if [[ "${BEEOS_INSTALL_DRY_RUN:-}" == "1" ]]; then
|
|
587
|
+
echo "[beeos] BEEOS_INSTALL_DRY_RUN=1 — exiting early (smoke test mode)"
|
|
588
|
+
return 0
|
|
589
|
+
fi
|
|
590
|
+
|
|
546
591
|
echo ""
|
|
547
592
|
echo " ${BOLD}BeeOS CLI Installer${RESET}"
|
|
548
593
|
echo " ${DIM}https://beeos.ai${RESET}"
|
|
@@ -576,9 +621,10 @@ main() {
|
|
|
576
621
|
exit 0
|
|
577
622
|
;;
|
|
578
623
|
upgrade)
|
|
579
|
-
info "
|
|
624
|
+
info "Reinstalling ${CLI_PACKAGE}..."
|
|
580
625
|
if command -v npm &>/dev/null; then
|
|
581
626
|
if ! npm install -g "$CLI_PACKAGE"; then
|
|
627
|
+
send_telemetry "install.bootstrap.npm_fail" "npm_install_cli_failed_upgrade" false
|
|
582
628
|
error "npm install -g ${CLI_PACKAGE} failed."
|
|
583
629
|
error ""
|
|
584
630
|
error "Common fixes:"
|
|
@@ -600,7 +646,13 @@ main() {
|
|
|
600
646
|
info "Running BeeOS CLI..."
|
|
601
647
|
echo ""
|
|
602
648
|
|
|
603
|
-
|
|
649
|
+
# P0-A of the install-link review: this event marks "Node bootstrap
|
|
650
|
+
# finished, about to dispatch into npm install -g + the CLI". The
|
|
651
|
+
# follow-up `install.bootstrap.cli_installed` (fired inside run_cli
|
|
652
|
+
# after npm succeeds) is the real "user has working `beeos` on PATH"
|
|
653
|
+
# signal. The two are split so dashboards can distinguish bootstrap
|
|
654
|
+
# failures from npm/CLI failures.
|
|
655
|
+
send_telemetry "install.bootstrap.bootstrap_done"
|
|
604
656
|
|
|
605
657
|
if [[ "$MODE" == "device" ]]; then
|
|
606
658
|
run_cli "device" "attach" "${PASSTHROUGH_ARGS[@]+"${PASSTHROUGH_ARGS[@]}"}"
|