Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
1.8 kB · 58 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import { enableCompileCache } from "node:module";import { maybeStartDaemonEarly } from "./cli/daemon-launch.js";import { closeOwnedSessionWorkerOwnerWatch, installOwnedSessionWorkerOwnerWatch, isOwnedSessionWorkerProcess, maybeRunOwnedSessionWorkerFrontend,} from "./cli/owned-session-worker.js";import { runRuntimeBootstrap } from "./cli/runtime-bootstrap.js";import { APP_NAME } from "./config.js";
export async function runCli(): Promise<void> { try { enableCompileCache?.(); } catch { // Read-only cache dir; startup just skips the cache. }
process.title = APP_NAME; process.env.PI_CODING_AGENT = "true"; process.emitWarning = (() => {}) as typeof process.emitWarning;
installOwnedSessionWorkerOwnerWatch();
const args = process.argv.slice(2); if (args.length === 1 && args[0] === "--prime-agent-bootstrap") { try { await runRuntimeBootstrap(); } catch (error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; } finally { closeOwnedSessionWorkerOwnerWatch(); } return; } const handledByOwnedWorker = await maybeRunOwnedSessionWorkerFrontend(args); if (!handledByOwnedWorker) { if (!isOwnedSessionWorkerProcess()) { // Boot a cold daemon concurrently with this process's heavy imports. maybeStartDaemonEarly(process.argv.slice(2)); } const [{ EnvHttpProxyAgent, setGlobalDispatcher }, { main }] = await Promise.all([ import("undici"), import("./main.js"), ]);
// undici's 300s body/headers timeouts abort long local-LLM SSE stalls; provider // SDKs enforce their own deadlines via retry.provider.timeoutMs. setGlobalDispatcher(new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 }));
try { await main(process.argv.slice(2)); } finally { closeOwnedSessionWorkerOwnerWatch(); } }}