feat(pocket-pi): bump to pi 0.81 + self-contained embedded binary - #3
Merged
Conversation
…version) Upstream pi moved scope (@mariozechner → @earendil-works) and jumped 0.73→0.81, which restructured the model/auth layer and pulled undici onto the HTTP path. Migrated the runtime and harness to run the new unmodified pi end-to-end. Model/auth (0.81): - createAgentSession now takes a `modelRuntime` (ModelRuntime.create), not an authStorage+ModelRegistry. Harness builds an in-memory, offline ModelRuntime and sets the key via `setRuntimeApiKey`; the custom gpt-5.6 model is passed straight through. entry.mjs deep-imports ModelRuntime + the auth classes (off the barrel now). undici (new transitive HTTP transport in 0.81): - pi only uses undici for its proxy-fetch path, which Pocket Pi never triggers (the native hub owns proxying). Aliased `undici` to a tiny stub at bundle time so its whole web-fetch/websocket/cache stack stays out — pi's source unmodified, same "heavy Node transport → native" rule the trimmed bundle applies to pi-ai. Runtime surface the newer bundle needs: - new `node:console` builtin (Console class); worker_threads.Worker + friends; path.toNamespacedPath/format; util.debuglog; async_hooks.AsyncResource (real base class so `class X extends AsyncResource` loads); crypto.getHashes/ timingSafeEqual; process.execPath/argv0/pid; Web globals MessagePort/ MessageChannel/EventTarget/Event/CustomEvent/DOMException. - fs: openSync now honors write/append/exclusive flags ("wx", "a", …) and writeFileSync/writeSync accept a file descriptor (0.81's SessionManager._persist writes via fd instead of appendFileSync). Verified end-to-end on 0.81: bundle loads, real gpt-5.6 turn ("pocket pi lives"), extension tool call (hook fires + echo executes), session persist/resume. Full suite green (23), clippy clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-contained binary Shrinks the one-shot distributable. The full unmodified pi-coding-agent bundle was a 13 MB .js loaded from disk; now it minifies to 9 MB, gzips to 1.8 MB, and (behind the `embed-full-pi` feature) is embedded in the binary and gunzipped at load. A binary that runs the full pi is a single self-contained 8.9 MB file — nothing alongside it, nothing to npm install (vs. the old 7 MB binary + 13 MB sidecar). - build-pi-full.mjs: whitespace-minify + --line-limit (identifier and syntax minification both emit tokens the embedded QuickJS parser rejects; gzip reclaims the difference), then emit pi-full.bundle.js.gz. - Cargo `embed-full-pi` feature (off by default so dev/CI, which path-load the bundle in #[ignore] tests, don't need it) pulls in flate2 (pure-Rust backend) and include_bytes! the gzip. - lib.rs: `embedded_full_pi_bundle()` (gunzip) + `PiRuntime::load_full_pi()` (declare → set import.meta.url → eval, since the in-memory module bypasses the loader that normally sets it). examples/self_contained.rs demonstrates it; loads_embedded_full_pi test (feature+ignore) asserts it initializes. Default suite green (23), clippy clean; feature build + embedded load verified. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Corrects facts changed by the bump + embed work (and removes the internal "Path B" jargon still on main): footprint is now one self-contained binary, ~8.9 MB with the full unmodified pi embedded (gzip) or ~7 MB trimmed-core only; sync scope is @earendil-works; the full bundle is ~9 MB minified / ~1.8 MB gzip; notes the undici stub. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two phases of a larger effort (the TypeScript build-pipeline rewrite lands as a follow-up).
Phase 1 — bump to latest pi (
@earendil-works/pi-coding-agent@0.81.1)Upstream moved scope (
@mariozechner→@earendil-works) and jumped 0.73 → 0.81, which was a real migration, not a version bump:ModelRuntimeAPI (ModelRuntime.create,setRuntimeApiKey); auth classes moved off the barrel (deep-imported likeloadExtensionFromFactory).node:console,worker_threads.Worker,async_hooks.AsyncResource(real base class soclass X extends AsyncResourceloads),util.debuglog,path.toNamespacedPath,crypto.getHashes,process.execPath, Web globals (MessagePort/EventTarget/…), and fd-basedfswrites (0.81 persists viaopenSync("wx")+writeFileSync(fd)instead ofappendFileSync).Validated end-to-end on 0.81: bundle loads, real gpt-5.6 turn (
pocket pi lives), extension tool call (hook fires +echoexecutes), session persist/resume.Phase 2 — minify + gzip-embed → 8.9 MB self-contained binary
--line-limitonly; gzip reclaims the rest) → 1.8 MB gzip.embed-full-piCargo feature (off by default so CI/dev — which path-load the bundle in#[ignore]tests — don't need it), the gzip isinclude_bytes!'d and gunzipped at load viaPiRuntime::load_full_pi()(declare → setimport.meta.url→ eval).examples/self_contained.rsdemonstrates it.Tests / CI
-D warningsclean.#[ignore]bundle-gated:loads_bundled_pi_coding_agent,binds_extension_into_session,persists_and_resumes_session,loads_pi_extension_via_our_loader(offline);runs_bundled_pi_turn,runs_pi_turn_with_extension_tool(network);loads_embedded_full_pi(feature + ignore).🤖 Generated with Claude Code