#6863: feat: add bun runtime support as opt-in feature
scripts
Cluster:
Bun Runtime and Docker Improvements
## Summary
Adds opt-in support for [Bun](https://bun.sh/) as an alternative runtime to Node.js. Bun offers faster startup times and built-in TypeScript support, which can improve the development experience for openclaw users.
## What is this?
This PR enables a "Bun Runtime" opt-in feature for openclaw. Users can now choose to run openclaw with Bun instead of Node.js for potentially faster execution.
## Changes
### New Files
- `scripts/run.mjs` - Runtime-agnostic runner that detects OPENCLAW_RUNTIME env var
- `scripts/get-runtime.mjs` - Runtime detection utility
- `openclaw-bun.mjs` - Bun-optimized entry point
### Modified
- `package.json` - Added bun variants of key scripts:
- `dev:bun`, `start:bun`, `openclaw:bun`
- `gateway:dev:bun`, `tui:bun`, `tui:dev:bun`
- Updated existing scripts to use `scripts/run.mjs` (backward compatible)
## Usage
### Opt-in via environment variable:
```bash
export OPENCLAW_RUNTIME=bun
pnpm run openclaw
```
### Or use the explicit bun scripts:
```bash
pnpm run dev:bun
pnpm run start:bun
pnpm run openclaw:bun
pnpm run gateway:dev:bun
pnpm run tui:bun
```
## Benefits
- **Faster startup**: Bun has significantly faster cold start times
- **Native TypeScript**: No need for tsx/ts-node for some operations
- **Drop-in replacement**: Existing Node.js workflow unchanged (opt-in only)
## Backward Compatibility
- Default runtime remains Node.js (no breaking changes)
- All existing scripts work exactly as before
- Bun is strictly opt-in via `OPENCLAW_RUNTIME=bun` or `*:bun` scripts
## Testing
- [x] Format/lint checks pass
- [ ] Unit tests pass with Node (default) - running
- [ ] Unit tests pass with Bun runtime
- [ ] E2E tests pass
---
## 🤖 Prompt to Generate This PR
If you want an AI assistant to generate this same PR, use this prompt:
```
I want to add Bun runtime support to openclaw as an opt-in feature.
Requirements:
1. Create a runtime-agnostic runner script (scripts/run.mjs) that:
- Detects OPENCLAW_RUNTIME=bun environment variable
- Defaults to node for backward compatibility
- Validates bun is installed when requested
- Handles the build process appropriately for each runtime
2. Create scripts/get-runtime.mjs for runtime detection
3. Create openclaw-bun.mjs as a bun-optimized entry point
4. Update package.json to:
- Replace node scripts/run-node.mjs with node scripts/run.mjs in existing scripts
- Add bun variants: dev:bun, start:bun, openclaw:bun, gateway:dev:bun, tui:bun, tui:dev:bun
- Follow existing naming conventions (e.g., gateway:dev:bun pattern)
5. Ensure:
- Format checks pass (pnpm run format:fix)
- Backward compatible (node remains default)
- Clear error message if bun not found but OPENCLAW_RUNTIME=bun is set
6. Create branch feat/bun-runtime-optin, commit, push to fork, create PR against openclaw/openclaw
The PR title should be: feat: add bun runtime support as opt-in feature
``"
---
**Note for maintainers:** This is a developer-experience improvement. Bun support is opt-in only with no breaking changes to existing Node.js workflows.
Most Similar PRs
#17123: Add Cloud Run deployment guide and Bun version pinning
by optiflow · 2026-02-15
66.3%
#6843: feat: add install:hackable script for hackable installs
by aashishsingla567 · 2026-02-02
65.8%
#21075: fix(media): use sips on Node.js + darwin to prevent Photos TCC prompt
by irchelper · 2026-02-19
65.0%
#6051: feat(memory): add Bun sqlite compatibility
by cheeeee · 2026-02-01
64.2%
#8600: fix(update): add --ignore-scripts to prevent supply chain attacks
by yubrew · 2026-02-04
63.1%
#17636: Build: add runtime-only build target
by joshp123 · 2026-02-16
61.4%
#6064: fix(daemon): prefer bundled node from install-cli.sh over system node
by joyshmitz · 2026-02-01
61.4%
#18676: feat: add patch-ui.sh
by jasonkneen · 2026-02-16
60.3%
#13168: perf: short-circuit --version to skip process respawn and full modu...
by RamiNoodle733 · 2026-02-10
60.0%
#22692: fix(memory-lancedb): [P1] add missing runtime deps — plugin broken ...
by mahsumaktas · 2026-02-21
59.8%