Skip to content

Commit c0b19da

Browse files
BillLeoutsakosvl346Bill Leoutsakos
andauthored
feat(pi): install Bun in cloud sandboxes (#6123)
Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
1 parent 5c29d83 commit c0b19da

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

apps/docs/content/docs/en/workflows/blocks/pi.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ The one case neither layer can rescue is a *first* prompt that already exceeds t
211211

212212
### Create PR [#setup-cloud-pr]
213213

214-
Create PR runs in a sandbox image with the Pi CLI and git baked in.
214+
Create PR runs in a sandbox image with the Pi CLI, Git, Node.js, and Bun baked in. Repository dependencies are not preinstalled; Pi can run `bun install` when a repository needs them.
215215

216216
1. **Enable sandbox execution.** On self-hosted Sim, set `E2B_ENABLED=true`, `E2B_API_KEY`, `E2B_PI_TEMPLATE_ID` (the Pi template id), and `NEXT_PUBLIC_E2B_ENABLED=true` (this reveals Create PR, Update PR, and Review Code in the UI). Build the template with `bun run apps/sim/scripts/build-pi-e2b-template.ts`. These modes stay hidden until `NEXT_PUBLIC_E2B_ENABLED` is set.
217217

apps/sim/scripts/build-pi-daytona-snapshot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ import { Daytona, Image } from '@daytona/sdk'
2828
import { getErrorMessage } from '@sim/utils/errors'
2929
import {
3030
PI_APT,
31+
PI_BUN_VERSION_ASSERT,
32+
PI_GLOBAL_NPM_PACKAGES,
3133
PI_NODE_MAJOR,
3234
PI_NODE_VERSION_ASSERT,
33-
PI_NPM,
3435
PI_SANDBOX_CPU_COUNT,
3536
PI_SANDBOX_MEMORY_GB,
3637
} from '@/scripts/pi-sandbox-packages'
@@ -63,7 +64,8 @@ export const piImage = Image.base(BASE_IMAGE).runCommands(
6364
// ships an older Node fails here rather than at the first agent run.
6465
`apt-get update && curl -fsSL https://deb.nodesource.com/setup_${PI_NODE_MAJOR}.x | bash - && ${APT_PREFIX} nodejs && rm -rf /var/lib/apt/lists/* && ${PI_NODE_VERSION_ASSERT}`,
6566
`apt-get update && ${APT_PREFIX} ${PI_APT.join(' ')} && rm -rf /var/lib/apt/lists/*`,
66-
`npm install -g ${PI_NPM.join(' ')}`,
67+
`npm install -g ${PI_GLOBAL_NPM_PACKAGES.join(' ')}`,
68+
PI_BUN_VERSION_ASSERT,
6769
// The clone target. E2B's base ships a world-writable /code; Pi writes to
6870
// /workspace (cloud-review-tools.ts:14), so create it explicitly.
6971
'mkdir -p /workspace'

apps/sim/scripts/build-pi-e2b-template.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
import { defaultBuildLogger, Template, waitForTimeout } from '@e2b/code-interpreter'
2020
import {
2121
PI_APT,
22+
PI_BUN_VERSION_ASSERT,
23+
PI_GLOBAL_NPM_PACKAGES,
2224
PI_NODE_MAJOR,
2325
PI_NODE_VERSION_ASSERT,
24-
PI_NPM,
2526
PI_SANDBOX_CPU_COUNT,
2627
PI_SANDBOX_MEMORY_MB,
2728
} from '@/scripts/pi-sandbox-packages'
@@ -38,7 +39,8 @@ const piTemplate = Template()
3839
.fromTemplate('code-interpreter-v1')
3940
.runCmd(INSTALL_NODE_COMMAND, { user: 'root' })
4041
.aptInstall([...PI_APT])
41-
.npmInstall([...PI_NPM], { g: true })
42+
.npmInstall([...PI_GLOBAL_NPM_PACKAGES], { g: true })
43+
.runCmd(PI_BUN_VERSION_ASSERT, { user: 'root' })
4244
.setStartCmd(START_COMMAND, waitForTimeout(1_000))
4345

4446
async function main() {

apps/sim/scripts/pi-sandbox-packages.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
* owns the Pi block.
1414
*/
1515

16-
/** Exact first-party Pi versions mirrored from bun.lock — image builds run npm independently. */
17-
export const PI_NPM = [
16+
/** Bun version mirrored from the root packageManager field. */
17+
export const PI_BUN_VERSION = '1.3.13'
18+
19+
/** Exact global package versions mirrored from package.json and bun.lock. */
20+
export const PI_GLOBAL_NPM_PACKAGES = [
21+
`bun@${PI_BUN_VERSION}`,
1822
'@earendil-works/pi-coding-agent@0.80.10',
1923
'@earendil-works/pi-agent-core@0.80.10',
2024
'@earendil-works/pi-ai@0.80.10',
@@ -51,6 +55,9 @@ export const PI_NODE_MAJOR = 22
5155
export const PI_NODE_VERSION_ASSERT =
5256
'node -e "const [major, minor] = process.versions.node.split(\'.\').map(Number); if (major < 22 || (major === 22 && minor < 19)) process.exit(1)"'
5357

58+
/** Fails the build loudly if the sandbox does not contain the repository's Bun version. */
59+
export const PI_BUN_VERSION_ASSERT = `test "$(bun --version)" = "${PI_BUN_VERSION}"`
60+
5461
/**
5562
* The review tools run `python3 /workspace/sim-review-tools.py`
5663
* (`cloud-review-tools.ts:15`). E2B's `code-interpreter-v1` base ships Python, so

0 commit comments

Comments
 (0)