UNPKG

configure

Version:

Identity layer SDK for AI agents

49 lines (40 loc) 1.38 kB
// spawn-interactive.js — postinstall hook // Opens /dev/tty directly to bypass npm's output suppression. // Silently exits in non-interactive environments (CI, Docker, scripts). // Wrapped in try/catch so postinstall never fails npm install. try { const { spawn } = require('node:child_process'); const { openSync } = require('node:fs'); const { join } = require('node:path'); function tryOpenTTY() { if (process.platform === 'win32') { if (process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY) { return { available: true, useInherit: true }; } return { available: false }; } try { openSync('/dev/tty', 'r'); return { available: true, useInherit: false }; } catch { return { available: false }; } } const tty = tryOpenTTY(); if (tty.available) { const spawnOptions = tty.useInherit ? { stdio: 'inherit', shell: true } : { stdio: [ openSync('/dev/tty', 'r'), openSync('/dev/tty', 'w'), openSync('/dev/tty', 'w'), ], }; const child = spawn('node', [join(__dirname, 'dist', 'cli.js')], spawnOptions); child.on('close', (code) => process.exit(code || 0)); child.on('error', () => {}); } else { process.stdout.write('Configure installed. Run npx configure setup to link your agent.\n'); } } catch (_) { /* silently exit — never fail npm install */ }