diff --git a/package.json b/package.json index b82db78a5..70aaa7220 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "changeset": "changeset", "version-packages": "changeset version", "release": "pnpm -r --filter '!@composio/ao-web' build && changeset publish", - "prepare": "husky" + "prepare": "husky", + "postinstall": "node scripts/rebuild-node-pty.js" }, "devDependencies": { "@changesets/cli": "^2.29.8", diff --git a/scripts/rebuild-node-pty.js b/scripts/rebuild-node-pty.js new file mode 100644 index 000000000..a659f9a2f --- /dev/null +++ b/scripts/rebuild-node-pty.js @@ -0,0 +1,39 @@ +#!/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 (error) { + 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); +} diff --git a/scripts/setup.sh b/scripts/setup.sh index 9f56d63a6..2d495a38c 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -19,11 +19,6 @@ pnpm install echo "🔨 Building all packages..." pnpm build -echo "🔧 Rebuilding node-pty from source (fixes DirectTerminal)..." -cd node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty -npx node-gyp rebuild > /dev/null 2>&1 || echo "âš ī¸ node-pty rebuild failed (non-critical)" -cd ../../../../.. - echo "🔗 Linking CLI globally..." cd packages/cli npm link