mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 15:10:00 +08:00
Build the SDK with Headroom's patched esbuild release inside the bundler's supported dependency range. Headroom already overrides esbuild to the 0.28 series as part of dependency-CVE remediation ([#1509](https://github.com/headroomlabs-ai/headroom/pull/1509)); tsup 8.5.1 declares ^0.27.0, so that combination relies on an out-of-range override. Tsup 9 declares ^0.28.2. Upgrade the bundler and raise the override floor from ^0.28.1 to ^0.28.2 so the selected secure-build inputs agree with the upstream-supported range. The original tsup 9 lock still selected esbuild 0.28.1 through the override. This maintainer follow-up corrects that mismatch, regenerates the lock and documents the actual source-build Node requirement. It does not claim that 0.28.1 introduces a new advisory or that the old bundler's emitted SDK was demonstrated broken. ## Dependency assessment - **Why tsup/version:** existing ESM/CJS/declaration builder; version 9 provides the upstream-supported esbuild 0.28 build combination needed by the existing security override. This avoids introducing a new bundler or relying indefinitely on tsup 8's incompatible declared dependency range. [Official v9 changes](https://github.com/egoist/tsup/releases/tag/v9.0.0). - **Maintenance/security:** tsup's published 9.0.0 release/source and installed manifest were reviewed, including esbuild/chokidar upgrades, the debug-to-obug change, and the Node floor. Security expectations are evaluated on the resolved dependency tree, not inferred from the major number. Fresh Windows and Linux audits report zero vulnerabilities; this does not assert a clean history for every upstream project. - **Build/runtime boundary:** tsup 9 requires `^22.18.0 || ^24.11.0 || >=26.0.0`. The source-build README now recommends Node 24 LTS >=24.11 and documents the alternatives. The published SDK's Node >=18 engines field and optional peer requirements are unchanged. Built ESM/CJS entrypoints load and construct the SDK client on Node 18.20.8; current Vercel peers have their own higher runtime floor, qualified separately on Node 22. - **Transitive/native/install surface:** the lock adds Rollup's optional Linux-x64 GNU LZMA binding and Android-x64 parser binding. It removes debug, ms, source-map and a nested tinyexec entry while updating the bundler's declared toolchain. No new install-script flag is introduced. Existing esbuild/Rollup platform-native components and installation scripts remain development inputs. The Linux LZMA package is a legitimate Rollup optional dependency, not an unreferenced lock entry. It was installed and resolvable in the Linux qualification; its compression functions and Android bindings were not independently exercised. Fresh installs with scripts enabled and actual builds were run on Windows x64 and Linux x64 GNU. No build tooling/native binary is added to the SDK's published runtime dependency list. - **Network surface:** npm registry/package downloads and any existing build-tool setup behavior remain install-time network surfaces. Normal SDK/provider HTTP behavior is unchanged; the proof uses an isolated local proxy/provider fixture and no real vendor credential. No release or production rollout is performed. ## Real behavior proof Windows/Node 22.22.0 and Linux/Debian bookworm/Node 24.22.2, with the resolved tsup 9.0.0 and esbuild 0.28.2. The Linux run copies the SDK source into an ephemeral container, keeping its install/build separate from the Windows tree. From `sdk/typescript`, on each environment: ```bash npm ci --ignore-scripts=false --no-audit --no-fund npm run typecheck npm test -- --reporter=dot npm run build npm audit --audit-level=low ``` Both report **406 tests passed, 33 skipped**, no type errors, successful ESM/CJS/declaration builds, and zero audit findings. Linux resolves `@napi-rs/lzma-linux-x64-gnu` and loads Rollup 4.67.2. These are fresh installs with scripts enabled, rather than relying only on a scripts-disabled install. Against the Windows-built artifacts, `python scripts/verify_sdk_provider_peers.py` runs the real Headroom HTTP compression path (isolated temporary state, stateless mode, no subscription tracking/upstream discovery) and actual provider/native SDK clients with loopback provider responses. It verifies final JSON text preservation, per-request async credential resolution, and native chat completion through the generated adapters. Observed exit 0 with four `/v1/compress` responses of 200. The local run reused an existing Headroom native extension and does not claim a fresh local Rust build or live model inference. From `sdk/typescript`, `npm exec --yes --package=node@18.20.8 -- node ../../scripts/verify_sdk_dist_compat.mjs .` reports that the built ESM and CJS SDK entrypoints load and construct the client. This tests the core entrypoint boundary, not all optional provider peers or every SDK call on Node 18. `git diff --check` and the new Node proof's syntax check pass. The branch is synchronized with main, including the already-qualified dependency/security updates. After main gained the native Anthropic 1.3 update, the SDK lock was combined again without dropping that update or any of the six provider-group targets. The final tree retains tsup 9.0.0, esbuild 0.28.2 and native Anthropic 1.3.0, preserving unrelated platform metadata. Fresh scripts-enabled install, 406 tests/33 skips, types/build/audit and Node 18 entrypoint loading pass again on Windows. Both `verify_sdk_provider_peers.py` (four compression HTTP calls) and `verify_anthropic_peer.py` (native thinking/cache/tool/system/metadata preservation) also pass against these newly built artifacts. The earlier Linux qualification used the same bundler/esbuild graph before that native-peer merge; final-head hosted platform CI supplies the combined-tree platform coverage. Untested: other operating systems/architectures, Android or musl native bindings, LZMA compression behavior, watch-mode filesystem events, live vendor models/credentials, streaming, production publishing, and the 33 skipped tests. Hosted CI must qualify the current head. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
16 lines
747 B
JavaScript
16 lines
747 B
JavaScript
import assert from 'node:assert/strict';
|
|
import { createRequire } from 'node:module';
|
|
import path from 'node:path';
|
|
import { pathToFileURL } from 'node:url';
|
|
const root = path.resolve(process.argv[2]);
|
|
const require = createRequire(import.meta.url);
|
|
const cjs = require(path.join(root, 'dist/index.cjs'));
|
|
const esm = await import(pathToFileURL(path.join(root, 'dist/index.js')));
|
|
for (const api of [cjs, esm]) {
|
|
assert.equal(typeof api.HeadroomClient, 'function');
|
|
assert.equal(typeof api.compress, 'function');
|
|
const client = new api.HeadroomClient({ baseUrl: 'http://127.0.0.1:9' });
|
|
assert.equal(typeof client.compress, 'function');
|
|
}
|
|
console.log(process.version + ': built ESM and CJS SDK entrypoints load and construct the client');
|