Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build-runner-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
curl -fsSL "${URL}" | tar xz -C /tmp/
cp "/tmp/boxlite-c-v${VERSION}-linux-x64-gnu/lib/libboxlite.a" sdks/go/libboxlite.a

- name: Smoke-test libboxlite ABI for Go SDK
run: bash scripts/build/check-libboxlite-abi.sh sdks/go/libboxlite.a

- name: Rewrite go.work for minimal modules
run: |
printf 'go 1.25.4\n\nuse (\n\t./runner\n\t./daemon\n\t./common-go\n\t./api-client-go\n\t./libs/computer-use\n\t../sdks/go\n)\n' > apps/go.work
Expand Down
7 changes: 7 additions & 0 deletions make/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ dist\:go:
@echo "📦 Building Go SDK (release)..."
@cargo build --release -p boxlite-c
@bash $(SCRIPT_DIR)/build/fix-go-symbols.sh target/release/libboxlite.a
@bash $(SCRIPT_DIR)/build/check-libboxlite-abi.sh target/release/libboxlite.a
@cp target/release/libboxlite.a sdks/go/libboxlite.a
@go clean -cache
@echo "✅ Go SDK static library staged at sdks/go/libboxlite.a"
@echo "✅ Go SDK release built"

dist\:runner:
@bash $(SCRIPT_DIR)/build/build-runner-binary.sh
1 change: 1 addition & 0 deletions make/help.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ help:
@echo " make dist:c - Build C SDK release and stage to sdks/c/dist/"
@echo " make dist:node - Build npm package with napi-rs"
@echo " make dist:go - Build Go SDK release"
@echo " make dist:runner - Build local runner release artifact without deploying"
@echo ""
@echo "Platform: $$(uname) ($$(uname -m))"
@echo ""
67 changes: 67 additions & 0 deletions scripts/build/build-runner-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Build a local Linux amd64 runner release artifact without deploying it.

set -euo pipefail

SCRIPT_BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_DIR="$(cd "$SCRIPT_BUILD_DIR/.." && pwd)"
source "$SCRIPT_DIR/common.sh"

