termify-agent 1.0.14 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termify-agent",
3
- "version": "1.0.14",
3
+ "version": "1.0.17",
4
4
  "description": "Termify Agent CLI - Connect your local terminal to Termify",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,45 +20,117 @@ const TERMIFY_DIR = join(homedir(), '.termify');
20
20
  const DAEMON_PATH = join(TERMIFY_DIR, 'termify-daemon');
21
21
  const STATS_AGENT_PATH = join(TERMIFY_DIR, 'stats-agent');
22
22
 
23
+ /**
24
+ * Test if node-pty actually works by spawning a shell
25
+ */
26
+ function testNodePty() {
27
+ try {
28
+ const testScript = `
29
+ const pty = require('node-pty');
30
+ const term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : '/bin/sh', [], {
31
+ name: 'xterm-256color',
32
+ cols: 80,
33
+ rows: 24,
34
+ cwd: process.env.HOME || process.env.USERPROFILE || '/',
35
+ env: process.env
36
+ });
37
+ term.kill();
38
+ process.exit(0);
39
+ `;
40
+ execSync(`node -e "${testScript.replace(/"/g, '\\"').replace(/\n/g, ' ')}"`, {
41
+ stdio: 'pipe',
42
+ timeout: 10000,
43
+ cwd: process.cwd(),
44
+ });
45
+ return true;
46
+ } catch (err) {
47
+ return false;
48
+ }
49
+ }
50
+
23
51
  /**
24
52
  * Step 1: Rebuild node-pty with improved error handling
53
+ * For Node.js v24+, prebuilds may not be compatible, so we compile from source
25
54
  */
26
55
  function rebuildNodePty() {
27
- console.log('[termify-agent] Rebuilding node-pty for your platform...');
56
+ console.log('[termify-agent] Setting up node-pty for your platform...');
57
+ console.log(`[termify-agent] Node.js version: ${process.version}`);
58
+
59
+ // First, check if node-pty already works
60
+ if (testNodePty()) {
61
+ console.log('[termify-agent] node-pty is already working.');
62
+ return true;
63
+ }
28
64
 
65
+ console.log('[termify-agent] node-pty prebuilt not working, attempting rebuild...');
66
+
67
+ // Try npm rebuild first
29
68
  try {
30
- // First try regular rebuild
31
69
  execSync('npm rebuild node-pty', {
32
70
  stdio: 'pipe',
33
71
  timeout: 180000,
34
72
  });
35
- console.log('[termify-agent] node-pty rebuilt successfully.');
36
- return true;
73
+
74
+ if (testNodePty()) {
75
+ console.log('[termify-agent] node-pty rebuilt successfully.');
76
+ return true;
77
+ }
37
78
  } catch (err) {
38
- console.warn('[termify-agent] Warning: npm rebuild node-pty failed.');
39
- console.warn('[termify-agent] Attempting to reinstall node-pty...');
40
-
41
- try {
42
- // Try removing and reinstalling
43
- execSync('rm -rf node_modules/node-pty && npm install node-pty', {
44
- stdio: 'pipe',
45
- timeout: 180000,
46
- });
47
- console.log('[termify-agent] node-pty reinstalled successfully.');
79
+ // Continue to next step
80
+ }
81
+
82
+ // Prebuilds don't work (common with Node.js v24+), compile from source with node-gyp
83
+ console.log('[termify-agent] Prebuilds not compatible, compiling from source...');
84
+ console.log('[termify-agent] This may take a minute (requires Xcode Command Line Tools on macOS)...');
85
+
86
+ try {
87
+ const nodePtyDir = join(process.cwd(), 'node_modules', 'node-pty');
88
+ execSync('npx node-gyp rebuild', {
89
+ stdio: 'inherit',
90
+ timeout: 300000,
91
+ cwd: nodePtyDir,
92
+ });
93
+
94
+ if (testNodePty()) {
95
+ console.log('[termify-agent] node-pty compiled from source successfully.');
96
+ return true;
97
+ }
98
+ } catch (err) {
99
+ console.warn('[termify-agent] Warning: node-gyp rebuild failed.');
100
+ }
101
+
102
+ // Last resort: try removing and reinstalling
103
+ console.warn('[termify-agent] Attempting full reinstall of node-pty...');
104
+ try {
105
+ execSync('rm -rf node_modules/node-pty && npm install node-pty', {
106
+ stdio: 'pipe',
107
+ timeout: 180000,
108
+ });
109
+
110
+ // Try node-gyp again after fresh install
111
+ const nodePtyDir = join(process.cwd(), 'node_modules', 'node-pty');
112
+ execSync('npx node-gyp rebuild', {
113
+ stdio: 'inherit',
114
+ timeout: 300000,
115
+ cwd: nodePtyDir,
116
+ });
117
+
118
+ if (testNodePty()) {
119
+ console.log('[termify-agent] node-pty reinstalled and compiled successfully.');
48
120
  return true;
49
- } catch (err2) {
50
- console.error('[termify-agent] CRITICAL: node-pty installation failed.');
51
- console.error('[termify-agent] Terminal features will NOT work.');
52
- console.error('[termify-agent] Manual fix required:');
53
- console.error(`[termify-agent] cd ${process.cwd()}`);
54
- console.error('[termify-agent] npm rebuild node-pty');
55
- console.error('[termify-agent]');
56
- console.error('[termify-agent] If that fails, try:');
57
- console.error('[termify-agent] rm -rf node_modules/node-pty');
58
- console.error('[termify-agent] npm install node-pty');
59
- return false;
60
121
  }
122
+ } catch (err2) {
123
+ // Continue to error message
61
124
  }
125
+
126
+ console.error('[termify-agent] CRITICAL: node-pty installation failed.');
127
+ console.error('[termify-agent] Terminal features will NOT work.');
128
+ console.error('[termify-agent] ');
129
+ console.error('[termify-agent] Manual fix required:');
130
+ console.error('[termify-agent] 1. Install Xcode Command Line Tools: xcode-select --install');
131
+ console.error(`[termify-agent] 2. cd ${join(process.cwd(), 'node_modules', 'node-pty')}`);
132
+ console.error('[termify-agent] 3. npx node-gyp rebuild');
133
+ return false;
62
134
  }
63
135
 
64
136
  /**