claude-tg 1.0.8 → 1.0.9

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/bin/claude-tg.js CHANGED
@@ -276,18 +276,27 @@ program
276
276
  const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
277
277
  const hooks = settings.hooks || {};
278
278
 
279
- // Extract script path from hook command (handles optional env prefix)
279
+ // Extract script path and node binary from hook command
280
280
  function extractScriptPath(cmd) {
281
281
  const match = cmd.match(/node\s+(.+)$/);
282
282
  return match ? match[1].trim() : null;
283
283
  }
284
+ function extractNodeBin(cmd) {
285
+ const match = cmd.match(/^(?:\S+=\S+\s+)?(\S*node)\s/);
286
+ return match ? match[1] : 'node';
287
+ }
284
288
 
285
289
  const permHooks = hooks.PermissionRequest || [];
286
290
  const permCmd = permHooks[0]?.hooks?.[0]?.command || 'NOT FOUND';
287
291
  console.log(` PermissionRequest: ${permCmd}`);
288
292
  if (permCmd !== 'NOT FOUND') {
293
+ const nodeBin = extractNodeBin(permCmd);
289
294
  const scriptPath = extractScriptPath(permCmd);
290
- if (scriptPath && fs.existsSync(scriptPath)) {
295
+ if (nodeBin !== 'node' && !fs.existsSync(nodeBin)) {
296
+ console.log(` Node binary: NO — ${nodeBin}`);
297
+ console.log(' Run: claude-tg setup (to fix hook paths)');
298
+ ok = false;
299
+ } else if (scriptPath && fs.existsSync(scriptPath)) {
291
300
  console.log(' File exists: YES');
292
301
  } else {
293
302
  console.log(` File exists: NO — ${scriptPath || permCmd}`);
@@ -299,8 +308,13 @@ program
299
308
  const notifCmd = notifHooks[0]?.hooks?.[0]?.command || 'NOT FOUND';
300
309
  console.log(` Notification: ${notifCmd}`);
301
310
  if (notifCmd !== 'NOT FOUND') {
311
+ const nodeBin = extractNodeBin(notifCmd);
302
312
  const scriptPath = extractScriptPath(notifCmd);
303
- if (scriptPath && fs.existsSync(scriptPath)) {
313
+ if (nodeBin !== 'node' && !fs.existsSync(nodeBin)) {
314
+ console.log(` Node binary: NO — ${nodeBin}`);
315
+ console.log(' Run: claude-tg setup (to fix hook paths)');
316
+ ok = false;
317
+ } else if (scriptPath && fs.existsSync(scriptPath)) {
304
318
  console.log(' File exists: YES');
305
319
  } else {
306
320
  console.log(` File exists: NO — ${scriptPath || notifCmd}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-tg",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Control Claude Code from Telegram — approve permissions, answer questions, reply to idle sessions, send files, all from your phone",
5
5
  "bin": {
6
6
  "claude-tg": "./bin/claude-tg.js"
package/src/setup.js CHANGED
@@ -26,13 +26,16 @@ function telegramApiCall(token, method) {
26
26
 
27
27
  function getHooksConfig(port) {
28
28
  const envPrefix = port !== 7483 ? `CLAUDE_TG_PORT=${port} ` : '';
29
+ // Use absolute path to the node binary that ran setup — ensures hooks work
30
+ // even if node isn't in PATH for non-interactive shells (nvm, fnm, etc.)
31
+ const nodeBin = process.execPath;
29
32
  return {
30
33
  PermissionRequest: [
31
34
  {
32
35
  hooks: [
33
36
  {
34
37
  type: 'command',
35
- command: `${envPrefix}node ${path.join(HOOKS_DIR, 'permission-request.js')}`,
38
+ command: `${envPrefix}${nodeBin} ${path.join(HOOKS_DIR, 'permission-request.js')}`,
36
39
  timeout: 1800,
37
40
  statusMessage: 'Waiting for Telegram approval...',
38
41
  },
@@ -45,7 +48,7 @@ function getHooksConfig(port) {
45
48
  hooks: [
46
49
  {
47
50
  type: 'command',
48
- command: `${envPrefix}node ${path.join(HOOKS_DIR, 'notification.js')}`,
51
+ command: `${envPrefix}${nodeBin} ${path.join(HOOKS_DIR, 'notification.js')}`,
49
52
  async: true,
50
53
  },
51
54
  ],