Something went wrong. Try again.
snapcompact for prime agent
Something went wrong. Try again.
769 B · 21 lines
JavaScript
at main
12345678910111213141516171819202122import { existsSync } from "node:fs";import { join } from "node:path";import { spawnSync } from "node:child_process";
export function resolvePrimeRoot() { const npmRoot = spawnSync("npm", ["root", "--global"], { encoding: "utf8" }); const candidates = [ process.env.PRIME_AGENT_ROOT, npmRoot.status === 0 ? join(npmRoot.stdout.trim(), "prime-agent") : undefined, "/opt/homebrew/lib/node_modules/prime-agent", "/usr/local/lib/node_modules/prime-agent", "/usr/lib/node_modules/prime-agent", ]; const root = candidates.find((candidate) => candidate && existsSync(join(candidate, "dist/index.d.ts")) ); if (!root) { throw new Error("Prime Agent was not found; set PRIME_AGENT_ROOT to its package directory"); } return root;}