agent-orchestrator/scripts/rebuild-node-pty.js

39 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
// Automatically rebuild node-pty from source after pnpm install
// This fixes DirectTerminal "posix_spawnp failed" errors from incompatible prebuilt binaries
import { execSync } from "node:child_process";
import { existsSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const repoRoot = join(__dirname, "..");
// Find node-pty in pnpm node_modules
const nodePtyPath = join(repoRoot, "node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty");
if (!existsSync(nodePtyPath)) {
console.log(" node-pty not found, skipping rebuild");
process.exit(0);
}
console.log("🔧 Rebuilding node-pty from source...");
try {
execSync("npx node-gyp rebuild", {
cwd: nodePtyPath,
stdio: "inherit",
});
console.log("✅ node-pty rebuilt successfully");
} catch {
console.warn("⚠️ node-pty rebuild failed (non-critical)");
console.warn(" DirectTerminal may not work correctly");
console.warn(
" Run manually: cd node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty && npx node-gyp rebuild",
);
// Don't fail the install - node-pty rebuild failure is non-critical
process.exit(0);
}