@hmduc16031996/claude-mb-bridge 1.1.9 → 1.1.10
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/dist/index.js +11 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { supabase } from './supabase.js';
|
|
4
4
|
import { createRequire } from 'module';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
5
6
|
const require = createRequire(import.meta.url);
|
|
6
7
|
const pty = require('node-pty');
|
|
7
8
|
const program = new Command();
|
|
@@ -57,11 +58,19 @@ program
|
|
|
57
58
|
// 3. Local pairing server (optional / fallback as per plan)
|
|
58
59
|
// For now, we'll stick to the token-based pairing.
|
|
59
60
|
});
|
|
61
|
+
function resolveClaudePath() {
|
|
62
|
+
try {
|
|
63
|
+
return execSync('which claude', { encoding: 'utf8' }).trim();
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return 'claude';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
60
69
|
async function handleUserPrompt(content, sessionId, cwd) {
|
|
61
70
|
console.log('⏳ Executing Claude Code with PTY...');
|
|
62
|
-
// Spawn claude directly (not via shell) so PTY works reliably across environments
|
|
63
71
|
const isWin = process.platform === 'win32';
|
|
64
|
-
|
|
72
|
+
// Resolve absolute path so posix_spawnp can find it without shell PATH lookup
|
|
73
|
+
const claudeExe = isWin ? 'cmd.exe' : resolveClaudePath();
|
|
65
74
|
const args = isWin
|
|
66
75
|
? ['/c', 'claude', '--print', content]
|
|
67
76
|
: ['--print', content];
|