REPO_ROOT="$PROJECT_ROOT"
VERSION="${VERSION:-$(grep -m 1 '^version' "$REPO_ROOT/Cargo.toml" | sed -E 's/^version *= *"([^"]+)".*/\1/')}"
COMMIT="${COMMIT:-$(git -C "$REPO_ROOT" rev-parse --short HEAD)}"
OUTPUT_DIR="${OUTPUT_DIR:-$REPO_ROOT/dist/runner-release}"
RUNNER_BIN="$OUTPUT_DIR/boxlite-runner"
RUNNER_TARBALL="$OUTPUT_DIR/boxlite-runner-v${VERSION}-linux-amd64-${COMMIT}.tar.gz"

if [[ -z "$VERSION" ]]; then
print_error "Could not read version from $REPO_ROOT/Cargo.toml"
exit 1
fi

if [[ "$(detect_os)" != "linux" ]]; then
print_error "Runner release artifacts must be built on Linux because the binary uses cgo"
exit 1
fi

require_command git "Install git"
require_command go "Install Go"
require_command tar "Install tar"
require_command sha256sum "Install coreutils"
Comment on lines +27 to +30

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add an explicit make prerequisite check.

Line 38 invokes make, but make is not validated in the dependency checks. On minimal hosts this fails with a generic command not found instead of a guided error.

Suggested patch
 require_command git "Install git"
+require_command make "Install GNU Make"
 require_command go "Install Go"
 require_command tar "Install tar"
 require_command sha256sum "Install coreutils"

Also applies to: 38-38

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build/build-runner-binary.sh` around lines 27 - 30, The make command
is invoked on line 38 but is not validated in the prerequisite dependency checks
(lines 27-30). Add a require_command call for make in the same pattern as the
existing require_command calls for git, go, tar, and sha256sum to ensure users
receive a guided error message if make is not installed rather than a generic
command not found error.


if [[ "${SKIP_SUBMODULE_UPDATE:-0}" != "1" ]]; then
print_section "Updating submodules"
git -C "$REPO_ROOT" submodule update --init --recursive
fi

print_section "Building and validating Go SDK static library"
make -C "$REPO_ROOT" dist:go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate dist:runner to amd64 before staging libboxlite

On Linux arm64 or any non-amd64 host, this make dist:go invocation builds and smoke-tests sdks/go/libboxlite.a for the host architecture, but the script later forces the cgo runner build with GOARCH=amd64 (go help environment confirms GOARCH is the target architecture). The ABI probe also runs natively, so it can pass while the subsequent amd64 cgo link consumes an arm64 archive and fails; either reject non-amd64 hosts here or build the C archive for the same target as the runner.

Useful? React with 👍 / 👎.

bash "$SCRIPT_BUILD_DIR/check-libboxlite-abi.sh" "$REPO_ROOT/sdks/go/libboxlite.a"

print_section "Building embedded daemon assets"
cd "$REPO_ROOT/apps"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-ldflags "-X github.com/boxlite-ai/daemon/internal.Version=${VERSION}" \
-o "$REPO_ROOT/apps/runner/pkg/daemon/static/daemon-amd64" \
./daemon/cmd/daemon/

CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build \
-o "$REPO_ROOT/apps/runner/pkg/daemon/static/boxlite-computer-use" \
./libs/computer-use/

print_section "Building runner"
mkdir -p "$OUTPUT_DIR"
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build \
-ldflags "-X github.com/boxlite-ai/runner/internal.Version=${VERSION}" \
-o "$RUNNER_BIN" \
./runner/cmd/runner/

tar -C "$OUTPUT_DIR" -czf "$RUNNER_TARBALL" "$(basename "$RUNNER_BIN")"

print_success "Runner artifact built"
echo "binary: $RUNNER_BIN"
echo "tarball: $RUNNER_TARBALL"
sha256sum "$RUNNER_BIN" "$RUNNER_TARBALL"
87 changes: 87 additions & 0 deletions scripts/build/check-libboxlite-abi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
# Smoke-test the C ABI used by the Go SDK prebuilt static library.

set -euo pipefail

SCRIPT_BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_DIR="$(cd "$SCRIPT_BUILD_DIR/.." && pwd)"
source "$SCRIPT_DIR/common.sh"

LIB="${1:-target/release/libboxlite.a}"
REPO_ROOT="$PROJECT_ROOT"

if [[ "$LIB" != /* ]]; then
LIB="$REPO_ROOT/$LIB"
fi

if [[ ! -f "$LIB" ]]; then
print_error "Library not found: $LIB"
exit 1
fi

require_command cc "Install a C compiler"

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

PROBE_C="$TMP_DIR/check-libboxlite-abi.c"
PROBE_BIN="$TMP_DIR/check-libboxlite-abi"

cat > "$PROBE_C" <<'C'
#include "boxlite.h"
#include <stdio.h>

int main(void) {
CBoxliteOptions *opts = NULL;
CBoxliteError err = {0};

enum BoxliteErrorCode new_code = boxlite_options_new(
"ghcr.io/boxlite-ai/boxlite-agent-base:latest",
&opts,
&err
);
enum BoxliteErrorCode port_code = boxlite_options_add_port(
opts,
33689,
2280,
BoxlitePortProtocolTcp,
NULL
);

printf("new=%d add_port=%d\n", (int)new_code, (int)port_code);
if (opts != NULL) {
boxlite_options_free(opts);
}

return (new_code == Ok && port_code == Ok) ? 0 : 1;
}
C

OS="$(detect_os)"
case "$OS" in
linux)
LINK_FLAGS=(-lresolv -lpthread -ldl -lrt -lm)
;;
macos)
LINK_FLAGS=(-framework CoreFoundation -framework Security -framework IOKit -framework Hypervisor -framework vmnet -lresolv)
;;
*)
print_error "Unsupported platform: $(uname -s)"
exit 1
;;
esac

cc -I"$REPO_ROOT/sdks/c/include" "$PROBE_C" "$LIB" "${LINK_FLAGS[@]}" -o "$PROBE_BIN"

set +e
OUTPUT="$("$PROBE_BIN" 2>&1)"
STATUS=$?
set -e
echo "$OUTPUT"

if [[ "$STATUS" -ne 0 || "$OUTPUT" != "new=0 add_port=0" ]]; then
print_error "libboxlite ABI smoke check failed for $LIB"
exit 1
fi

print_success "libboxlite ABI smoke check passed for $LIB"
3 changes: 3 additions & 0 deletions scripts/deploy/runner-update-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# scripts/deploy/runner-update-binary.sh 0.9.5 # explicit version
# AWS_REGION=us-west-2 scripts/deploy/runner-update-binary.sh
# STAGE=production scripts/deploy/runner-update-binary.sh
#
# For unreleased main builds, use `make dist:runner` first to create a local
# artifact. This script intentionally downloads published GitHub release assets.

set -euo pipefail

Expand Down
Loading