From 01d473b1a63c39d990434f7b57f78156df5c08c7 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:37:00 +0000 Subject: [PATCH 1/3] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-cli-generator: 0.57.2 --- .github/workflows/ci.yml | 387 ++++++++++++++++++++++++++++++++++ Cargo.lock | 6 +- Cargo.toml | 2 +- livingbrain-sdk/Cargo.toml | 2 +- livingbrain-sdk/src/config.rs | 2 +- livingbrain-types/Cargo.toml | 2 +- 6 files changed, 394 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b28387d..fbb6a0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,3 +45,390 @@ jobs: - name: Test run: cargo test + + # The npm packages take their version from the release tag, while the + # binary reports the version in Cargo.toml. Publishing when they disagree + # ships a package whose --version names a release that isn't on the + # registry, so refuse to publish instead (cargo-dist hard-fails on the + # same mismatch for the GitHub Release). + version: + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v6 + + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Check tag matches crate version + shell: bash + run: | + set -euo pipefail + + TAG_VERSION="${GITHUB_REF_NAME#v}" + CRATE_VERSION=$(cargo metadata --no-deps --format-version 1 \ + | jq -r --arg manifest "${PWD}/Cargo.toml" \ + '.packages[] | select(.manifest_path == $manifest) | .version') + + if [[ -z "${CRATE_VERSION}" ]]; then + echo "::error::Could not determine the crate version from cargo metadata (no package matched ${PWD}/Cargo.toml)." + exit 1 + fi + + if [[ "${TAG_VERSION}" != "${CRATE_VERSION}" ]]; then + echo "::error::Tag ${GITHUB_REF_NAME} publishes version ${TAG_VERSION}, but Cargo.toml is ${CRATE_VERSION}." + echo "::error::The binary would report ${CRATE_VERSION} from --version while the npm packages say ${TAG_VERSION}." + echo "::error::Set the generator's output version to ${TAG_VERSION} and regenerate, or tag v${CRATE_VERSION} instead." + exit 1 + fi + echo "Tag and crate version agree: ${TAG_VERSION}" + + publish: + needs: [check, compile, test, version] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ${{ matrix.runner }} + permissions: + contents: read + id-token: write + strategy: + # Don't cancel sibling matrix jobs on first failure — let every + # platform that can publish do so. Publishing skips versions already + # on the registry, so re-running the failed jobs completes the + # release (the launcher waits for every platform package). + fail-fast: false + matrix: + include: + - rust-target: x86_64-unknown-linux-musl + runner: ubuntu-latest + npm-platform-suffix: linux-x64 + - rust-target: aarch64-unknown-linux-musl + runner: ubuntu-24.04-arm + npm-platform-suffix: linux-arm64 + - rust-target: x86_64-apple-darwin + runner: macos-latest + npm-platform-suffix: darwin-x64 + - rust-target: aarch64-apple-darwin + runner: macos-latest + npm-platform-suffix: darwin-arm64 + - rust-target: x86_64-pc-windows-msvc + runner: windows-latest + npm-platform-suffix: win32-x64 + steps: + - name: Checkout repo + uses: actions/checkout@v6 + + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: ${{ matrix.rust-target }} + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: "lts/Krypton" + registry-url: "https://registry.npmjs.org" + + - name: Install musl build tools + if: contains(matrix.rust-target, '-linux-musl') + run: | + sudo apt-get update + sudo apt-get install -y musl-tools + + # The TLS backend and the keyring backend are selected per target by + # Cargo.toml, so no per-target feature flags are needed here. + # + # musl targets get a C compiler for the C dependencies, but not a + # linker: musl-gcc cannot produce static-pie, so it yields a binary + # that needs /lib/ld-musl-*.so.1 at runtime — which defeats the point + # of a musl build and crashes where that loader is absent. Left alone, + # rustc links the self-contained musl objects statically. + # + # Built with the `dist` profile — the same one cargo-dist uses for the + # GitHub Release — so npm and the Release ship byte-identical binaries + # for a given tag. Building `--release` here meant two channels + # shipping different bytes under one version, which surfaces as an + # unreproducible bug report. + - name: Build release binary + shell: bash + run: | + if [[ "${{ matrix.rust-target }}" == *-linux-musl ]]; then + TARGET_UNDERSCORE=$(echo "${{ matrix.rust-target }}" | tr '-' '_') + export "CC_${TARGET_UNDERSCORE}=musl-gcc" + fi + cargo build --profile dist --target ${{ matrix.rust-target }} + + - name: Package and publish npm platform package + env: + NPM_REGISTRY_URL: "https://registry.npmjs.org" + shell: bash + run: | + set -euo pipefail + + VERSION="${GITHUB_REF_NAME#v}" + PLATFORM_PKG="@living-brain/cli-${{ matrix.npm-platform-suffix }}" + PKG_DIR="npm-pkg/${PLATFORM_PKG}" + mkdir -p "${PKG_DIR}" + + # Locate the compiled binary + BINARY_NAME="livingbrain" + if [[ "${{ matrix.rust-target }}" == *"windows"* ]]; then + BINARY_NAME="livingbrain.exe" + fi + # A custom cargo profile writes to target///, not + # .../release/. + cp "target/${{ matrix.rust-target }}/dist/${BINARY_NAME}" "${PKG_DIR}/" + + # Write platform package.json + cat > "${PKG_DIR}/package.json" <"${log}") || view_status=$? + # npm <= 7 exits 0 with no output for a missing version; npm >= 8 + # fails with E404. Any other failure (network, auth) must stop the + # job rather than be mistaken for "not published". + if [[ "${view_status}" -eq 0 && "${view_out}" == "${version}" ]]; then + echo "::notice::${name}@${version} is already published; skipping." + rm -f "${log}" + return 0 + elif [[ "${view_status}" -eq 0 ]]; then + echo "${name}@${version} is not on the registry yet; publishing." + elif grep -Eq '^npm (ERR!|error) code E404' "${log}"; then + echo "${name}@${version} is not on the registry yet; publishing." + else + cat "${log}" >&2 + echo "::error::Could not check whether ${name}@${version} is already published (npm view exited ${view_status})." + rm -f "${log}" + return 1 + fi + + publish_status=0 + npm publish "$@" 2>&1 | tee "${log}" || publish_status=$? + if [[ "${publish_status}" -ne 0 ]] && grep -q 'EOTP' "${log}"; then + echo "::error::npm publish of ${name}@${version} requires a one-time password (EOTP). Use a granular npm access token with \"Bypass 2FA\" enabled, or configure npm trusted publishing (OIDC) for this package." + fi + rm -f "${log}" + return "${publish_status}" + } + + # Pre-release detection. ANY SemVer pre-release (a "-" after the + # version core) must get a non-latest dist-tag: matching only + # -alpha/-beta let a v1.1.0-rc.1 or -next.1 tag fall through to a + # bare `npm publish`, which moves `latest` to a pre-release for + # every existing installer. The tag is the first dot-separated + # pre-release identifier, stripped to a safe slug, so -rc.1 -> rc + # and -next.1 -> next; an all-numeric or empty identifier falls + # back to "prerelease" because npm rejects a numeric dist-tag. + PRERELEASE="${VERSION#*-}" + if [[ "${VERSION}" == *-* ]]; then + TAG=$(echo "${PRERELEASE%%.*}" | tr -cd '[:alnum:]-') + if [[ -z "${TAG}" || "${TAG}" =~ ^[0-9]+$ ]]; then + TAG=prerelease + fi + echo "Publishing pre-release ${VERSION} with --tag ${TAG}" + npm_publish_once --access public --tag "${TAG}" + else + PKG_NAME=$(node -p "require('./package.json').name") + PKG_VERSION=$(node -p "require('./package.json').version") + CURRENT_LATEST=$(npm view "${PKG_NAME}" dist-tags.latest 2>/dev/null || echo "0.0.0") + if npx -y semver@7.8.1 "${PKG_VERSION}" -r "<${CURRENT_LATEST}" > /dev/null 2>&1; then + echo "Publishing ${PKG_VERSION} with --tag backport (current latest is ${CURRENT_LATEST})" + npm_publish_once --access public --tag backport + else + npm_publish_once --access public + fi + fi + + publish-launcher: + needs: [publish] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout repo + uses: actions/checkout@v6 + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: "lts/Krypton" + registry-url: "https://registry.npmjs.org" + + - name: Publish launcher package + env: + NPM_REGISTRY_URL: "https://registry.npmjs.org" + shell: bash + run: | + set -euo pipefail + + VERSION="${GITHUB_REF_NAME#v}" + PKG_DIR="npm-pkg/launcher" + mkdir -p "${PKG_DIR}" + + BINARY_NAME="livingbrain" + + # Build optionalDependencies map + OPTIONAL_DEPS="" + OPTIONAL_DEPS="${OPTIONAL_DEPS}\"@living-brain/cli-linux-x64\": \"${VERSION}\"," + OPTIONAL_DEPS="${OPTIONAL_DEPS}\"@living-brain/cli-linux-arm64\": \"${VERSION}\"," + OPTIONAL_DEPS="${OPTIONAL_DEPS}\"@living-brain/cli-darwin-x64\": \"${VERSION}\"," + OPTIONAL_DEPS="${OPTIONAL_DEPS}\"@living-brain/cli-darwin-arm64\": \"${VERSION}\"," + OPTIONAL_DEPS="${OPTIONAL_DEPS}\"@living-brain/cli-win32-x64\": \"${VERSION}\"" + + cat > "${PKG_DIR}/package.json" < "${PKG_DIR}/bin/cli.js" <<'LAUNCHER' + #!/usr/bin/env node + "use strict"; + const { execFileSync } = require("child_process"); + const path = require("path"); + const os = require("os"); + + const PLATFORMS = { + "linux-x64": "@living-brain/cli-linux-x64", + "linux-arm64": "@living-brain/cli-linux-arm64", + "darwin-x64": "@living-brain/cli-darwin-x64", + "darwin-arm64": "@living-brain/cli-darwin-arm64", + "win32-x64": "@living-brain/cli-win32-x64", + }; + + const platformKey = os.platform() + "-" + os.arch(); + const pkg = PLATFORMS[platformKey]; + if (!pkg) { + console.error("Unsupported platform: " + platformKey); + process.exit(1); + } + + const binName = os.platform() === "win32" ? "livingbrain.exe" : "livingbrain"; + const binPath = path.join(require.resolve(pkg + "/package.json"), "..", binName); + + try { + execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" }); + } catch (e) { + if (e && typeof e === "object") { + // Propagate the child's exit code; a signal death has no + // numeric status, so report it as 128+signum like a shell does. + if (typeof e.status === "number") { + process.exit(e.status); + } + if (typeof e.signal === "string") { + const SIGNUM = { SIGHUP: 1, SIGINT: 2, SIGQUIT: 3, SIGILL: 4, SIGABRT: 6, SIGFPE: 8, SIGKILL: 9, SIGSEGV: 11, SIGPIPE: 13, SIGALRM: 14, SIGTERM: 15 }; + process.exit(128 + (SIGNUM[e.signal] || 0)); + } + } + throw e; + } + LAUNCHER + + cd "${PKG_DIR}" + # Publishes the package in the current directory unless this exact + # version is already on the registry, so re-running a release after a + # partial failure skips what already shipped instead of failing on it. + npm_publish_once() { + local name version log view_out view_status publish_status + name=$(node -p "require('./package.json').name") + version=$(node -p "require('./package.json').version") + log=$(mktemp) + + view_status=0 + view_out=$(npm view "${name}@${version}" version --registry "${NPM_REGISTRY_URL}" 2>"${log}") || view_status=$? + # npm <= 7 exits 0 with no output for a missing version; npm >= 8 + # fails with E404. Any other failure (network, auth) must stop the + # job rather than be mistaken for "not published". + if [[ "${view_status}" -eq 0 && "${view_out}" == "${version}" ]]; then + echo "::notice::${name}@${version} is already published; skipping." + rm -f "${log}" + return 0 + elif [[ "${view_status}" -eq 0 ]]; then + echo "${name}@${version} is not on the registry yet; publishing." + elif grep -Eq '^npm (ERR!|error) code E404' "${log}"; then + echo "${name}@${version} is not on the registry yet; publishing." + else + cat "${log}" >&2 + echo "::error::Could not check whether ${name}@${version} is already published (npm view exited ${view_status})." + rm -f "${log}" + return 1 + fi + + publish_status=0 + npm publish "$@" 2>&1 | tee "${log}" || publish_status=$? + if [[ "${publish_status}" -ne 0 ]] && grep -q 'EOTP' "${log}"; then + echo "::error::npm publish of ${name}@${version} requires a one-time password (EOTP). Use a granular npm access token with \"Bypass 2FA\" enabled, or configure npm trusted publishing (OIDC) for this package." + fi + rm -f "${log}" + return "${publish_status}" + } + + # Pre-release detection. ANY SemVer pre-release (a "-" after the + # version core) must get a non-latest dist-tag: matching only + # -alpha/-beta let a v1.1.0-rc.1 or -next.1 tag fall through to a + # bare `npm publish`, which moves `latest` to a pre-release for + # every existing installer. The tag is the first dot-separated + # pre-release identifier, stripped to a safe slug, so -rc.1 -> rc + # and -next.1 -> next; an all-numeric or empty identifier falls + # back to "prerelease" because npm rejects a numeric dist-tag. + PRERELEASE="${VERSION#*-}" + if [[ "${VERSION}" == *-* ]]; then + TAG=$(echo "${PRERELEASE%%.*}" | tr -cd '[:alnum:]-') + if [[ -z "${TAG}" || "${TAG}" =~ ^[0-9]+$ ]]; then + TAG=prerelease + fi + echo "Publishing pre-release ${VERSION} with --tag ${TAG}" + npm_publish_once --access public --tag "${TAG}" + else + PKG_NAME=$(node -p "require('./package.json').name") + PKG_VERSION=$(node -p "require('./package.json').version") + CURRENT_LATEST=$(npm view "${PKG_NAME}" dist-tags.latest 2>/dev/null || echo "0.0.0") + if npx -y semver@7.8.1 "${PKG_VERSION}" -r "<${CURRENT_LATEST}" > /dev/null 2>&1; then + echo "Publishing ${PKG_VERSION} with --tag backport (current latest is ${CURRENT_LATEST})" + npm_publish_once --access public --tag backport + else + npm_publish_once --access public + fi + fi diff --git a/Cargo.lock b/Cargo.lock index 3a80f2d..28c3b64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -497,7 +497,7 @@ checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" [[package]] name = "livingbrain-cli" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "base64", @@ -3320,7 +3320,7 @@ checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" [[package]] name = "livingbrain_types" -version = "0.2.3" +version = "0.2.4" dependencies = [ "base64", "chrono", @@ -3332,7 +3332,7 @@ dependencies = [ [[package]] name = "livingbrain_sdk" -version = "0.2.3" +version = "0.2.4" dependencies = [ "bytes", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 990592e..9d3ff90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "livingbrain-cli" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "Command-line interface for the Living Brain API" license = "Apache-2.0" diff --git a/livingbrain-sdk/Cargo.toml b/livingbrain-sdk/Cargo.toml index 9f71fd5..dfc9eb0 100644 --- a/livingbrain-sdk/Cargo.toml +++ b/livingbrain-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "livingbrain_sdk" -version = "0.2.3" +version = "0.2.4" edition = "2021" description = "Rust SDK for livingbrain_sdk generated by Fern" license = "MIT" diff --git a/livingbrain-sdk/src/config.rs b/livingbrain-sdk/src/config.rs index da07aea..41cef4b 100644 --- a/livingbrain-sdk/src/config.rs +++ b/livingbrain-sdk/src/config.rs @@ -40,7 +40,7 @@ impl Default for ClientConfig { custom_headers: HashMap::from([ ("X-Fern-Language".to_string(), "Rust".to_string()), ("X-Fern-SDK-Name".to_string(), "livingbrain_sdk".to_string()), - ("X-Fern-SDK-Version".to_string(), "0.2.3".to_string()), + ("X-Fern-SDK-Version".to_string(), "0.2.4".to_string()), ]), user_agent: "Api Rust SDK".to_string(), reqwest_client: None, diff --git a/livingbrain-types/Cargo.toml b/livingbrain-types/Cargo.toml index afa4a8c..108ecc3 100644 --- a/livingbrain-types/Cargo.toml +++ b/livingbrain-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "livingbrain_types" -version = "0.2.3" +version = "0.2.4" edition = "2021" [lib] From f8915d532e185bcc5c72bd48f1940d707adc2eb7 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:37:01 +0000 Subject: [PATCH 2/3] [fern-replay] advance lockfile --- .fern/replay.lock | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.fern/replay.lock b/.fern/replay.lock index 1a48c88..6d0f509 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -12,5 +12,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-cli-generator: 0.57.2 -current_generation: efcea6986a307daff87726ea608832bee726a1cc + - commit_sha: 392072c035e1b803c503a7673e45980cb38b22d6 + tree_hash: 292b9b88f96163f3449438f932882f5b83c8303c + timestamp: 2026-11-04T15:36:58.193Z + cli_version: unknown + generator_versions: + fernapi/fern-cli-generator: 0.57.2 +current_generation: 392072c035e1b803c503a7673e45980cb38b22d6 patches: [] From ec9336dde9c2209f86b942c70f59742be4c991bc Mon Sep 17 00:00:00 2001 From: ping Date: Wed, 4 Nov 2026 15:50:43 +0000 Subject: [PATCH 3/3] ci: restrict default workflow permissions --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbb6a0d..414e023 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ name: ci on: [push] +permissions: + contents: read + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false