import { ensureKernelPython } from "./core/kernel/bootstrap.js"; import { loadBundledPythonSkills } from "./core/skills.js"; import { ensureTool } from "./utils/tools-manager.js"; export function shouldBootstrapKernel(): boolean { return process.env.PRIME_AGENT_BOOTSTRAP_KERNEL_ON_INSTALL === "1"; } export function shouldBootstrapTools(): boolean { return process.env.PRIME_AGENT_BOOTSTRAP_TOOLS_ON_INSTALL === "1"; } export async function runPostinstall(): Promise { const bootstrapKernel = shouldBootstrapKernel(); const bootstrapTools = shouldBootstrapTools(); if (!bootstrapKernel && !bootstrapTools) { return; } if (bootstrapKernel && process.env.PRIME_AGENT_INSTALL_UV === undefined) { process.env.PRIME_AGENT_INSTALL_UV = "1"; } try { if (bootstrapTools) { await Promise.all([ensureTool("fd", true), ensureTool("rg", true)]); } if (bootstrapKernel) { await ensureKernelPython({ pythonSkills: loadBundledPythonSkills() }); } } catch (error) { console.error(`prime-agent: postinstall setup skipped: ${oneLine(errorMessage(error))}`); } } function errorMessage(error: unknown): string { return error instanceof Error ? error.message : String(error); } function oneLine(message: string): string { return message.replace(/\s+/g, " ").trim(); } await runPostinstall();