@beeos-ai/cli 1.0.18 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beeos-ai/cli",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "type": "module",
5
5
  "description": "BeeOS CLI — run AI agents from your desktop",
6
6
  "bin": {
@@ -27,6 +27,16 @@
27
27
  $env:BEEOS_USE_NPX = "1" Power-user throwaway install (beeos
28
28
  won't persist on PATH).
29
29
 
30
+ IMPORTANT (env inheritance):
31
+ $env:BEEOS_API_URL / BEEOS_AGENT_GATEWAY_URL / BEEOS_DASHBOARD_URL
32
+ must be set in THE SAME PowerShell session that runs this script
33
+ before the irm | iex pipe. They reach `beeos init` via the normal
34
+ process env passthrough — there is NO auto-injection from
35
+ command-line args.
36
+
37
+ Working: $env:BEEOS_API_URL = '...'; irm beeos.ai/install.ps1 | iex
38
+ Broken: irm beeos.ai/install.ps1 | iex (vars never set)
39
+
30
40
  .EXAMPLE
31
41
  # One-liner (PowerShell 5+):
32
42
  irm https://beeos.ai/install.ps1 | iex
@@ -331,9 +341,15 @@ function Install-NodeAuto {
331
341
  # choco's portable installs work without admin in some cases.
332
342
  if (-not (Test-IsAdministrator)) {
333
343
  if (Request-Elevation) {
334
- # Elevated process took over; exit cleanly so the user
335
- # doesn't see two installs racing.
336
- exit 0
344
+ # Elevated process took over; exit so the user doesn't see
345
+ # two installs racing. We use exit 10 (not 0) so any CI /
346
+ # automation wrapping the call can distinguish "the install
347
+ # COMPLETED in this session" (exit 0) from "the install
348
+ # was MOVED to an elevated window — wait for that one to
349
+ # finish" (exit 10). The new window's exit code is the
350
+ # authoritative success / failure signal.
351
+ Write-BeeOk "Installation moved to the elevated window. This session exits with code 10."
352
+ exit 10
337
353
  }
338
354
  Write-BeeWarn "Continuing without admin — winget/choco may fail with EACCES."
339
355
  }
@@ -441,19 +457,25 @@ function Invoke-BeeosCli {
441
457
  }
442
458
 
443
459
  Write-BeeInfo "Installing $CliPackage globally..."
444
- & npm install -g $CliPackage
445
- if ($LASTEXITCODE -ne 0) {
460
+ # 1.0.19: tee npm output into $BeeosInstallLog so support
461
+ # engineers can see the full npm stderr after-the-fact, not just
462
+ # whatever scrolled past in the terminal. `2>&1` merges stderr
463
+ # into the pipe so Tee-Object captures both streams.
464
+ & npm install -g $CliPackage 2>&1 | Tee-Object -FilePath $BeeosInstallLog -Append
465
+ $npmExit = $LASTEXITCODE
466
+ if ($npmExit -ne 0) {
446
467
  # P0-A of the install-link review: fail-after-bootstrap signal.
447
468
  # The `install.bootstrap.cli_installed` event is only emitted
448
469
  # AFTER npm reports success.
449
470
  Send-Telemetry -Event "install.bootstrap.npm_fail" -ErrorCode "npm_install_cli_failed" -Success $false
450
471
  Write-BeeError "npm install -g $CliPackage failed."
472
+ Write-BeeError " Full log: $BeeosInstallLog"
451
473
  Write-BeeError ""
452
474
  Write-BeeError "Common fixes:"
453
475
  Write-BeeError " - EEXIST on beeos from another package:"
454
- Write-BeeError " npm uninstall -g beeos # then re-run installer"
476
+ Write-BeeError " npm uninstall -g @beeos-ai/cli # then re-run installer"
455
477
  Write-BeeError " - EACCES / permission error: run PowerShell as Administrator"
456
- exit 1
478
+ exit 3
457
479
  }
458
480
  # Device-agent suite is intentionally NOT installed here; `beeos
459
481
  # device attach` will auto-install it on first use via
@@ -21,6 +21,16 @@
21
21
  # `beeos init` menu, not here. The bootstrap script stays small so it's
22
22
  # easy to maintain and easy to diagnose on a customer machine.
23
23
  #
24
+ # ── Exit codes ────────────────────────────────────────────────────
25
+ # 0 Success (or `exec` handed off — the CLI's own exit code wins)
26
+ # 1 Node bootstrap failure (Node missing / version too old / npm
27
+ # not on PATH after Node install)
28
+ # 2 Unsupported OS / CPU architecture (and user declined override)
29
+ # 3 `npm install -g @beeos-ai/cli` failed (CLI didn't reach PATH)
30
+ #
31
+ # Automation can branch on these — `1` is "fix your Node install",
32
+ # `2` is "wrong machine", `3` is "your npm prefix / proxy / disk".
33
+ #
24
34
  # ── Optional env vars ─────────────────────────────────────────────
25
35
  # BEEOS_API_URL Public API base (this script uses it for
26
36
  # telemetry; the CLI uses it for runtime).
@@ -36,6 +46,17 @@
36
46
  # BEEOS_USE_NPX=1 Power-user throwaway install (beeos won't
37
47
  # persist on PATH).
38
48
  #
49
+ # IMPORTANT (env inheritance):
50
+ # BEEOS_API_URL / BEEOS_AGENT_GATEWAY_URL / BEEOS_DASHBOARD_URL must
51
+ # be set in THE SHELL THAT RUNS THIS SCRIPT before the curl pipe.
52
+ # They reach `beeos init` only via the normal exec env passthrough
53
+ # — there is NO auto-injection from the curl arguments.
54
+ #
55
+ # Working: `BEEOS_API_URL=... bash -c 'curl ...| bash'`
56
+ # Working: Set the var in your shell profile, then run normally.
57
+ # Broken: `bash -c "BEEOS_API_URL=... curl ... | bash"`
58
+ # (the var is local to the inner bash, not exported).
59
+ #
39
60
  # Bare-metal staging one-liner:
40
61
  #
41
62
  # BEEOS_API_URL=https://public-api-staging.beeos.ai \
@@ -100,6 +121,25 @@ success() { printf "${BOLD}${GREEN}[beeos]${RESET} %s\n" "$*"; }
100
121
  # `BEEOS_NO_TELEMETRY=1` short-circuits everything. This matches the
101
122
  # Node CLI's opt-out env var verbatim so a user who disabled telemetry
102
123
  # for the CLI doesn't unexpectedly get events from the bootstrap.
124
+ # Minimal JSON string-value escaper. Maps the four characters that
125
+ # can break a `"..."` JSON literal to their backslash escapes:
126
+ #
127
+ # \ -> \\
128
+ # " -> \"
129
+ # <CR> -> \r
130
+ # <LF> -> \n
131
+ #
132
+ # We deliberately don't pull in jq (not always available) or full
133
+ # JSON encoding — telemetry payload values are short slugs and human
134
+ # strings, not arbitrary binary. Tab + control-char escaping is
135
+ # nice-to-have but the four cases above are the ones that actually
136
+ # show up (e.g. `error_code` strings carrying quoted reasons, or
137
+ # error messages with embedded newlines).
138
+ json_escape() {
139
+ printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' \
140
+ | tr '\r' ' ' | tr '\n' ' '
141
+ }
142
+
103
143
  send_telemetry() {
104
144
  local event="$1"
105
145
  local error_code="${2:-}"
@@ -121,13 +161,25 @@ send_telemetry() {
121
161
  local host_hint
122
162
  host_hint="$(hostname 2>/dev/null || echo unknown)-${os_arch}"
123
163
 
164
+ # 1.0.19: every value below goes through `json_escape` so a stray
165
+ # `"` or newline in any of these fields can't break the POST body.
166
+ # `success_flag` is a bare boolean literal — never user-controlled —
167
+ # so it stays unquoted/unescaped.
168
+ local ev_e os_e arch_e node_e ec_e host_e
169
+ ev_e=$(json_escape "$event")
170
+ os_e=$(json_escape "$os_kind")
171
+ arch_e=$(json_escape "$os_arch")
172
+ node_e=$(json_escape "$node_ver")
173
+ ec_e=$(json_escape "$error_code")
174
+ host_e=$(json_escape "$host_hint")
175
+
124
176
  # POST body kept deliberately small — matches Node CLI payload.
125
177
  # Note: `cli_version` is empty until after npx install; we fill it
126
178
  # only when the bootstrap telemetry is fired post-install, from the
127
179
  # Node side. For pre-install events it stays "" and that's fine.
128
180
  local body
129
181
  body=$(cat <<JSON
130
- {"event":"${event}","cli_version":"","dist_tag":"","os":"${os_kind}","arch":"${os_arch}","node_version":"${node_ver}","success":${success_flag},"error_code":"${error_code}","host_hint":"${host_hint}"}
182
+ {"event":"${ev_e}","cli_version":"","dist_tag":"","os":"${os_e}","arch":"${arch_e}","node_version":"${node_e}","success":${success_flag},"error_code":"${ec_e}","host_hint":"${host_e}"}
131
183
  JSON
132
184
  )
133
185
 
@@ -324,8 +376,12 @@ try_install_node() {
324
376
  fi
325
377
  fi
326
378
 
327
- # 3. fnm — works on locked-down Linux without git/curl quirks
328
- if [[ "$OS_KIND" == "linux" ]] && ! command -v fnm &>/dev/null; then
379
+ # 3. fnm — works on locked-down Linux without git/curl quirks AND
380
+ # on macOS where users have neither Homebrew nor an existing nvm
381
+ # (the historical 1.0.18 path required brew on darwin, which is not
382
+ # always available — corporate-managed Macs, fresh users).
383
+ if [[ "$OS_KIND" == "linux" || "$OS_KIND" == "darwin" ]] \
384
+ && ! command -v fnm &>/dev/null; then
329
385
  info "Trying fnm (single-user, no sudo)..."
330
386
  if curl -fsSL "$FNM_INSTALL_URL" 2>>"$BEEOS_INSTALL_LOG" \
331
387
  | bash -s -- --skip-shell >> "$BEEOS_INSTALL_LOG" 2>&1; then
@@ -339,7 +395,8 @@ try_install_node() {
339
395
  fi
340
396
  fi
341
397
 
342
- # 4. macOS Homebrew
398
+ # 4. macOS Homebrew (last resort — already-installed brew only,
399
+ # we don't try to install brew itself).
343
400
  if [[ "$OS_KIND" == "darwin" ]] && command -v brew &>/dev/null; then
344
401
  info "Trying Homebrew..."
345
402
  if brew install node >> "$BEEOS_INSTALL_LOG" 2>&1; then
@@ -433,20 +490,27 @@ run_cli() {
433
490
  fi
434
491
 
435
492
  info "Installing ${CLI_PACKAGE} globally..."
436
- if ! npm install -g "$CLI_PACKAGE"; then
493
+ # 1.0.19: tee npm output into BEEOS_INSTALL_LOG. Without this, when
494
+ # `npm install -g` fails the user (and support engineers) only see
495
+ # whatever scrolled past in the terminal — important details like
496
+ # the npm error code, registry URL, or proxy hint may be gone by
497
+ # the time they go to copy-paste. `set -o pipefail` (file header)
498
+ # ensures the pipe's exit status is `npm`'s, not `tee`'s.
499
+ if ! npm install -g "$CLI_PACKAGE" 2>&1 | tee -a "$BEEOS_INSTALL_LOG"; then
437
500
  # P0-A of the install-link review: separate "Node ready" from
438
501
  # "CLI is actually on PATH" so the dashboard never reports a
439
502
  # success that the user can't reproduce. `install.bootstrap.npm_fail`
440
503
  # is the canonical fail-after-bootstrap marker.
441
504
  send_telemetry "install.bootstrap.npm_fail" "npm_install_cli_failed" false
442
505
  error "npm install -g ${CLI_PACKAGE} failed."
506
+ error " Full log: ${BEEOS_INSTALL_LOG}"
443
507
  error ""
444
508
  error "Common fixes:"
445
509
  error " - EEXIST on /bin/beeos from another package:"
446
- error " npm uninstall -g beeos # then re-run installer"
510
+ error " npm uninstall -g @beeos-ai/cli # then re-run installer"
447
511
  error " - EACCES permission error:"
448
512
  error " use a node version manager (nvm / fnm) or sudo"
449
- exit 1
513
+ exit 3
450
514
  fi
451
515
  # NPM succeeded — CLI is now on PATH. The device-agent suite is
452
516
  # deliberately NOT installed here; `beeos device attach` will