@moondeck/station 1.0.3 → 1.0.5

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.
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # Design points:
11
11
  # - Debian bookworm-slim base, non-root `node` user (home /home/node).
12
- # - asdf at /opt/asdf with plugins for nodejs/python/golang/ruby/rust.
12
+ # - asdf at /opt/asdf with plugins for nodejs/python/golang/ruby/rust/bun.
13
13
  # Before Compose starts a task, a host-controlled maintenance container
14
14
  # materializes its declared versions into the host-wide /opt/asdf-data
15
15
  # volume. uai-init only installs task-local dependencies afterward.
@@ -29,6 +29,8 @@ FROM debian:bookworm-slim
29
29
 
30
30
  # asdf release to clone. Pinned for reproducible builds; bump deliberately.
31
31
  ENV ASDF_VERSION=v0.14.1
32
+ ENV ASDF_BUN_PLUGIN_COMMIT=804d9603c473ea616fa078f851fa8380246e2c7a
33
+ ENV MISE_VERSION=2026.11.1
32
34
 
33
35
  # Qualified agent builds. These are execution-contract pins: per-command env
34
36
  # freshness is requalified before any of them moves.
@@ -74,6 +76,7 @@ RUN apt-get update \
74
76
  procps \
75
77
  python3-minimal \
76
78
  ripgrep \
79
+ sqlite3 \
77
80
  tk-dev \
78
81
  tmux \
79
82
  unzip \
@@ -112,6 +115,30 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
112
115
  # Installed system-wide so both root and node can run it.
113
116
  RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin sh
114
117
 
118
+ # mise is opt-in: install its binary on the system PATH, with no activation
119
+ # hook or mise shims. asdf shims retain priority for every managed runtime.
120
+ # Published hashes: https://github.com/jdx/mise/releases/download/v2026.11.1/SHASUMS256.txt
121
+ RUN set -eu; \
122
+ case "$(dpkg --print-architecture)" in \
123
+ amd64) mise_arch=x64; mise_sha256=9c3f740597f5e5815ecb50ec6fafa080e94472d0780220bcb214eb98bd902dca ;; \
124
+ arm64) mise_arch=arm64; mise_sha256=6b54d9223f8bce04f9168ef482d9ee27f219c1ea11f4903569660049e5dec5aa ;; \
125
+ *) echo "unsupported mise architecture" >&2; exit 1 ;; \
126
+ esac; \
127
+ curl -fsSL "https://github.com/jdx/mise/releases/download/v${MISE_VERSION}/mise-v${MISE_VERSION}-linux-${mise_arch}.tar.gz" -o /tmp/mise.tar.gz; \
128
+ echo "$mise_sha256 /tmp/mise.tar.gz" | sha256sum -c -; \
129
+ tar -xzf /tmp/mise.tar.gz -C /tmp mise/bin/mise; \
130
+ install -m 0755 /tmp/mise/bin/mise /usr/local/bin/mise; \
131
+ rm -rf /tmp/mise /tmp/mise.tar.gz; \
132
+ mise --version
133
+
134
+ # Keep an image-local pinned Bun plugin for volumes created before Bun support.
135
+ # Give node ownership so Git permits its local clone (safe-directory ownership
136
+ # checks reject a root-owned source). Apple task edits affect only its overlay.
137
+ RUN git clone https://github.com/cometkim/asdf-bun.git /usr/local/share/uai/asdf-bun \
138
+ && git -C /usr/local/share/uai/asdf-bun checkout --detach "$ASDF_BUN_PLUGIN_COMMIT" \
139
+ && test "$(git -C /usr/local/share/uai/asdf-bun rev-parse HEAD)" = "$ASDF_BUN_PLUGIN_COMMIT" \
140
+ && chown -R 1000:1000 /usr/local/share/uai/asdf-bun
141
+
115
142
  # ---------------------------------------------------------------------------
116
143
  # 2. Non-root `node` user.
117
144
  #
@@ -232,6 +259,7 @@ RUN bash -lc '\
232
259
  asdf plugin add golang https://github.com/asdf-community/asdf-golang.git; \
233
260
  asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \
234
261
  asdf plugin add rust https://github.com/asdf-community/asdf-rust.git; \
262
+ asdf plugin add bun /usr/local/share/uai/asdf-bun; \
235
263
  cd /home/node && asdf install nodejs && asdf install python; \
236
264
  '
237
265
 
@@ -14,11 +14,16 @@ See [`docs/runtime.md`](../../../docs/runtime.md) for the authoritative spec.
14
14
  expect `/home/node`.
15
15
  - **asdf** at `/opt/asdf`, data dir `/opt/asdf-data` (the host-wide
16
16
  `moondeck-asdf-data` volume mounts there read-only in task apps). Plugins
17
- pre-added for `nodejs`, `python`, `golang`, `ruby`, `rust`. Only the root
18
- defaults are installed at build time; after worktree resolution, a
17
+ pre-added for `nodejs`, `python`, `golang`, `ruby`, `rust`, `bun` (pinned
18
+ plugin). Only the root defaults are installed at build time; after worktree resolution, a
19
19
  host-controlled pre-start maintenance container is the bounded, locked
20
20
  read-write user that installs and proves other versions before the task app
21
21
  exists.
22
+ - **mise** 2026.11.1 at `/usr/local/bin/mise`, checksum-verified for amd64/arm64.
23
+ It is not activated globally and adds no shims ahead of asdf. Use
24
+ `mise install <tool>@<version>`, then `mise exec -- <cmd>` for skipped tools;
25
+ repositories with `mise.toml` need `mise trust` first.
26
+ - **sqlite3**, the Debian command-line client, alongside `libsqlite3-dev`.
22
27
  - **Default `~/.tool-versions`** (asdf's global fallback, at `/home/node`)
23
28
  pinning a default Node + Python. The `tool-versions` file in this directory is
24
29
  the authoritative source for the numbers; the `Dockerfile` `COPY`s it to
@@ -99,6 +99,7 @@ export ASDF_PYTHON_VERSION=
99
99
  export ASDF_GOLANG_VERSION=
100
100
  export ASDF_RUBY_VERSION=
101
101
  export ASDF_RUST_VERSION=
102
+ export ASDF_BUN_VERSION=
102
103
  export ASDF_SKIP_RESHIM=1
103
104
  export COREPACK_HOME=/opt/asdf-data/corepack
104
105
  export COREPACK_DEFAULT_TO_LATEST=0
@@ -507,6 +508,49 @@ run_workspace_installs() {
507
508
  return 0
508
509
  }
509
510
 
511
+ # Synchronous, bounded runtime notes, separate from repository install output.
512
+ # Materialization has a read-only workspace and can only log to Station.
513
+ # Read only safe allowlisted worktrees; never discover extra runtime inputs.
514
+ log_skipped_runtime_tools() {
515
+ local slug manifest line tool shown hint count=0
516
+ local notes_file="$deps_state_dir/runtime-notes" staging
517
+ local -a fields=()
518
+ local -A seen=()
519
+ staging=$(mktemp "$deps_state_dir/.runtime-notes.XXXXXX") || return 0
520
+ # At most 16 entries, each with a 64-character slug and a 128-character
521
+ # tool name: under 8 KiB, regardless of repository install output or reruns.
522
+ while IFS= read -r slug || [ -n "$slug" ]; do
523
+ [[ "$slug" =~ ^[a-z0-9-]{1,64}$ ]] || continue
524
+ [ ! -L "$WORKSPACE/$slug" ] && [ -d "$WORKSPACE/$slug" ] || continue
525
+ manifest="$WORKSPACE/$slug/.tool-versions"
526
+ [ ! -L "$manifest" ] && [ -f "$manifest" ] || continue
527
+ while IFS= read -r line || [ -n "$line" ]; do
528
+ line=${line%%#*}
529
+ read -r -a fields <<< "$line" || true
530
+ [ "${#fields[@]}" -ge 2 ] || continue
531
+ tool=${fields[0]}
532
+ [[ "$tool" =~ ^[a-z0-9][a-z0-9_-]*$ ]] || continue
533
+ case "$tool" in
534
+ nodejs|python|golang|ruby|rust|bun|pnpm|yarn) continue ;;
535
+ esac
536
+ [ -z "${seen[$slug/$tool]:-}" ] || continue
537
+ seen[$slug/$tool]=1
538
+ shown=${tool:0:128}
539
+ [ "${#tool}" -le 128 ] || shown="$shown..."
540
+ hint=""
541
+ case "$tool" in node) hint=" Did you mean nodejs?" ;; go) hint=" Did you mean golang?" ;; esac
542
+ printf '%s\n' "$slug: skipped unsupported tool '$shown'; use mise install <tool>@<version>, then mise exec -- <cmd> (or its vendor installer).$hint" >>"$staging"
543
+ count=$((count + 1))
544
+ [ "$count" -lt 16 ] || break 2
545
+ done < "$manifest"
546
+ done < "$RUNTIME_PROJECTS"
547
+ if [ -s "$staging" ]; then
548
+ mv -fT -- "$staging" "$notes_file"
549
+ else
550
+ rm -f -- "$staging" "$notes_file"
551
+ fi
552
+ }
553
+
510
554
  # The detached worker is the only uai-init role that receives project env.
511
555
  # Its caller has already used uai-env-exec to perform one authenticated
512
556
  # refresh; this role does no editor or Git-control-plane work and exits after
@@ -526,6 +570,7 @@ if [ -d "$WORKSPACE" ] && [ -f "$RUNTIME_PROJECTS" ] \
526
570
  deps_log_file="$deps_state_dir/deps.log"
527
571
  deps_lock_dir="$deps_state_dir/deps.lock.d"
