The server bundler (packages/cli/src/cmd/build/vite/server-bundler.ts) unconditionally uses npm install --os=linux --cpu=x64 --force to install all externalized runtime packages into .agentuity/node_modules/ during production builds. This was done because packages like sharp have platform-specific native binaries distributed as optional dependencies, and bun has no equivalent to npm's --os/--cpu flags for overriding target platform during install.
However, the code already scans each package's optionalDependencies for linux-x64 entries (lines 175-194) and collects them into platformOptionalDeps. When this list is empty — meaning none of the externalized packages have platform-specific native deps — npm's cross-platform flags serve no purpose. A plain bun install would work fine.
In practice, most projects only externalize pure JS packages like ws. The sharp, chromium-bidi, and fsevents entries in the runtimeExternals list
are defensive — they're only installed if they actually exist in the project's node_modules.
Proposed change
In server-bundler.ts around lines 204-225, split the install into two paths:
- If platformOptionalDeps.length > 0: use npm install --os=linux --cpu=x64 --force (current behavior, unchanged)
- If platformOptionalDeps.length === 0: use bun install instead
Advantages
- Removes npm as a hard dependency for the majority of projects that don't use packages with native platform-specific binaries
- More correct — doesn't apply cross-platform flags when there's nothing cross-platform to resolve
- Slightly faster installs for the common case
Tradeoffs
- Adds a second code path for package installation
- Less impactful now that sandbox-agentuity includes npm
The server bundler (packages/cli/src/cmd/build/vite/server-bundler.ts) unconditionally uses npm install --os=linux --cpu=x64 --force to install all externalized runtime packages into .agentuity/node_modules/ during production builds. This was done because packages like sharp have platform-specific native binaries distributed as optional dependencies, and bun has no equivalent to npm's --os/--cpu flags for overriding target platform during install.
However, the code already scans each package's optionalDependencies for linux-x64 entries (lines 175-194) and collects them into platformOptionalDeps. When this list is empty — meaning none of the externalized packages have platform-specific native deps — npm's cross-platform flags serve no purpose. A plain bun install would work fine.
In practice, most projects only externalize pure JS packages like ws. The sharp, chromium-bidi, and fsevents entries in the runtimeExternals list
are defensive — they're only installed if they actually exist in the project's node_modules.
Proposed change
In server-bundler.ts around lines 204-225, split the install into two paths:
Advantages
Tradeoffs