chore(vendor): import pi 0.85.1

Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
2026-09-14 10:48:47 -04:00
parent 5ebc7018c3
commit 4def357d09
1669 changed files with 397627 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env node
import "./sandbox-env-setup.ts";
import "./runtime-setup.ts";
import "../cli.ts";

View File

@@ -0,0 +1,36 @@
/**
* Workaround for https://github.com/oven-sh/bun/issues/27802
*
* Bun compiled binaries have an empty `process.env` when running inside
* sandbox environments (e.g. nono on Linux/macOS). On Linux we can recover
* the environment from `/proc/self/environ`.
*
* Keep this in sync with getBunSandboxEnvValue() in
* packages/ai/src/utils/provider-env.ts. The ai package duplicates the lookup
* for direct consumers that do not go through this coding-agent entrypoint.
*/
import { readFileSync } from "node:fs";
/**
* Restore environment variables from `/proc/self/environ` when running
* inside a sandbox where Bun's `process.env` is empty.
*/
export function restoreSandboxEnv(): void {
if (!process.versions?.bun) return;
// If process.env already has entries, nothing to fix.
if (Object.keys(process.env).length > 0) return;
try {
const data = readFileSync("/proc/self/environ", "utf-8");
for (const entry of data.split("\0")) {
const idx = entry.indexOf("=");
if (idx > 0) {
process.env[entry.slice(0, idx)] = entry.slice(idx + 1);
}
}
} catch {
// /proc/self/environ may not be readable; ignore.
}
}

View File

@@ -0,0 +1,9 @@
import { bedrockProviderModule } from "@earendil-works/pi-ai/bedrock-provider";
import { registerBunOAuthFlows } from "@earendil-works/pi-ai/bun-oauth";
import { setBedrockProviderModule } from "@earendil-works/pi-ai/compat";
import { APP_NAME } from "../config.ts";
process.title = APP_NAME;
process.emitWarning = (() => {}) as typeof process.emitWarning;
registerBunOAuthFlows();
setBedrockProviderModule(bedrockProviderModule);

View File

@@ -0,0 +1,4 @@
import { restoreSandboxEnv } from "./restore-sandbox-env.ts";
// Restore the environment before evaluating modules that read it at startup.
restoreSandboxEnv();