UNPKG

@theaiinc/torch

Version:

Standalone CLI for the Coding Agent

37 lines (30 loc) 1.1 kB
#!/usr/bin/env node const { spawn } = require('child_process'); const path = require('path'); // The command for the Python CLI, installed by 'pip install ./python_src' const command = path.join(__dirname, 'binaries', 'torch'); // Get arguments passed to this wrapper script const args = process.argv.slice(2); // Spawn the Python CLI command const pythonProcess = spawn(command, args, { stdio: 'inherit', // Inherit stdin, stdout, stderr shell: process.platform === 'win32', // Use shell on Windows if needed }); // Handle process exit pythonProcess.on('exit', code => { process.exit(code); }); // Handle errors in spawning the process pythonProcess.on('error', err => { console.error(`Failed to start binary '${command}':`); console.error(err); if (err.code === 'ENOENT') { console.error( `\nHint: The binary was not found. This can happen if the postinstall script failed or if a pre-compiled binary for your platform is not available.` ); console.error( 'Please check the installation logs, or try rebuilding the package.' ); } process.exit(1); });