Skip to content

perf(2a): pi SDK snapshot bundle (one snapshottable IIFE) - #1525

Merged
NathanFlurry merged 1 commit into
mainfrom
stack/perf-2a-pi-sdk-snapshot-bundle-one-snapshottable-iife-swtnlxlr
Jun 25, 2026
Merged

NathanFlurry merged 1 commit into
mainfrom
stack/perf-2a-pi-sdk-snapshot-bundle-one-snapshottable-iife-swtnlxlr

Conversation

@NathanFlurry

@NathanFlurry NathanFlurry commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

esbuild bundles the lean pi-SDK graph (the 13 exports loadPiSdkRuntime needs) into a
single IIFE, dist/pi-sdk-snapshot.js, that publishes globalThis.PI_SDK_RUNTIME.

  • src/snapshot-entry.ts: imports the SDK exports, assigns the runtime global.
  • scripts/build-snapshot-bundle.mjs: format:iife, platform:node (node builtins external),
    deep-import plugin to bypass the package exports map (avoids the ~100MB TUI graph the
    adapter skips), provider SDKs kept lazy/external, sha256 sidecar for dep-keying.
    C0 mitigations baked in: import.meta.url pinned to projected guest path; clipboard
    native-addon require made unreachable (DISPLAY='').
  • package.json build chains build:snapshot; tsconfig excludes the esbuild-only entry.

Validated (host, CJS harness): 13/13 exports populate, ~201ms eval, 880 modules inlined,
7.6MB. Traced top-level fs footprint = 2 deterministic package.json reads only (no net/
sockets/timers/native addons/per-session config). Artifact (dist) is gitignored.

Step 2a of the agent-SDK snapshot goal.

@NathanFlurry

Copy link
Copy Markdown
Member Author

Stack for rivet-dev/agentos

Get stack: forklift get 1525
Push local edits: forklift submit
Merge when ready: forklift merge 1525

@railway-app

railway-app Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the agentos-pr-1525 environment in agentos

Service Status Web Updated (UTC)
agentos 😴 Sleeping (View Logs) Web Jun 25, 2026 at 1:53 am

🚅 Deployed to the agentos-pr-1525 environment in rivet-frontend

Service Status Web Updated (UTC)
agent-os 😴 Sleeping (View Logs) Jun 25, 2026 at 1:52 am

esbuild bundles the lean pi-SDK graph (the 13 exports loadPiSdkRuntime needs) into a
single IIFE, dist/pi-sdk-snapshot.js, that publishes globalThis.__PI_SDK_RUNTIME__.
- src/snapshot-entry.ts: imports the SDK exports, assigns the runtime global.
- scripts/build-snapshot-bundle.mjs: format:iife, platform:node (node builtins external),
  deep-import plugin to bypass the package exports map (avoids the ~100MB TUI graph the
  adapter skips), provider SDKs kept lazy/external, sha256 sidecar for dep-keying.
  C0 mitigations baked in: import.meta.url pinned to projected guest path; clipboard
  native-addon require made unreachable (DISPLAY=''). 
- package.json build chains build:snapshot; tsconfig excludes the esbuild-only entry.

Validated (host, CJS harness): 13/13 exports populate, ~201ms eval, 880 modules inlined,
7.6MB. Traced top-level fs footprint = 2 deterministic package.json reads only (no net/
sockets/timers/native addons/per-session config). Artifact (dist) is gitignored.

Step 2a of the agent-SDK snapshot goal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NathanFlurry
NathanFlurry force-pushed the stack/perf-2a-pi-sdk-snapshot-bundle-one-snapshottable-iife-swtnlxlr branch from b51b360 to 0edfda0 Compare June 25, 2026 08:11
@railway-app
railway-app Bot temporarily deployed to agentos / agentos-pr-1525 June 25, 2026 08:11 Destroyed
@railway-app
railway-app Bot temporarily deployed to rivet-frontend / agentos-pr-1525 June 25, 2026 08:11 Destroyed
@NathanFlurry
NathanFlurry merged commit 0edfda0 into main Jun 25, 2026
3 of 4 checks passed
@NathanFlurry
NathanFlurry deleted the stack/perf-2a-pi-sdk-snapshot-bundle-one-snapshottable-iife-swtnlxlr branch June 25, 2026 08:12

This branch was successfully deployed

No deployments
rivet-frontend / agentos-pr-1525 — 0edfda00 Deployed Jun 25, 2026 by railway-app[bot]
agentos / agentos-pr-1525 — 0edfda00 Deployed Jun 25, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant