Skip to content

Migrating from 1.5.x to 1.6.0

TL;DR: Browser consumers need no changes. Node consumers now get a real HTTP server automatically — instead of a crash.

What changed

@dvai-bridge/core 1.6.0 adds a real HTTP server transport for Node and the Electron main process. Browser behaviour — MSW interception — is unchanged. See CHANGELOG.md for the full list.

Browser consumers (React / Vanilla)

No action required. new DVAI({}) still uses MSW in browsers with identical behaviour. dvai.mockUrl and every existing config option keep working.

To read the endpoint in a platform-agnostic way, use the new dvai.baseUrl field — set after initialize():

ts
const dvai = new DVAI({});
await dvai.initialize();
const openai = new OpenAI({ baseURL: dvai.baseUrl, apiKey: "ignored" });

Node / Electron consumers

Before: new DVAI({}) in Node crashed — MSW needs navigator.serviceWorker. Now: it auto-starts an HTTP server on 127.0.0.1:38883, with +1 port fallback up to 16 attempts.

ts
const dvai = new DVAI({ backend: "transformers" });
await dvai.initialize();
// dvai.baseUrl === "http://127.0.0.1:38883/v1"

const openai = new OpenAI({ baseURL: dvai.baseUrl, apiKey: "ignored" });

To keep the old "direct inference only" behaviour — no transport:

ts
new DVAI({ transport: "none" });
// or the still-supported BC form:
new DVAI({ serviceWorkerUrl: "" });

mockUrl under HTTP transport

mockUrl is ignored when the transport is HTTP. Set a custom mockUrl while HTTP is active and you'll get a one-time console warning on initialize(). Use dvai.baseUrl for the real URL at runtime.

Removed: DVAI.getWorker()

The MSW worker is now an implementation detail of the MswTransport class — not exposed directly. If you relied on this method:

  • To get the endpoint URL — use dvai.baseUrl or dvai.getBaseUrl().
  • To check the active transport — use dvai.getActiveTransport().
  • To stop intercepting — use dvai.unload().

New config options

  • transport?: "auto" | "msw" | "http" | "none" — transport selection.
  • httpBasePort?: number — HTTP base port (default 38883).
  • httpMaxPortAttempts?: number — max fallback attempts (default 16).
  • corsOrigin?: string | string[] — CORS origin config for HTTP.

See docs/guide/transports.md for a deep dive.