528
572
  mkdir -p "$deps_state_dir"
573
+ log_skipped_runtime_tools
529
574
 
530
575
  # One runner at a time. uai-init is re-runnable (task-up retry, recovery),
531
576
  # and each re-run SHOULD refresh dependencies — but never concurrently.
@@ -27,6 +27,9 @@ readonly PROJECT_ALLOWLIST=/run/uai/runtime-projects
27
27
  readonly COREPACK_VERSION_FILE=/usr/local/share/uai/corepack-version
28
28
  readonly ASDF_SH=/opt/asdf/asdf.sh
29
29
  readonly ASDF_DATA=/opt/asdf-data
30
+ # Pin bumps rely on ensure_bun_plugin replacing older cached checkouts under
31
+ # the maintenance lock; verify-only must escalate rather than mutate them.
32
+ readonly BUN_PLUGIN_COMMIT=804d9603c473ea616fa078f851fa8380246e2c7a
30
33
  readonly LOCK_PATH="$ASDF_DATA/.uai-maintenance.lock"
31
34
  readonly CONTROL_PATH=/opt/asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
32
35
  readonly APP_PATH="$ASDF_DATA/shims:$CONTROL_PATH"
@@ -249,6 +252,13 @@ validate_version() {
249
252
  reject_dot_segments "$version" "$manifest" "$line_number"
250
253
  }
251
254
 
255
+ supported_runtime() {
256
+ case "$1" in
257
+ nodejs|python|golang|ruby|rust|bun) return 0 ;;
258
+ *) return 1 ;;
259
+ esac
260
+ }
261
+
252
262
  # Parse and validate the complete manifest before passing any field to asdf.
253
263
  # ASDF remains the resolution authority; this parser only rejects shapes that
254
264
  # are ambiguous or could be interpreted as command/path injection.
@@ -277,7 +287,7 @@ validate_manifest() {
277
287
  [[ "$tool" =~ ^[a-z0-9][a-z0-9_-]*$ ]] \
278
288
  || fail "$manifest:$line_number has a malformed tool name '$tool'"
279
289
  case "$tool" in
280
- nodejs|python|golang|ruby|rust) ;;
290
+ nodejs|python|golang|ruby|rust|bun) ;;
281
291
  pnpm|yarn)
282
292
  # Not asdf plugins here: package managers are Corepack's domain
283
293
  # (live 2026-08-17 — the asdf-pnpm convention is common enough that
@@ -288,7 +298,7 @@ validate_manifest() {
288
298
  [[ "${fields[1]}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] \
289
299
  || fail "$manifest:$line_number must pin an exact $tool version (Corepack manages package managers)"
290
300
  ;;
291
- *) fail "$manifest:$line_number requests unsupported asdf plugin '$tool'" ;;
301
+ *) ;; # Valid unknown tools are ignored after full syntax validation.
292
302
  esac
293
303
  [ -z "${seen_tools[$tool]:-}" ] \
294
304
  || fail "$manifest:$line_number declares '$tool' more than once"
@@ -339,7 +349,7 @@ unset_tool_override() {
339
349
  unset "$variable"
340
350
  }
341
351
 
342
- for baked_tool in nodejs python golang ruby rust; do
352
+ for baked_tool in nodejs python golang ruby rust bun; do
343
353
  unset_tool_override "$baked_tool"
344
354
  done
345
355
 
@@ -416,6 +426,7 @@ tool_executable() {
416
426
  golang) printf go ;;
417
427
  ruby) printf ruby ;;
418
428
  rust) printf rustc ;;
429
+ bun) printf bun ;;
419
430
  *) return 1 ;;
420
431
  esac
421
432
  }
@@ -541,6 +552,10 @@ normalize_tool_version_output() {
541
552
  [[ "$output" =~ ^rustc[[:space:]]+([^[:space:]]+) ]] || return 1
542
553
  NORMALIZED_TOOL_VERSION=${BASH_REMATCH[1]}
543
554
  ;;
555
+ bun)
556
+ [[ "$output" =~ ^([0-9]+\.[0-9]+\.[0-9]+)([[:space:]]|$) ]] || return 1
557
+ NORMALIZED_TOOL_VERSION=${BASH_REMATCH[1]}
558
+ ;;
544
559
  *) return 1 ;;
545
560
  esac
546
561
  }
@@ -560,7 +575,7 @@ tool_selection_requires_exact_output() {
560
575
  ruby)
561
576
  [[ "$version" =~ ^${numeric}(-(preview|rc)[0-9]+)?$ ]]
562
577
  ;;
563
- golang|rust)
578
+ golang|rust|bun)
564
579
  [[ "$version" =~ ^${numeric}$ ]]
565
580
  ;;
566
581
  *) return 1 ;;
