The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
feat(packaging): native .deb and .rpm packages for Linux
shukieshahfc3a6c6f8c82
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex d0ee4299..490aeb01 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -197,6 +197,42 @@ jobs:BEACON_SMOKE_ARCH: amd64run: sh packaging/linux/smoke-systemd.sh+ # Installs the built .deb in a container where systemd is PID 1 and asserts that installing the+ # package alone yields a running system-mode endpoint. smoke-systemd covers the service backend;+ # this covers the package postinstall doing it for the user, which is what they actually do.+ linux-package-smoke:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-go@v5+ with:+ go-version-file: cli/beacon/go.mod+ - name: Build collector for Linux+ run: |+ go install go.opentelemetry.io/collector/cmd/[email protected]+ cd collector-builder+ for arch in amd64 arm64; do+ GOOS=linux GOARCH=$arch CGO_ENABLED=0 "$(go env GOPATH)/bin/builder" --config builder.yaml+ mkdir -p dist/beacon-otelcol/linux_$arch+ cp dist/beacon-otelcol/beacon-otelcol dist/beacon-otelcol/linux_$arch/beacon-otelcol+ done+ # The goreleaser before-hook stages all four targets, so darwin must exist too.+ for arch in amd64 arm64; do+ mkdir -p dist/beacon-otelcol/darwin_$arch+ cp dist/beacon-otelcol/linux_$arch/beacon-otelcol dist/beacon-otelcol/darwin_$arch/beacon-otelcol+ done+ - uses: goreleaser/goreleaser-action@v6+ with:+ version: latest+ install-only: true+ - name: Build packages+ working-directory: cli/beacon+ run: goreleaser release --snapshot --clean --skip=publish,homebrew,announce --parallelism 1+ - name: Install the .deb and verify the endpoint+ env:+ BEACON_SMOKE_ARCH: amd64+ run: sh packaging/linux/smoke-package.sh+package-smoke:runs-on: macos-lateststeps:diff --git a/cli/beacon/.goreleaser.yaml b/cli/beacon/.goreleaser.yamlindex 9c1ff0a0..0498a6f2 100644--- a/cli/beacon/.goreleaser.yaml+++ b/cli/beacon/.goreleaser.yaml@@ -75,6 +75,58 @@ archives:- src: release-collectors/{{ .Os }}_{{ .Arch }}/beacon-otelcoldst: beacon-otelcol+nfpms:+ # Native packages are the Linux counterpart of the signed macOS .pkg: installing one should+ # produce a running system-mode endpoint, not a pile of binaries plus a manual step. The payload+ # deliberately mirrors /opt/beacon so that selfupdate's classifyInstall recognises a package+ # install and seamless updates work the same way on both platforms.+ - id: beacon+ package_name: beacon+ ids:+ - beacon+ - beacon-hooks+ vendor: Asymptote Labs+ homepage: https://docs.asymptotelabs.ai+ maintainer: Asymptote Labs <[email protected]>+ description: |-+ Endpoint telemetry agent for AI coding agents.+ Captures prompts, commands, file activity, tokens and approvals from local agent+ runtimes and writes normalized events to local or customer-managed destinations.+ license: MIT+ formats:+ - deb+ - rpm+ # Not FHS, and deliberately: /opt is the correct home for a self-contained vendor bundle,+ # it matches the macOS package layout, and selfupdate keys off this path.+ bindir: /opt/beacon/bin+ contents:+ - src: ../../collector-builder/dist/beacon-otelcol/linux_{{ .Arch }}/beacon-otelcol+ dst: /opt/beacon/bin/beacon-otelcol+ file_info:+ mode: 0755+ - src: ../../packaging/linux/install-endpoint.sh+ dst: /opt/beacon/scripts/install-endpoint.sh+ file_info:+ mode: 0755+ - src: ../../packaging/linux/uninstall-endpoint.sh+ dst: /opt/beacon/scripts/uninstall-endpoint.sh+ file_info:+ mode: 0755+ scripts:+ postinstall: ../../packaging/linux/nfpm/postinstall.sh+ preremove: ../../packaging/linux/nfpm/preremove.sh+ postremove: ../../packaging/linux/nfpm/postremove.sh+ # systemd is required for the service backend the package registers. Without it the endpoint+ # falls back to a supervised collector that nothing restarts, which is not what a package+ # install should silently deliver.+ dependencies:+ - systemd+ rpm:+ group: Applications/System+ deb:+ fields:+ Bugs: https://github.com/asymptote-labs/agent-beacon/issues+checksum:name_template: "checksums.txt"algorithm: sha256diff --git a/packaging/linux/install-endpoint.sh b/packaging/linux/install-endpoint.shnew file mode 100755index 00000000..63c1a705--- /dev/null+++ b/packaging/linux/install-endpoint.sh@@ -0,0 +1,55 @@+#!/bin/sh+# Installs the Beacon endpoint in system mode.+#+# Called by the .deb/.rpm postinstall, and usable directly for fleet tooling. Configuration is+# environment-first with positional fallbacks, matching packaging/macos/install-endpoint.sh so a+# mixed fleet has one contract rather than two.+set -eu++if [ -z "${BEACON_BIN:-}" ]; then+ if [ -x "/opt/beacon/bin/beacon" ]; then+ BEACON_BIN="/opt/beacon/bin/beacon"+ else+ BEACON_BIN="beacon"+ fi+fi++BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-${1:-claude,codex}}"+BEACON_OTLP_GRPC_PORT="${BEACON_OTLP_GRPC_PORT:-${2:-4317}}"+BEACON_OTLP_HTTP_PORT="${BEACON_OTLP_HTTP_PORT:-${3:-4318}}"+BEACON_COLLECTOR="${BEACON_COLLECTOR:-${4:-}}"+BEACON_NO_START="${BEACON_NO_START:-${5:-0}}"+BEACON_SERVICE="${BEACON_SERVICE:-${6:-}}"+BEACON_SPLUNK_HEC_ENDPOINT="${BEACON_SPLUNK_HEC_ENDPOINT:-}"+BEACON_SPLUNK_HEC_TOKEN="${BEACON_SPLUNK_HEC_TOKEN:-}"+BEACON_SPLUNK_INDEX="${BEACON_SPLUNK_INDEX:-}"+BEACON_SPLUNK_SOURCE="${BEACON_SPLUNK_SOURCE:-}"+BEACON_SPLUNK_SOURCETYPE="${BEACON_SPLUNK_SOURCETYPE:-}"+BEACON_SPLUNK_INSECURE_SKIP_VERIFY="${BEACON_SPLUNK_INSECURE_SKIP_VERIFY:-0}"+BEACON_SPLUNK_CA_FILE="${BEACON_SPLUNK_CA_FILE:-}"++# The packaged collector sits beside the CLI. Auto-detected rather than required, so a manual+# invocation without BEACON_COLLECTOR still works.+if [ -z "$BEACON_COLLECTOR" ] && [ -x "/opt/beacon/bin/beacon-otelcol" ]; then+ BEACON_COLLECTOR="/opt/beacon/bin/beacon-otelcol"+fi++set -- endpoint install --system \+ --harness "$BEACON_ENDPOINT_HARNESSES" \+ --otlp-grpc-port "$BEACON_OTLP_GRPC_PORT" \+ --otlp-http-port "$BEACON_OTLP_HTTP_PORT"++[ -n "$BEACON_COLLECTOR" ] && set -- "$@" --collector "$BEACON_COLLECTOR"+# Empty means auto-detect: systemd when it is PID 1, otherwise a supervised collector.+[ -n "$BEACON_SERVICE" ] && set -- "$@" --service "$BEACON_SERVICE"+[ "$BEACON_NO_START" = "1" ] && set -- "$@" --no-start++[ -n "$BEACON_SPLUNK_HEC_ENDPOINT" ] && set -- "$@" --splunk-hec-endpoint "$BEACON_SPLUNK_HEC_ENDPOINT"+[ -n "$BEACON_SPLUNK_HEC_TOKEN" ] && set -- "$@" --splunk-hec-token "$BEACON_SPLUNK_HEC_TOKEN"+[ -n "$BEACON_SPLUNK_INDEX" ] && set -- "$@" --splunk-index "$BEACON_SPLUNK_INDEX"+[ -n "$BEACON_SPLUNK_SOURCE" ] && set -- "$@" --splunk-source "$BEACON_SPLUNK_SOURCE"+[ -n "$BEACON_SPLUNK_SOURCETYPE" ] && set -- "$@" --splunk-sourcetype "$BEACON_SPLUNK_SOURCETYPE"+[ "$BEACON_SPLUNK_INSECURE_SKIP_VERIFY" = "1" ] && set -- "$@" --splunk-insecure-skip-verify+[ -n "$BEACON_SPLUNK_CA_FILE" ] && set -- "$@" --splunk-ca-file "$BEACON_SPLUNK_CA_FILE"++exec "$BEACON_BIN" "$@"diff --git a/packaging/linux/nfpm/postinstall.sh b/packaging/linux/nfpm/postinstall.shnew file mode 100755index 00000000..317a4b17--- /dev/null+++ b/packaging/linux/nfpm/postinstall.sh@@ -0,0 +1,24 @@+#!/bin/sh+# Runs after the .deb/.rpm unpacks /opt/beacon.+#+# Installing the package is the whole user-facing action, so this performs the endpoint install+# rather than leaving a second manual step. It is the Linux counterpart of the macOS pkg's+# postinstall.+set -eu++# Both package managers invoke this for upgrades as well as first installs. `endpoint install` is+# idempotent and rewrites its own config, so no branch on the argument is needed -- but an upgrade+# must not lose an operator's explicit auto-update choice, which reconcile below preserves.+if ! /opt/beacon/scripts/install-endpoint.sh; then+ echo "beacon: endpoint install failed" >&2+ exit 1+fi++# Reconcile the scheduled updater against the configured mode. Non-fatal: a missing or refused+# scheduler must not fail the package install, since the endpoint itself is already collecting.+if [ -x /opt/beacon/bin/beacon ]; then+ /opt/beacon/bin/beacon endpoint update install-daemon >/dev/null 2>&1 || \+ echo "beacon: scheduled updater not configured (endpoint is installed and running)" >&2+fi++echo "beacon: endpoint installed. Check it with: beacon endpoint status --system"diff --git a/packaging/linux/nfpm/postremove.sh b/packaging/linux/nfpm/postremove.shnew file mode 100755index 00000000..c66d6e08--- /dev/null+++ b/packaging/linux/nfpm/postremove.sh@@ -0,0 +1,13 @@+#!/bin/sh+# Runs after the package is removed.+#+# On a dpkg purge (or an rpm erase), remove the state that preremove deliberately kept. Anything+# short of a purge leaves logs and config in place.+set -eu++case "${1:-}" in+ purge)+ rm -rf /etc/beacon/endpoint+ rm -rf /var/log/beacon-agent+ ;;+esacdiff --git a/packaging/linux/nfpm/preremove.sh b/packaging/linux/nfpm/preremove.shnew file mode 100755index 00000000..36b2e6cf--- /dev/null+++ b/packaging/linux/nfpm/preremove.sh@@ -0,0 +1,35 @@+#!/bin/sh+# Runs before the package is removed.+#+# Stops and deregisters the service while the binaries it references still exist -- doing this in+# postremove would leave a unit pointing at a deleted collector.+#+# Debian policy (and rpm convention) is that removing a package leaves configuration behind and+# only a purge deletes it. `endpoint uninstall` deliberately removes everything it installed,+# including /etc/beacon/endpoint/config.json, because that is what uninstall means at the CLI+# level. Note that --keep-config is about *harness* telemetry settings, not Beacon's own config,+# so it does not help here. So the config is set aside and restored, leaving purge as the only+# thing that discards it.+set -eu++CONFIG_DIR=/etc/beacon/endpoint+STASH="$(mktemp -d)"+saved=0+for f in config.json otelcol.yaml; do+ if [ -f "$CONFIG_DIR/$f" ]; then+ cp -p "$CONFIG_DIR/$f" "$STASH/$f" && saved=1+ fi+done++if [ -x /opt/beacon/scripts/uninstall-endpoint.sh ]; then+ BEACON_KEEP_LOGS=1 BEACON_KEEP_CONFIG=1 /opt/beacon/scripts/uninstall-endpoint.sh || \+ echo "beacon: endpoint uninstall reported a problem; check systemctl status" >&2+fi++if [ "$saved" = 1 ]; then+ mkdir -p "$CONFIG_DIR"+ for f in config.json otelcol.yaml; do+ [ -f "$STASH/$f" ] && cp -p "$STASH/$f" "$CONFIG_DIR/$f"+ done+fi+rm -rf "$STASH"diff --git a/packaging/linux/smoke-package.sh b/packaging/linux/smoke-package.shnew file mode 100755index 00000000..bb9b6df9--- /dev/null+++ b/packaging/linux/smoke-package.sh@@ -0,0 +1,159 @@+#!/bin/sh+# Installs the built .deb (or .rpm) in a container where systemd is genuinely PID 1, and asserts+# that installing the package alone produces a running system-mode endpoint.+#+# This is the test for the actual goal: a Linux user should be able to install a package and be+# done. smoke-systemd.sh covers the service backend by calling `endpoint install` directly; this+# covers the package's own postinstall doing it for them, which is a different thing and the one+# users experience.+#+# Needs systemd as PID 1, which only a privileged container provides. Build the packages first:+# cd cli/beacon && goreleaser release --snapshot --clean --skip=publish,homebrew,announce+set -eu++ROOT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)"+ARCH="${BEACON_SMOKE_ARCH:-}"+if [ -z "$ARCH" ]; then+ case "$(uname -m)" in+ arm64|aarch64) ARCH=arm64 ;;+ x86_64|amd64) ARCH=amd64 ;;+ *) echo "unknown machine $(uname -m); set BEACON_SMOKE_ARCH" >&2; exit 1 ;;+ esac+fi+FORMAT="${BEACON_SMOKE_FORMAT:-deb}"++PKG="${BEACON_SMOKE_PKG:-}"+if [ -z "$PKG" ]; then+ # Newest matching package, so a fresh snapshot build is picked up without being named.+ PKG="$(ls -t "$ROOT_DIR"/cli/beacon/dist/*_linux_"$ARCH"."$FORMAT" 2>/dev/null | head -1 || true)"+fi+if [ -z "$PKG" ] || [ ! -f "$PKG" ]; then+ echo "no $FORMAT package for linux_$ARCH in cli/beacon/dist" >&2+ echo "build one with: cd cli/beacon && goreleaser release --snapshot --clean --skip=publish,homebrew,announce" >&2+ exit 1+fi+echo "package: $(basename "$PKG")"++command -v docker >/dev/null 2>&1 || { echo "docker is required" >&2; exit 1; }++CONTAINER="${BEACON_SMOKE_CONTAINER:-beacon-package-smoke}"+cleanup() { docker rm -f "$CONTAINER" >/dev/null 2>&1 || true; }+trap cleanup EXIT INT TERM+cleanup++case "$FORMAT" in+ deb) IMAGE=beacon-package-smoke-deb+ BASE=ubuntu:24.04+ INSTALL_PKGS="systemd systemd-sysv dbus curl ca-certificates iproute2"+ PKGMGR_INSTALL="apt-get install -y -qq /var/tmp/beacon.deb" ;;+ rpm) IMAGE=beacon-package-smoke-rpm+ BASE=fedora:40+ INSTALL_PKGS="systemd dbus curl ca-certificates iproute"+ PKGMGR_INSTALL="dnf install -y -q /var/tmp/beacon.rpm" ;;+ *) echo "unsupported format $FORMAT" >&2; exit 1 ;;+esac++echo "building $IMAGE ($ARCH, $FORMAT)"+if [ "$FORMAT" = deb ]; then+ docker build -q -t "$IMAGE" - >/dev/null <<DOCKERFILE+FROM $BASE+RUN apt-get update -qq && apt-get install -y -qq $INSTALL_PKGS >/dev/null+STOPSIGNAL SIGRTMIN+3+CMD ["/sbin/init"]+DOCKERFILE+else+ docker build -q -t "$IMAGE" - >/dev/null <<DOCKERFILE+FROM $BASE+RUN dnf install -y -q $INSTALL_PKGS >/dev/null+STOPSIGNAL SIGRTMIN+3+CMD ["/sbin/init"]+DOCKERFILE+fi++echo "starting systemd container"+docker run -d --name "$CONTAINER" --privileged --cgroupns=host \+ -v /sys/fs/cgroup:/sys/fs/cgroup:rw --tmpfs /run --tmpfs /run/lock \+ "$IMAGE" >/dev/null++i=0+while [ "$i" -lt 30 ]; do+ state="$(docker exec "$CONTAINER" systemctl is-system-running 2>/dev/null || true)"+ case "$state" in running|degraded) break ;; esac+ i=$((i+1)); sleep 1+done+pid1="$(docker exec "$CONTAINER" cat /proc/1/comm 2>/dev/null || true)"+[ "$pid1" = systemd ] || { echo "PID 1 is $pid1, not systemd" >&2; exit 1; }+echo "ok: systemd is PID 1"++# The whole user-facing action: install the package. Nothing else.+#+# Two details that are load-bearing. The extension matters because both package managers dispatch+# on it. And the destination must be /var/tmp, not /tmp: Fedora's systemd enables tmp.mount, which+# mounts a tmpfs over /tmp once PID 1 starts -- so a file copied to /tmp before that is shadowed+# and dnf reports it as unopenable. Ubuntu does not do this, which is why only the rpm lane hit it.+docker cp "$PKG" "$CONTAINER":/var/tmp/beacon."$FORMAT" >/dev/null+if ! docker exec "$CONTAINER" sh -c "$PKGMGR_INSTALL" >/tmp/beacon-pkg-install.log 2>&1; then+ echo "package install failed:" >&2+ tail -30 /tmp/beacon-pkg-install.log >&2+ exit 1+fi+echo "ok: package installed"++# Everything below must be true without any further user action.+unit_state="$(docker exec "$CONTAINER" systemctl is-active beacon-collector.service 2>/dev/null || true)"+[ "$unit_state" = active ] || {+ echo "collector unit is $unit_state, not active" >&2+ docker exec "$CONTAINER" systemctl status beacon-collector.service --no-pager >&2 || true+ docker exec "$CONTAINER" journalctl -u beacon-collector.service --no-pager -n 40 >&2 || true+ exit 1+}+echo "ok: collector service is active straight after install"++enabled="$(docker exec "$CONTAINER" systemctl is-enabled beacon-collector.service 2>/dev/null || true)"+[ "$enabled" = enabled ] || { echo "unit is $enabled, so it would not survive reboot" >&2; exit 1; }+echo "ok: unit is enabled, so it survives reboot"++for f in /etc/beacon/endpoint/config.json /etc/beacon/endpoint/otelcol.yaml; do+ docker exec "$CONTAINER" test -f "$f" || { echo "missing $f" >&2; exit 1; }+done+echo "ok: system config written to /etc/beacon/endpoint"++# The two commands the docs tell a new user to run. Both must report healthy with no manual setup.+if ! docker exec "$CONTAINER" /opt/beacon/bin/beacon endpoint status --system --json >/tmp/beacon-status.json 2>&1; then+ echo "endpoint status failed:" >&2; cat /tmp/beacon-status.json >&2; exit 1+fi+python3 - <<'PY' || exit 1+import json, sys+s = json.load(open('/tmp/beacon-status.json'))+svc = s.get('service', {})+if svc.get('kind') != 'systemd':+ print(f" service.kind = {svc.get('kind')!r}, want systemd", file=sys.stderr); sys.exit(1)+if not svc.get('running'):+ print(f" service not running: {svc.get('message')}", file=sys.stderr); sys.exit(1)+print("ok: status reports a running systemd service")+PY++docker exec "$CONTAINER" /opt/beacon/bin/beacon endpoint doctor --system >/tmp/beacon-doctor.log 2>&1 || true+if grep -qiE "^fail|\[fail\]" /tmp/beacon-doctor.log; then+ echo "doctor reported failures:" >&2; cat /tmp/beacon-doctor.log >&2; exit 1+fi+echo "ok: doctor reports no failures"++# Removal must stop the service while the binaries it points at still exist, and must not destroy+# collected telemetry.+case "$FORMAT" in+ deb) docker exec "$CONTAINER" apt-get remove -y -qq beacon >/dev/null 2>&1 ;;+ rpm) docker exec "$CONTAINER" dnf remove -y -q beacon >/dev/null 2>&1 ;;+esac+after="$(docker exec "$CONTAINER" systemctl is-active beacon-collector.service 2>/dev/null || true)"+[ "$after" != active ] || { echo "collector still active after package removal" >&2; exit 1; }+echo "ok: removal stopped the service"++if ! docker exec "$CONTAINER" test -f /etc/beacon/endpoint/config.json; then+ echo "removal deleted the config; only a purge should do that" >&2+ exit 1+fi+echo "ok: removal kept config and logs (purge removes them)"++echo+echo "package smoke test passed ($FORMAT/$ARCH)"diff --git a/packaging/linux/uninstall-endpoint.sh b/packaging/linux/uninstall-endpoint.shnew file mode 100755index 00000000..437e660e--- /dev/null+++ b/packaging/linux/uninstall-endpoint.sh@@ -0,0 +1,24 @@+#!/bin/sh+# Removes the Beacon endpoint installed in system mode.+#+# Mirrors packaging/macos/uninstall-endpoint.sh. Called by the .deb/.rpm removal scripts, where+# the defaults matter: a package *removal* keeps logs and config so an operator does not lose+# collected telemetry by accident, while a purge removes everything.+set -eu++if [ -z "${BEACON_BIN:-}" ]; then+ if [ -x "/opt/beacon/bin/beacon" ]; then+ BEACON_BIN="/opt/beacon/bin/beacon"+ else+ BEACON_BIN="beacon"+ fi+fi++BEACON_KEEP_LOGS="${BEACON_KEEP_LOGS:-${1:-0}}"+BEACON_KEEP_CONFIG="${BEACON_KEEP_CONFIG:-${2:-0}}"++set -- endpoint uninstall --system+[ "$BEACON_KEEP_LOGS" = "1" ] && set -- "$@" --keep-logs+[ "$BEACON_KEEP_CONFIG" = "1" ] && set -- "$@" --keep-config++exec "$BEACON_BIN" "$@"