travel-agent-cli 0.4.3 → 0.4.4

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.
Files changed (2) hide show
  1. package/interactive.jsx +22 -4
  2. package/package.json +1 -1
package/interactive.jsx CHANGED
@@ -29,25 +29,43 @@ const commands = [
29
29
  { label: 'help - 帮助信息', value: 'help' },
30
30
  ];
31
31
 
32
+ // 查找 Python 命令
33
+ function findPython() {
34
+ const { execSync } = require('child_process');
35
+ const candidates = ['python3', 'python'];
36
+
37
+ for (const cmd of candidates) {
38
+ try {
39
+ execSync(`${cmd} --version`, { stdio: 'ignore' });
40
+ return cmd;
41
+ } catch (e) {
42
+ continue;
43
+ }
44
+ }
45
+
46
+ return 'python3'; // 默认使用 python3
47
+ }
48
+
32
49
  // 执行 Python 命令
33
50
  const runPythonCommand = (cmd, args) => {
34
51
  return new Promise((resolve, reject) => {
35
52
  let output = '';
36
53
  let error = '';
37
54
 
38
- const pythonCmd = spawn('python3', [mainPy, cmd, ...args], {
55
+ const pythonCmd = findPython();
56
+ const proc = spawn(pythonCmd, [mainPy, cmd, ...args], {
39
57
  cwd: pythonDir,
40
58
  });
41
59
 
42
- pythonCmd.stdout.on('data', (data) => {
60
+ proc.stdout.on('data', (data) => {
43
61
  output += data.toString();
44
62
  });
45
63
 
46
- pythonCmd.stderr.on('data', (data) => {
64
+ proc.stderr.on('data', (data) => {
47
65
  error += data.toString();
48
66
  });
49
67
 
50
- pythonCmd.on('close', (code) => {
68
+ proc.on('close', (code) => {
51
69
  if (code === 0) {
52
70
  resolve(output.trim());
53
71
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "travel-agent-cli",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "AI 驱动的旅行目的地推荐 Agent - 命令行工具(集成 FlyAI 旅行搜索)",
5
5
  "type": "module",
6
6
  "bin": {