@@ -674,7 +689,7 @@ managed_install_location() {
674
689
  local root lexical_root real_root candidate lexical_candidate real_candidate
675
690
 
676
691
  case "$tool" in
677
- nodejs|python|golang|ruby|rust) ;;
692
+ nodejs|python|golang|ruby|rust|bun) ;;
678
693
  *) fail "refusing to repair unsupported asdf plugin '$tool'" ;;
679
694
  esac
680
695
  case "$version" in
@@ -1066,8 +1081,84 @@ prepare_package_manager() {
1066
1081
  }
1067
1082
  # END UAI_MANAGED_COREPACK_REPAIR
1068
1083
 
1084
+ # An interrupted clone can have HEAD/bin but lack lib files or a full checkout.
1085
+ # Every validation operation is read-only, including Git's optional lock policy.
1086
+ bun_plugin_is_valid() {
1087
+ local plugin=$1 head
1088
+ BUN_PLUGIN_ERROR="bun plugin is incomplete at $plugin (needs .git, bin/download, bin/install, lib/utils.bash and lib/semver.bash)"
1089
+ [ ! -L "$plugin" ] && [ -d "$plugin/.git" ] && [ ! -L "$plugin/.git" ] \
1090
+ && [ -f "$plugin/bin/download" ] && [ -x "$plugin/bin/download" ] \
1091
+ && [ -f "$plugin/bin/install" ] && [ -x "$plugin/bin/install" ] \
1092
+ && [ -f "$plugin/lib/utils.bash" ] && [ -r "$plugin/lib/utils.bash" ] \
1093
+ && [ -f "$plugin/lib/semver.bash" ] && [ -r "$plugin/lib/semver.bash" ] \
1094
+ || return 1
1095
+ BUN_PLUGIN_ERROR="bun plugin commit cannot be verified at $plugin"
1096
+ head=$(GIT_OPTIONAL_LOCKS=0 git -C "$plugin" rev-parse HEAD 2>/dev/null) || return 1
1097
+ BUN_PLUGIN_ERROR="bun plugin commit mismatch at $plugin (expected $BUN_PLUGIN_COMMIT)"
1098
+ [ "$head" = "$BUN_PLUGIN_COMMIT" ] || return 1
1099
+ BUN_PLUGIN_ERROR="bun plugin checkout is dirty or incomplete at $plugin"
1100
+ GIT_OPTIONAL_LOCKS=0 git -c core.fsmonitor=false -C "$plugin" diff --quiet HEAD -- \
1101
+ || return 1
1102
+ BUN_PLUGIN_ERROR=""
1103
+ }
1104
+
1105
+ ensure_bun_plugin() {
1106
+ local plugins_root="$ASDF_DATA/plugins" plugin="$ASDF_DATA/plugins/bun" lexical resolved
1107
+ if bun_plugin_is_valid "$plugin"; then return 0; fi
1108
+ [ "$VERIFY_ONLY" != 1 ] \
1109
+ || fail "$BUN_PLUGIN_ERROR; verify-only pass makes no installs or repairs; retry with a writable maintenance pass"
1110
+ [ -d /usr/local/share/uai/asdf-bun ] \
1111
+ || fail "bun needs an updated standard image with the pinned asdf-bun plugin"
1112
+ # Keep all rename/delete targets in this exact real plugins directory, never
1113
+ # through an existing symlink. The caller already holds the maintenance lock.
1114
+ [ ! -L "$plugins_root" ] && [ -d "$plugins_root" ] \
1115
+ || fail "shared asdf plugins root is not a real directory"
1116
+ lexical=$("$REALPATH_BIN" -m -s -- "$plugins_root") \
1117
+ || fail "could not normalize shared asdf plugins root"
1118
+ resolved=$("$REALPATH_BIN" -e -- "$plugins_root") \
1119
+ || fail "could not resolve shared asdf plugins root"
1120
+ [ "$lexical" = "$resolved" ] \
1121
+ || fail "shared asdf plugins root traverses a symbolic link"
1122
+ log "$BUN_PLUGIN_ERROR; replacing bun plugin from the pinned image copy"
1123
+ (
1124
+ # asdf ignores dot directories. Clone/validate in staging even on the first
1125
+ # seed, so a killed clone cannot publish a half-written plugins/bun.
1126
+ staging=$(mktemp -d "$plugins_root/.bun-replace.XXXXXX") \
1127
+ || fail "could not stage bun plugin replacement"
1128
+ promoted=0
1129
+ cleanup_bun_replacement() {
1130
+ local status=$?
1131
+ trap - EXIT HUP INT TERM
1132
+ if [ "$promoted" != 1 ] && { [ -e "$staging/old" ] || [ -L "$staging/old" ]; }; then
1133
+ if [ -e "$plugin" ] || [ -L "$plugin" ] \
1134
+ || ! mv -T -- "$staging/old" "$plugin"; then
1135
+ log "could not restore old bun plugin; preserved at $staging/old"
1136
+ return 1
1137
+ fi
1138
+ fi
1139
+ if ! "$RM_BIN" -rf --one-file-system -- "$staging"; then
1140
+ log "could not remove bun plugin staging directory $staging"
1141
+ exit 1
1142
+ fi
1143
+ return "$status"
1144
+ }
1145
+ trap cleanup_bun_replacement EXIT
1146
+ trap 'exit 129' HUP
1147
+ trap 'exit 130' INT
1148
+ trap 'exit 143' TERM
1149
+ git clone --quiet -- /usr/local/share/uai/asdf-bun "$staging/new" \
1150
+ || fail "could not clone the image's bun plugin"
1151
+ bun_plugin_is_valid "$staging/new" || fail "$BUN_PLUGIN_ERROR"
1152
+ if [ -e "$plugin" ] || [ -L "$plugin" ]; then
1153
+ mv -T -- "$plugin" "$staging/old" || fail "could not move old bun plugin aside"
1154
+ fi
1155
+ mv -T -- "$staging/new" "$plugin" || fail "could not publish the validated bun plugin"
1156
+ promoted=1
1157
+ ) || fail "bun plugin replacement failed; retry runtime materialization"
1158
+ }
1159
+
1069
1160
  materialize_manifest() {
1070
- local manifest=$1 project line tool version line_number=0
1161
+ local manifest=$1 project line tool version hint line_number=0
1071
1162
  local -a fields=()
1072
1163
 
1073
1164
  project=$(dirname "$manifest")
@@ -1082,7 +1173,15 @@ materialize_manifest() {
1082
1173
  case "$tool" in
1083
1174
  pnpm|yarn) continue ;; # Corepack-managed; see project_package_manager.
1084
1175
  esac
1176
+ if ! supported_runtime "$tool"; then
1177
+ hint=""
1178
+ case "$tool" in node) hint=" Did you mean nodejs?" ;; go) hint=" Did you mean golang?" ;; esac
1179
+ log "$manifest:$line_number: skipped unsupported tool '$tool'; use mise install <tool>@<version>, then mise exec -- <cmd> (or its vendor installer).$hint"
1180
+ continue
1181
+ fi
1085
1182
  unset_tool_override "$tool"
