From 3015e11fd7c144339791ff4fc8f56bb053ffe1f6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 27 Jan 2026 14:58:01 +0000 Subject: [PATCH 1/5] fix: stabilize install smoke against clawdbot installer --- .github/workflows/install-smoke.yml | 2 +- scripts/docker/install-sh-nonroot/run.sh | 39 ++++++++++++---- scripts/docker/install-sh-smoke/run.sh | 58 ++++++++++++++++-------- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/.github/workflows/install-smoke.yml b/.github/workflows/install-smoke.yml index 16eba4eed..0347c7810 100644 --- a/.github/workflows/install-smoke.yml +++ b/.github/workflows/install-smoke.yml @@ -37,5 +37,5 @@ jobs: CLAWDBOT_NO_ONBOARD: "1" CLAWDBOT_INSTALL_SMOKE_SKIP_CLI: "1" CLAWDBOT_INSTALL_SMOKE_SKIP_NONROOT: ${{ github.event_name == 'pull_request' && '1' || '0' }} - CLAWDBOT_INSTALL_SMOKE_PREVIOUS: "2026.1.11-4" + CLAWDBOT_INSTALL_SMOKE_SKIP_PREVIOUS: "1" run: pnpm test:install:smoke diff --git a/scripts/docker/install-sh-nonroot/run.sh b/scripts/docker/install-sh-nonroot/run.sh index a689498e0..58a8fc3e7 100644 --- a/scripts/docker/install-sh-nonroot/run.sh +++ b/scripts/docker/install-sh-nonroot/run.sh @@ -2,6 +2,16 @@ set -euo pipefail INSTALL_URL="${CLAWDBOT_INSTALL_URL:-https://molt.bot/install.sh}" +DEFAULT_PACKAGE="moltbot" +if [[ -z "${CLAWDBOT_INSTALL_PACKAGE:-}" && "$INSTALL_URL" == *"clawd.bot"* ]]; then + DEFAULT_PACKAGE="clawdbot" +fi +PACKAGE_NAME="${CLAWDBOT_INSTALL_PACKAGE:-$DEFAULT_PACKAGE}" +if [[ "$PACKAGE_NAME" == "moltbot" ]]; then + ALT_PACKAGE_NAME="clawdbot" +else + ALT_PACKAGE_NAME="moltbot" +fi echo "==> Pre-flight: ensure git absent" if command -v git >/dev/null; then @@ -18,26 +28,39 @@ export PATH="$HOME/.npm-global/bin:$PATH" echo "==> Verify git installed" command -v git >/dev/null -echo "==> Verify moltbot installed" EXPECTED_VERSION="${CLAWDBOT_INSTALL_EXPECT_VERSION:-}" if [[ -n "$EXPECTED_VERSION" ]]; then LATEST_VERSION="$EXPECTED_VERSION" else - LATEST_VERSION="$(npm view moltbot version)" + LATEST_VERSION="$(npm view "$PACKAGE_NAME" version)" fi -CMD_PATH="$(command -v moltbot || true)" -if [[ -z "$CMD_PATH" && -x "$HOME/.npm-global/bin/moltbot" ]]; then - CMD_PATH="$HOME/.npm-global/bin/moltbot" +CLI_NAME="$PACKAGE_NAME" +CMD_PATH="$(command -v "$CLI_NAME" || true)" +if [[ -z "$CMD_PATH" ]]; then + CLI_NAME="$ALT_PACKAGE_NAME" + CMD_PATH="$(command -v "$CLI_NAME" || true)" +fi +if [[ -z "$CMD_PATH" && -x "$HOME/.npm-global/bin/$PACKAGE_NAME" ]]; then + CLI_NAME="$PACKAGE_NAME" + CMD_PATH="$HOME/.npm-global/bin/$PACKAGE_NAME" +fi +if [[ -z "$CMD_PATH" && -x "$HOME/.npm-global/bin/$ALT_PACKAGE_NAME" ]]; then + CLI_NAME="$ALT_PACKAGE_NAME" + CMD_PATH="$HOME/.npm-global/bin/$ALT_PACKAGE_NAME" fi if [[ -z "$CMD_PATH" ]]; then - echo "moltbot not on PATH" >&2 + echo "Neither $PACKAGE_NAME nor $ALT_PACKAGE_NAME is on PATH" >&2 exit 1 fi +if [[ -z "$EXPECTED_VERSION" && "$CLI_NAME" != "$PACKAGE_NAME" ]]; then + LATEST_VERSION="$(npm view "$CLI_NAME" version)" +fi +echo "==> Verify CLI installed: $CLI_NAME" INSTALLED_VERSION="$("$CMD_PATH" --version 2>/dev/null | head -n 1 | tr -d '\r')" -echo "installed=$INSTALLED_VERSION expected=$LATEST_VERSION" +echo "cli=$CLI_NAME installed=$INSTALLED_VERSION expected=$LATEST_VERSION" if [[ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]]; then - echo "ERROR: expected moltbot@$LATEST_VERSION, got @$INSTALLED_VERSION" >&2 + echo "ERROR: expected ${CLI_NAME}@${LATEST_VERSION}, got ${CLI_NAME}@${INSTALLED_VERSION}" >&2 exit 1 fi diff --git a/scripts/docker/install-sh-smoke/run.sh b/scripts/docker/install-sh-smoke/run.sh index 9c8870b2b..09a597de8 100755 --- a/scripts/docker/install-sh-smoke/run.sh +++ b/scripts/docker/install-sh-smoke/run.sh @@ -4,15 +4,26 @@ set -euo pipefail INSTALL_URL="${CLAWDBOT_INSTALL_URL:-https://molt.bot/install.sh}" SMOKE_PREVIOUS_VERSION="${CLAWDBOT_INSTALL_SMOKE_PREVIOUS:-}" SKIP_PREVIOUS="${CLAWDBOT_INSTALL_SMOKE_SKIP_PREVIOUS:-0}" +DEFAULT_PACKAGE="moltbot" +if [[ -z "${CLAWDBOT_INSTALL_PACKAGE:-}" && "$INSTALL_URL" == *"clawd.bot"* ]]; then + DEFAULT_PACKAGE="clawdbot" +fi +PACKAGE_NAME="${CLAWDBOT_INSTALL_PACKAGE:-$DEFAULT_PACKAGE}" +if [[ "$PACKAGE_NAME" == "moltbot" ]]; then + ALT_PACKAGE_NAME="clawdbot" +else + ALT_PACKAGE_NAME="moltbot" +fi echo "==> Resolve npm versions" +LATEST_VERSION="$(npm view "$PACKAGE_NAME" version)" if [[ -n "$SMOKE_PREVIOUS_VERSION" ]]; then - LATEST_VERSION="$(npm view moltbot version)" PREVIOUS_VERSION="$SMOKE_PREVIOUS_VERSION" else - VERSIONS_JSON="$(npm view moltbot versions --json)" - versions_line="$(node - <<'NODE' + VERSIONS_JSON="$(npm view "$PACKAGE_NAME" versions --json)" + PREVIOUS_VERSION="$(VERSIONS_JSON="$VERSIONS_JSON" LATEST_VERSION="$LATEST_VERSION" node - <<'NODE' const raw = process.env.VERSIONS_JSON || "[]"; +const latest = process.env.LATEST_VERSION || ""; let versions; try { versions = JSON.parse(raw); @@ -25,41 +36,52 @@ if (!Array.isArray(versions)) { if (versions.length === 0) { process.exit(1); } -const latest = versions[versions.length - 1]; -const previous = versions.length >= 2 ? versions[versions.length - 2] : latest; -process.stdout.write(`${latest} ${previous}`); +const latestIndex = latest ? versions.lastIndexOf(latest) : -1; +if (latestIndex > 0) { + process.stdout.write(String(versions[latestIndex - 1])); + process.exit(0); +} +process.stdout.write(String(latest || versions[versions.length - 1])); NODE )" - LATEST_VERSION="${versions_line%% *}" - PREVIOUS_VERSION="${versions_line#* }" fi -if [[ -n "${CLAWDBOT_INSTALL_LATEST_OUT:-}" ]]; then - printf "%s" "$LATEST_VERSION" > "$CLAWDBOT_INSTALL_LATEST_OUT" -fi - -echo "latest=$LATEST_VERSION previous=$PREVIOUS_VERSION" +echo "package=$PACKAGE_NAME latest=$LATEST_VERSION previous=$PREVIOUS_VERSION" if [[ "$SKIP_PREVIOUS" == "1" ]]; then echo "==> Skip preinstall previous (CLAWDBOT_INSTALL_SMOKE_SKIP_PREVIOUS=1)" else echo "==> Preinstall previous (forces installer upgrade path)" - npm install -g "moltbot@${PREVIOUS_VERSION}" + npm install -g "${PACKAGE_NAME}@${PREVIOUS_VERSION}" fi echo "==> Run official installer one-liner" curl -fsSL "$INSTALL_URL" | bash echo "==> Verify installed version" -INSTALLED_VERSION="$(moltbot --version 2>/dev/null | head -n 1 | tr -d '\r')" -echo "installed=$INSTALLED_VERSION expected=$LATEST_VERSION" +CLI_NAME="$PACKAGE_NAME" +if ! command -v "$CLI_NAME" >/dev/null 2>&1; then + if command -v "$ALT_PACKAGE_NAME" >/dev/null 2>&1; then + CLI_NAME="$ALT_PACKAGE_NAME" + LATEST_VERSION="$(npm view "$CLI_NAME" version)" + echo "==> Detected alternate CLI: $CLI_NAME" + else + echo "ERROR: neither $PACKAGE_NAME nor $ALT_PACKAGE_NAME is on PATH" >&2 + exit 1 + fi +fi +if [[ -n "${CLAWDBOT_INSTALL_LATEST_OUT:-}" ]]; then + printf "%s" "$LATEST_VERSION" > "$CLAWDBOT_INSTALL_LATEST_OUT" +fi +INSTALLED_VERSION="$("$CLI_NAME" --version 2>/dev/null | head -n 1 | tr -d '\r')" +echo "cli=$CLI_NAME installed=$INSTALLED_VERSION expected=$LATEST_VERSION" if [[ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]]; then - echo "ERROR: expected moltbot@$LATEST_VERSION, got moltbot@$INSTALLED_VERSION" >&2 + echo "ERROR: expected ${CLI_NAME}@${LATEST_VERSION}, got ${CLI_NAME}@${INSTALLED_VERSION}" >&2 exit 1 fi echo "==> Sanity: CLI runs" -moltbot --help >/dev/null +"$CLI_NAME" --help >/dev/null echo "OK" From 0594ccf92afea316d8fe590ed5cf9ec580b25ba5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 27 Jan 2026 15:01:57 +0000 Subject: [PATCH 2/5] fix: skip a2ui bundling when sources are excluded --- scripts/bundle-a2ui.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/bundle-a2ui.sh b/scripts/bundle-a2ui.sh index a1cf7ff2b..304002324 100755 --- a/scripts/bundle-a2ui.sh +++ b/scripts/bundle-a2ui.sh @@ -10,12 +10,21 @@ trap on_error ERR ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" HASH_FILE="$ROOT_DIR/src/canvas-host/a2ui/.bundle.hash" OUTPUT_FILE="$ROOT_DIR/src/canvas-host/a2ui/a2ui.bundle.js" +A2UI_RENDERER_DIR="$ROOT_DIR/vendor/a2ui/renderers/lit" +A2UI_APP_DIR="$ROOT_DIR/apps/shared/ClawdbotKit/Tools/CanvasA2UI" + +# Docker builds exclude vendor/apps via .dockerignore. +# In that environment we must keep the prebuilt bundle. +if [[ ! -d "$A2UI_RENDERER_DIR" || ! -d "$A2UI_APP_DIR" ]]; then + echo "A2UI sources missing; keeping prebuilt bundle." + exit 0 +fi INPUT_PATHS=( "$ROOT_DIR/package.json" "$ROOT_DIR/pnpm-lock.yaml" - "$ROOT_DIR/vendor/a2ui/renderers/lit" - "$ROOT_DIR/apps/shared/ClawdbotKit/Tools/CanvasA2UI" + "$A2UI_RENDERER_DIR" + "$A2UI_APP_DIR" ) collect_files() { @@ -46,7 +55,7 @@ if [[ -f "$HASH_FILE" ]]; then fi fi -pnpm -s exec tsc -p vendor/a2ui/renderers/lit/tsconfig.json -rolldown -c apps/shared/ClawdbotKit/Tools/CanvasA2UI/rolldown.config.mjs +pnpm -s exec tsc -p "$A2UI_RENDERER_DIR/tsconfig.json" +rolldown -c "$A2UI_APP_DIR/rolldown.config.mjs" echo "$current_hash" > "$HASH_FILE" From e4518d227118e053baca48688ea2477565dfa246 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 27 Jan 2026 15:16:20 +0000 Subject: [PATCH 3/5] fix: allow docker builds to skip missing a2ui assets --- Dockerfile | 2 +- scripts/canvas-a2ui-copy.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 642cfd612..9c6aa7036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ COPY scripts ./scripts RUN pnpm install --frozen-lockfile COPY . . -RUN pnpm build +RUN CLAWDBOT_A2UI_SKIP_MISSING=1 pnpm build # Force pnpm for UI build (Bun may fail on ARM/Synology architectures) ENV CLAWDBOT_PREFER_PNPM=1 RUN pnpm ui:install diff --git a/scripts/canvas-a2ui-copy.ts b/scripts/canvas-a2ui-copy.ts index b8a80675f..e95be5fdd 100644 --- a/scripts/canvas-a2ui-copy.ts +++ b/scripts/canvas-a2ui-copy.ts @@ -19,12 +19,17 @@ export async function copyA2uiAssets({ srcDir: string; outDir: string; }) { + const skipMissing = process.env.CLAWDBOT_A2UI_SKIP_MISSING === "1"; try { await fs.stat(path.join(srcDir, "index.html")); await fs.stat(path.join(srcDir, "a2ui.bundle.js")); } catch (err) { const message = 'Missing A2UI bundle assets. Run "pnpm canvas:a2ui:bundle" and retry.'; + if (skipMissing) { + console.warn(`${message} Skipping copy (CLAWDBOT_A2UI_SKIP_MISSING=1).`); + return; + } throw new Error(message, { cause: err }); } await fs.mkdir(path.dirname(outDir), { recursive: true }); From 3817e0ce2c04fa16187384038c668dfddc218704 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 27 Jan 2026 15:38:31 +0000 Subject: [PATCH 4/5] fix: bundle a2ui before tests --- .github/workflows/ci.yml | 6 ++--- scripts/bundle-a2ui.sh | 56 +++++++++++++++++++++++++++++----------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cc86bd63..ca4fef2b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: command: pnpm lint - runtime: node task: test - command: pnpm test + command: pnpm canvas:a2ui:bundle && pnpm test - runtime: node task: build command: pnpm build @@ -88,7 +88,7 @@ jobs: command: pnpm format - runtime: bun task: test - command: bunx vitest run + command: pnpm canvas:a2ui:bundle && bunx vitest run - runtime: bun task: build command: bunx tsc -p tsconfig.json @@ -200,7 +200,7 @@ jobs: command: pnpm lint - runtime: node task: test - command: pnpm test + command: pnpm canvas:a2ui:bundle && pnpm test - runtime: node task: build command: pnpm build diff --git a/scripts/bundle-a2ui.sh b/scripts/bundle-a2ui.sh index 304002324..75844ec6d 100755 --- a/scripts/bundle-a2ui.sh +++ b/scripts/bundle-a2ui.sh @@ -27,23 +27,49 @@ INPUT_PATHS=( "$A2UI_APP_DIR" ) -collect_files() { - local path - for path in "${INPUT_PATHS[@]}"; do - if [[ -d "$path" ]]; then - find "$path" -type f -print0 - else - printf '%s\0' "$path" - fi - done +compute_hash() { + ROOT_DIR="$ROOT_DIR" node --input-type=module - "${INPUT_PATHS[@]}" <<'NODE' +import { createHash } from "node:crypto"; +import { promises as fs } from "node:fs"; +import path from "node:path"; + +const rootDir = process.env.ROOT_DIR ?? process.cwd(); +const inputs = process.argv.slice(2); +const files = []; + +async function walk(entryPath) { + const st = await fs.stat(entryPath); + if (st.isDirectory()) { + const entries = await fs.readdir(entryPath); + for (const entry of entries) { + await walk(path.join(entryPath, entry)); + } + return; + } + files.push(entryPath); } -compute_hash() { - collect_files \ - | LC_ALL=C sort -z \ - | xargs -0 shasum -a 256 \ - | shasum -a 256 \ - | awk '{print $1}' +for (const input of inputs) { + await walk(input); +} + +function normalize(p) { + return p.split(path.sep).join("/"); +} + +files.sort((a, b) => normalize(a).localeCompare(normalize(b))); + +const hash = createHash("sha256"); +for (const filePath of files) { + const rel = normalize(path.relative(rootDir, filePath)); + hash.update(rel); + hash.update("\0"); + hash.update(await fs.readFile(filePath)); + hash.update("\0"); +} + +process.stdout.write(hash.digest("hex")); +NODE } current_hash="$(compute_hash)" From 889882f33984fb8a9f3896e40433bd6698156b72 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 27 Jan 2026 15:51:21 +0000 Subject: [PATCH 5/5] fix: cap windows vitest workers in ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca4fef2b7..885d87fcb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,6 +188,7 @@ jobs: runs-on: blacksmith-4vcpu-windows-2025 env: NODE_OPTIONS: --max-old-space-size=4096 + CLAWDBOT_TEST_WORKERS: 1 defaults: run: shell: bash