npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@oh-my-ai-sdk/code-mode-bun-compat

v0.1.2

Published

Make @ai-sdk/code-mode importable under Bun: a postinstall patcher that swaps its static node:module stripTypeScriptTypes import for a feature-test with an amaro fallback. Self-retiring once Bun ships the API (oven-sh/bun#35517).

Readme

code-mode-bun-compat

Part of Oh mAI SDK, a collection of community extensions for Vercel AI SDK.

Make @ai-sdk/code-mode work under Bun. Two lines of integration, self-retiring when Bun catches up.

Quick start

bun add ai @ai-sdk/code-mode
bun add -d code-mode-bun-compat

Then wire the postinstall (after the add above — a postinstall referencing a bin that isn't installed yet fails the next install with a bare exit 127):

// package.json
{
  "scripts": {
    "postinstall": "code-mode-bun-compat"
  }
}

That's the whole integration. bun install triggers the postinstall, the installed @ai-sdk/code-mode gets patched in place (~50ms, idempotent), and code mode just works under Bun:

import { experimental_runCodeMode } from "@ai-sdk/code-mode";

const result = await experimental_runCodeMode({
  js: "return 6 * 7;",
  tools: myTools,
  options: { executionPolicy: { timeoutMs: 30_000, maxBridgeRequests: 10 } },
});

Without the patch, that import line throws under Bun before any of your code runs.

What you get

  • Reinstalls are handled. Every bun install re-runs the postinstall; already-patched files are detected and skipped. A lockfile change can't silently un-patch you.
  • Node stays unaffected. The shim is a runtime feature-test — on Node it finds the native API immediately, same code path as unpatched. Dual-runtime projects (dev on Bun, CI on Node) need no conditionals.
  • Nothing to unwind later. When Bun ships stripTypeScriptTypes natively (PR #35517 is in progress), the feature-test starts finding the real function and the fallback simply never runs again. Delete the dep at leisure, or don't.
  • Loud failure, never a weird one. If a future @ai-sdk/code-mode restructures its dist files, the patcher exits 1 with UNEXPECTED SHAPE instead of half-patching — your install fails legibly rather than your runtime failing mysteriously.
  • Monorepos: code-mode-bun-compat packages/my-app resolves from a specific workspace; the bare command resolves from cwd. Resolution uses createRequire, so hoisted layouts are handled.

What it actually fixes

Two Bun gaps break @ai-sdk/code-mode today:

  1. node:module has no stripTypeScriptTypes (oven-sh/bun#25058). The Code Mode runtime imports it statically in dist/utils/source-cache.js, so under Bun the import itself dies—even for programs that never feed it TypeScript. The runtime lives in @ai-sdk/code-mode in older releases and its run dependency in newer releases; the patcher resolves either layout.
  2. The QuickJS worker boots from a multi-MB base64 data: URL, which Bun's module specifier canonicalization rejects (NameTooLong).

The patcher rewrites both, in place:

  1. The static import becomes a feature-test with an amaro fallback. amaro is the same SWC-wasm wrapper Node itself uses for type stripping, so strip-mode output keeps Node's position-preserving semantics (types replaced in place with whitespace).
  2. The data: worker URL becomes a process-private temp-file file: URL, created exclusively and removed on exit—identical worker semantics, valid in both runtimes without a shared predictable path.

Test

bun run test

Runs offline patch-shape fixtures, then installs two exact @ai-sdk/code-mode / ai pairs in isolated scratch caches: the historical in-package runtime and the extracted run layout. Both must reproduce the known Bun import failure, work natively under pinned Node, accept the patcher, accept an idempotent second run, and execute a real Bun cell end-to-end. The consumer installs the packed compatibility package and does not install amaro directly.

A separate scheduled canary installs current upstream releases and current Bun. It characterizes native support without making ordinary pull requests depend on release timing.

Scope and honesty

  • This patches published dist files of a specific package shape — a bridge, not a fork. The right long-term fixes live upstream: Bun implementing the API (#35517), and/or @ai-sdk/code-mode feature-testing its import.
  • Extracted from a durable agent runtime where it has been the load-bearing enabler for running code-mode cells under Bun since 2026-08.

License

Apache-2.0