1183
+ # Seed only this allowlisted plugin under the existing maintenance lock.
1184
+ [ "$tool" != bun ] || ensure_bun_plugin
1086
1185
  asdf plugin list | grep -Fqx -- "$tool" \
1087
1186
  || fail "$manifest:$line_number requests unsupported asdf plugin '$tool'"
1088
1187
 
@@ -1156,9 +1255,11 @@ materialize_fallback_runtimes() {
1156
1255
  [ -n "$line" ] || continue
1157
1256
  read -r -a fields <<< "$line"
1158
1257
  tool=${fields[0]}
1258
+ supported_runtime "$tool" || continue
1159
1259
  if manifest_declares_tool "$manifest" "$tool"; then
1160
1260
  continue
1161
1261
  fi
1262
+ [ "$tool" != bun ] || ensure_bun_plugin
1162
1263
  asdf plugin list | grep -Fqx -- "$tool" \
1163
1264
  || fail "$defaults requests unavailable fallback plugin '$tool'"
1164
1265
  for version in "${fields[@]:1}"; do
@@ -1345,6 +1446,7 @@ prove_fallback_runtimes() {
1345
1446
  [ -n "$line" ] || continue
1346
1447
  read -r -a fields <<< "$line"
1347
1448
  tool=${fields[0]}
1449
+ supported_runtime "$tool" || continue
1348
1450
  if manifest_declares_tool "$manifest" "$tool"; then
1349
1451
  continue
1350
1452
  fi
@@ -1508,6 +1610,7 @@ for manifest in "${manifests[@]}"; do
1508
1610
  case "${fields[0]}" in
1509
1611
  pnpm|yarn) continue ;; # proven via prove_project_package_manager below
1510
1612
  esac
1613
+ supported_runtime "${fields[0]}" || continue
1511
1614
  unset_tool_override "${fields[0]}"
1512
1615
  for version in "${fields[@]:1}"; do
1513
1616
  prove_selection "${fields[0]}" "$version" "$project" "$manifest"
package/lib/agent-cli.ts CHANGED
@@ -1288,7 +1288,7 @@ async function main() {
1288
1288
  ? await api("POST", "/api/agent/previews", { name, containerPort: port, ...upstream })
1289
1289
  : await api("PATCH", "/api/agent/previews/" + encodeURIComponent(name), { containerPort: port, ...upstream });
1290
1290
  out("preview '" + r.name + "' on port " + r.containerPort + (action === "add" ? " — turn it on with: moondeck preview enable " + r.name : " — updated"));
1291
- if (upstream.upstreamHost || upstream.upstreamTls) console.error("Portless users: outside self tasks, start with portless proxy start --lan (or PORTLESS_LAN=1; enables mDNS). Check for LAN mode disabled; if printed, use an updated Moondeck image with avahi-utils, or ask the operator to install it and fix any reported LAN-IP problem, then restart. Use its printed LAN hostname (usually mta.local) and proxy port: HTTPS 443, HTTP 80, or your explicit -p port (e.g. 1355).");
1291
+ if (upstream.upstreamHost || upstream.upstreamTls) console.error("Portless users: use Portless >= 0.16 (no sudo needed for ports >= 80). Outside self tasks, start with portless proxy start --lan (or PORTLESS_LAN=1; enables mDNS). Check for LAN mode disabled; if printed, use an updated Moondeck image with avahi-utils, or ask the operator to install it and fix any reported LAN-IP problem, then restart. Use its printed LAN hostname (usually mta.local) and proxy port: HTTPS 443, HTTP 80, or your explicit -p port (e.g. 1355).");
1292
1292
  break;
1293
1293
  }
1294
1294
  case "preview remove": {
@@ -1486,7 +1486,7 @@ async function main() {
1486
1486
  " moondeck preview add <name> <containerPort> [--upstream-host <h>] [--https]",
1487
1487
  " moondeck preview update <name> <containerPort> [--upstream-host <h>] [--https]",
1488
1488
  " moondeck preview remove <name>",
1489
- " Portless outside self: portless proxy start --lan or PORTLESS_LAN=1 (mDNS); use printed *.local Host and proxy port 443/80, or explicit -p 1355. Check for LAN mode disabled; update the image/install avahi-utils and resolve the reported LAN issue, then restart.",
1489
+ " Portless >= 0.16 (no sudo for ports >= 80), outside self: portless proxy start --lan or PORTLESS_LAN=1 (mDNS); use printed *.local Host and proxy port 443/80, or explicit -p 1355. Check for LAN mode disabled; update the image/install avahi-utils and resolve the reported LAN issue, then restart.",
1490
1490
  " moondeck preview enable|disable <name> (turn it on; prints its URL)",
1491
1491
  " moondeck preview public|private <name> (public: a link anyone can open)",
1492
1492
  " moondeck project list | show <id|slug>",
@@ -0,0 +1,246 @@
1
+ /**
2
+ * The Station's view of its task scripts' dependencies (owner ask 4,
3
+ * 2026-11-09): check-deps.sh reports what _common.sh would refuse over, and
4
+ * the Station advertises it as `agentDependencies`, so a host missing
5
+ * sqlite3 or the Compose plugin says so on its page instead of failing one
6
+ * task script at a time.
7
+ *
8
+ * Report-only. Nothing here gates a task: every --aws-host Station launched
9
+ * by an installer before 2026-11 lacks both, and runs machine tasks fine.
10
+ *
11
+ * The check follows the runtime the Station pinned, exactly as the task
12
+ * scripts do: Docker needs the docker CLI and the Compose plugin; the Apple
13
+ * runtime needs neither. Until a runtime is pinned (or in sidecar mode,
14
+ * where no task script runs) there is nothing to report.
15
+ */
16
+ import { spawn } from "node:child_process";
17
+ import { readFileSync } from "node:fs";
18
+
19
+ import {
20
+ AGENT_DEPENDENCY_NAME,
21
+ MAX_AGENT_DEPENDENCIES,
22
+ MAX_AGENT_DEPENDENCY_FIX_CHARS,
23
+ type AgentDependencyCapability,
24
+ } from "../src/protocol";
25
+ import { agentScriptPath } from "./agent";
26
+
27
+ export type AgentDependencyRuntime = "docker" | "apple-container";
28
+
29
+ /** How often the Station re-runs the check, so installing a package clears
30
+ * the state without a restart. */
31
+ export const AGENT_DEPENDENCY_RECHECK_MS = 5 * 60_000;
32
+ const CHECK_TIMEOUT_MS = 15_000;
33
+ const MAX_CHECK_OUTPUT_BYTES = 16 * 1024;
34
+
35
+ /** The `missing` list from check-deps.sh's stdout; throws on anything else. */
36
+ export function parseCheckDepsOutput(stdout: string): string[] {
37
+ const line = stdout.trim().split("\n").pop() ?? "";
38
+ let parsed: unknown;
39
+ try {
40
+ parsed = JSON.parse(line);
41
+ } catch {
42
+ throw new Error("check-deps.sh printed no JSON");
43
+ }
44
+ const missing = (parsed as { ok?: unknown; data?: { missing?: unknown } } | null)?.data?.missing;
45
+ if (
46
+ (parsed as { ok?: unknown } | null)?.ok !== true ||
47
+ !Array.isArray(missing) ||
48
+ missing.length > MAX_AGENT_DEPENDENCIES ||
49
+ !missing.every((name) => typeof name === "string" && AGENT_DEPENDENCY_NAME.test(name)) ||
50
+ new Set(missing).size !== missing.length
51
+ ) {
52
+ throw new Error("check-deps.sh printed an unexpected result");
53
+ }
54
+ return [...missing] as string[];
55
+ }
56
+
57
+ /** The environment the task scripts get for this runtime: the Station
58
+ * publishes UAI_TASK_RUNTIME=apple-container for Apple and clears it for
59
+ * Docker (lib/container-runtime.ts). */
60
+ export function checkDepsEnv(
61
+ runtime: AgentDependencyRuntime,
62
+ base: NodeJS.ProcessEnv = process.env,
63
+ ): NodeJS.ProcessEnv {
64
+ const next: NodeJS.ProcessEnv = { ...base };
65
+ if (runtime === "apple-container") next.UAI_TASK_RUNTIME = "apple-container";
66
+ else delete next.UAI_TASK_RUNTIME;
67
+ return next;
68
+ }
69
+
70
+ /** Runs this generation's check-deps.sh; resolves the missing list. */
71
+ export function runCheckDeps(
72
+ runtime: AgentDependencyRuntime,
73
+ options: { scriptPath?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number } = {},
74
+ ): Promise<string[]> {
75
+ const scriptPath = options.scriptPath ?? agentScriptPath("check-deps.sh");
76
+ return new Promise((resolve, reject) => {
77
+ const child = spawn(scriptPath, [], {
78
+ stdio: ["ignore", "pipe", "pipe"],
79
+ env: checkDepsEnv(runtime, options.env),
80
+ });
81
+ let stdout = "";
82
+ let stderr = "";
83
+ let settled = false;
84
+ const finish = (error: Error | null, missing?: string[]): void => {
85
+ if (settled) return;
86
+ settled = true;
87
+ clearTimeout(timer);
88
+ if (error) reject(error);
89
+ else resolve(missing ?? []);
90
+ };
91
+ const timer = setTimeout(() => {
92
+ child.kill("SIGKILL");
93
+ finish(new Error("check-deps.sh timed out"));
94
+ }, options.timeoutMs ?? CHECK_TIMEOUT_MS);
95
+ timer.unref?.();
96
+ child.stdout.on("data", (chunk: Buffer) => {
97
+ if (stdout.length < MAX_CHECK_OUTPUT_BYTES) stdout += chunk.toString("utf8");
98
+ });
99
+ child.stderr.on("data", (chunk: Buffer) => {
100
+ if (stderr.length < MAX_CHECK_OUTPUT_BYTES) stderr += chunk.toString("utf8");
101
+ });
102
+ child.on("error", (error) => finish(error));
103
+ child.on("close", (code) => {
104
+ if (code !== 0) {
105
+ finish(new Error(`check-deps.sh exited ${String(code)}${stderr.trim() ? `: ${stderr.trim().slice(-300)}` : ""}`));
106
+ return;
107
+ }
108
+ try {
109
+ finish(null, parseCheckDepsOutput(stdout));
110
+ } catch (error) {
111
+ finish(error instanceof Error ? error : new Error(String(error)));
112
+ }
113
+ });
114
+ });
115
+ }
116
+
117
+ /** The package each missing binary comes from, per OS the Station can name. */
118
+ const AL2023_PACKAGES: Readonly<Record<string, string>> = {
119
+ sqlite3: "sqlite",
120
+ jq: "jq",
121
+ git: "git",
122
+ docker: "docker",
123
+ };
124
+ const HOMEBREW_PACKAGES: Readonly<Record<string, string>> = {
125
+ sqlite3: "sqlite",
126
+ jq: "jq",
127
+ git: "git",
128
+ };
129
+
130
+ export interface HostOs {
131
+ platform: NodeJS.Platform;
132
+ /** /etc/os-release ID, when Linux. */
133
+ osReleaseId?: string;
134
+ }
135
+
136
+ export function currentHostOs(): HostOs {
137
+ if (process.platform !== "linux") return { platform: process.platform };
138
+ try {
139
+ const release = readFileSync("/etc/os-release", "utf8");
140
+ const id = /^ID="?([A-Za-z0-9._-]+)"?$/m.exec(release)?.[1];
141
+ return id ? { platform: "linux", osReleaseId: id } : { platform: "linux" };
142
+ } catch {
143
+ return { platform: "linux" };
144
+ }
145
+ }
146
+
147
+ /** A copyable install command for the packaged ones, when this OS has one.
148
+ * The Compose plugin is never in it: AL2023 does not package it. */
149
+ export function agentDependencyFix(missing: readonly string[], os: HostOs): string | undefined {
150
+ const [table, command] =
151
+ os.platform === "linux" && os.osReleaseId === "amzn"
152
+ ? [AL2023_PACKAGES, "sudo dnf install -y"]
153
+ : os.platform === "darwin"
154
+ ? [HOMEBREW_PACKAGES, "brew install"]
155
+ : [null, ""];
156
+ if (table === null) return undefined;
157
+ const packages = missing.flatMap((name) => (table[name] === undefined ? [] : [table[name]]));
158
+ if (packages.length === 0) return undefined;
159
+ const fix = `${command} ${[...new Set(packages)].join(" ")}`;
160
+ return fix.length <= MAX_AGENT_DEPENDENCY_FIX_CHARS ? fix : undefined;
161
+ }
162
+
163
+ export interface AgentDependencyMonitorDeps {
164
+ check(runtime: AgentDependencyRuntime): Promise<string[]>;
165
+ fix(missing: readonly string[]): string | undefined;
166
+ /** The advertised state changed: re-send capabilities. */
167
+ changed(): void;
168
+ warn?(message: string): void;
169
+ }
170
+
171
+ /**
172
+ * The last check's result, kept current. One check at a time; a request
173
+ * while one runs schedules exactly one more with the newest runtime. A
174
+ * check that cannot run reports nothing (absent), never "ok".
175
+ */
176
+ export class AgentDependencyMonitor {
177
+ #state: AgentDependencyCapability | undefined;
178
+ #running: Promise<void> | null = null;
179
+ #next: { runtime: AgentDependencyRuntime | null } | null = null;
180
+ readonly #deps: AgentDependencyMonitorDeps;
181
+
182
+ constructor(deps: AgentDependencyMonitorDeps) {
183
+ this.#deps = deps;
184
+ }
185
+
186
+ state(): AgentDependencyCapability | undefined {
187
+ return this.#state;
188
+ }
189
+
190
+ /** Re-run the check for `runtime` (null: none pinned, so nothing to report). */
191
+ recheck(runtime: AgentDependencyRuntime | null): Promise<void> {
192
+ this.#next = { runtime };
193
+ if (this.#running === null) {
194
+ this.#running = this.#drain().finally(() => {
195
+ this.#running = null;
196
+ });
197
+ }
198
+ return this.#running;
199
+ }
200
+
201
+ async #drain(): Promise<void> {
202
+ while (this.#next !== null) {
203
+ const { runtime } = this.#next;
204
+ this.#next = null;
205
+ let next: AgentDependencyCapability | undefined;
206
+ if (runtime === null) {
207
+ next = undefined;
208
+ } else {
209
+ try {
210
+ const missing = await this.#deps.check(runtime);
211
+ if (missing.length === 0) {
212
+ next = { status: "ok" };
213
+ } else {
214
+ const fix = this.#deps.fix(missing);
215
+ next = fix === undefined ? { status: "missing", missing } : { status: "missing", missing, fix };
216
+ }
217
+ } catch (error) {
218
+ this.#deps.warn?.(
219
+ `[agent-deps] dependency check failed: ${error instanceof Error ? error.message : String(error)}`,
220
+ );
221
+ next = undefined;
222
+ }
223
+ }
224
+ if (JSON.stringify(next) !== JSON.stringify(this.#state)) {
225
+ this.#state = next;
226
+ if (next?.status === "missing") {
227
+ this.#deps.warn?.(`[agent-deps] task scripts are missing on PATH: ${next.missing.join(", ")}`);
228
+ }
229
+ this.#deps.changed();
230
+ }
231
+ }
232
+ }
233
+ }
234
+
235
+ let recheckRequester: (() => void) | null = null;
236
+
237
+ /** main.ts binds the live monitor; tests and other entry points leave it unbound. */
238
+ export function setAgentDependencyRecheckRequester(requester: (() => void) | null): void {
239
+ recheckRequester = requester;
240
+ }
241
+
242
+ /** A task script just refused over a missing dependency: re-check now, so
243
+ * the host page shows it without waiting for the timer. */
244
+ export function requestAgentDependencyRecheck(): void {
245
+ recheckRequester?.();
246
+ }
package/lib/agent.ts CHANGED
@@ -119,6 +119,11 @@ function agentDir(): string {
119
119
  return env.agentDir ?? packageAgentScriptsDir();
120
120
  }
121
121
 
122
+ /** Absolute path of one of this generation's agent scripts. */
123
+ export function agentScriptPath(scriptName: string): string {
124
+ return resolve(agentDir(), scriptName);
125
+ }
126
+
122
127
  // ---------------------------------------------------------------------------
123
128
  // Result schemas. Each command shares the success envelope and produces a
124
129
  // command-specific `data` payload.
@@ -266,7 +271,7 @@ async function runAgent<T extends z.ZodTypeAny>(
266
271
  * (ADR-154: a start on cloud credentials gets none of the runner's). */
267
272
  withoutRunnerEnv: ReadonlySet<string> = new Set(),
268
273
  ): Promise<z.infer<T>> {
269
- const scriptPath = resolve(agentDir(), scriptName);
274
+ const scriptPath = agentScriptPath(scriptName);
270
275
  const runnerEnv = Object.fromEntries(
271
276
  Object.entries(process.env).filter(([name]) => !withoutRunnerEnv.has(name)),
272
277
  );