Skip to content

fix(model): make Transformers peer optional - #87

Merged
davideast merged 1 commit into
mainfrom
fix/optional-transformers-peer
Jul 13, 2026
Merged

fix(model): make Transformers peer optional#87
davideast merged 1 commit into
mainfrom
fix/optional-transformers-peer

Conversation

@davideast

Copy link
Copy Markdown
Owner

Makes @huggingface/transformers opt-in so installing the agent for cloud models does not also install the on-device Transformers and ONNX runtimes.

mkdir /tmp/inbrowser-cloud-agent
cd /tmp/inbrowser-cloud-agent
npm init -y
npm install @inbrowser/agent@0.4.2
npm ls @huggingface/transformers onnxruntime-node --all

# The dependency tree is empty because neither package is needed for a
# cloud-backed ModelClient.
# └── (empty)

Risk

There is no source-interface change. The installation contract changes for applications using createEngine: npm no longer supplies @huggingface/transformers automatically, so those applications must declare it directly. This is intentional, documented, and covered by the packed-install smoke test.

The release metadata advances every coordinated workspace package to 0.4.2; the runtime behavior change is confined to @inbrowser/model.

Local inference now declares its runtime explicitly

mkdir /tmp/inbrowser-local-model
cd /tmp/inbrowser-local-model
npm init -y
npm install @inbrowser/model@0.4.2 @huggingface/transformers

createEngine, its presets, and its event interface are unchanged. Only ownership of the Transformers installation moves to the application that uses on-device inference.

A missing local runtime reports the install command

mkdir /tmp/inbrowser-missing-local-runtime
cd /tmp/inbrowser-missing-local-runtime
npm init -y
npm install @inbrowser/model@0.4.2
node --input-type=module -e "
  import { createEngine, smollm2_360m } from '@inbrowser/model';
  await createEngine(smollm2_360m).ensureReady();
"

# Error: Local inference requires the optional peer
# @huggingface/transformers. Install it alongside @inbrowser/model.

The error translation is limited to failure to resolve the peer itself. Missing transitive modules and errors thrown while evaluating Transformers retain their original error and stack.

Implementation notes and verification
  • peerDependenciesMeta marks @huggingface/transformers optional; it remains a peer so local-inference applications control the version.
  • The pack smoke installs all six 0.4.2 tarballs with npm defaults and asserts that neither @huggingface/transformers nor onnxruntime-node appears anywhere in the dependency tree.
  • bun scripts/smoke-pack.ts: 84 checks passed, including packed imports and the missing-peer diagnostic.
  • bun run build: passed for all six packages.
  • bun run check: passed across 427 files.
  • bun test --cwd packages/model: 171 passed; two Claude CLI stdin-fixture tests also fail on main and are unchanged here.

@davideast
davideast merged commit 401f70f into main Jul 13, 2026
1 check passed
@davideast
davideast deleted the fix/optional-transformers-peer branch July 13, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant