@aiyiran/myclaw 1.0.247 → 1.0.248

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/index.js CHANGED
@@ -835,12 +835,17 @@ function runPatch() {
835
835
  console.log('');
836
836
  const skillResult = patchSkills();
837
837
 
838
- // 3. 智能体上传(从 agent-list/ 复制到 ~/.openclaw/)
838
+ // 3. Python 依赖安装(读取 requirements.txt,pip install 缺失的包)
839
+ console.log('');
840
+ const { patchPythonDeps } = require('./patches/patch-python-deps');
841
+ patchPythonDeps();
842
+
843
+ // 4. 智能体上传(从 agent-list/ 复制到 ~/.openclaw/)
839
844
  console.log('');
840
845
  const { patchAgents } = require('./patches/patch-agent');
841
846
  const agentResult = patchAgents();
842
847
 
843
- // 4. Config 补丁(从 manifest 读取,修改 openclaw.json)
848
+ // 5. Config 补丁(从 manifest 读取,修改 openclaw.json)
844
849
  console.log('');
845
850
  try {
846
851
  const { loadManifest } = require('./patches/patch-agent');
@@ -888,7 +893,7 @@ function runPatch() {
888
893
  console.log('[myclaw-config] ⚠ 配置补丁失败: ' + err.message);
889
894
  }
890
895
 
891
- // 5. 自定义注入脚本执行引擎 (Manifest `run` 数组)
896
+ // 6. 自定义注入脚本执行引擎 (Manifest `run` 数组)
892
897
  // 此处读取 manifest.json 中的 "run" 数组,并按顺序 require 执行对应的模块。
893
898
  // 通过修改 manifest 即可控制额外脚本(如 inject-image, inject-search)是否跟随 patch 自动执行,
894
899
  // 从而避免硬编码具体要注入哪些模块。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.247",
3
+ "version": "1.0.248",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,79 @@
1
+ /**
2
+ * ============================================================================
3
+ * MyClaw Patch Python Deps
4
+ * ============================================================================
5
+ *
6
+ * 功能:
7
+ * 读取 myclaw 根目录下的 requirements.txt,检查并安装所有 Python 依赖。
8
+ * 幂等:已安装的包跳过,只安装缺失的。
9
+ * ============================================================================
10
+ */
11
+
12
+ const { execSync } = require('child_process');
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+
16
+ function patchPythonDeps() {
17
+ const reqPath = path.join(__dirname, '..', 'requirements.txt');
18
+
19
+ if (!fs.existsSync(reqPath)) {
20
+ console.log('[myclaw-python-deps] ⚠ 未找到 requirements.txt,跳过');
21
+ return { success: true, installed: [] };
22
+ }
23
+
24
+ const packages = fs.readFileSync(reqPath, 'utf8')
25
+ .split('\n')
26
+ .map(l => l.trim())
27
+ .filter(l => l && !l.startsWith('#'));
28
+
29
+ if (packages.length === 0) {
30
+ console.log('[myclaw-python-deps] ✅ requirements.txt 为空,无需安装');
31
+ return { success: true, installed: [] };
32
+ }
33
+
34
+ console.log('[myclaw-python-deps] 检查 Python 依赖...');
35
+
36
+ const missing = [];
37
+
38
+ for (const pkg of packages) {
39
+ // pip 包名转 import 名:把连字符换成下划线(volcengine → volcengine,boto3 → boto3)
40
+ const importName = pkg.split(/[>=<!]/)[0].trim().replace(/-/g, '_');
41
+ try {
42
+ execSync(`python3 -c "import ${importName}"`, { stdio: 'pipe' });
43
+ console.log('[myclaw-python-deps] ✅ 已安装: ' + pkg);
44
+ } catch {
45
+ console.log('[myclaw-python-deps] ⚠ 缺少: ' + pkg);
46
+ missing.push(pkg);
47
+ }
48
+ }
49
+
50
+ if (missing.length === 0) {
51
+ console.log('[myclaw-python-deps] ✅ 所有依赖已就绪');
52
+ return { success: true, installed: [] };
53
+ }
54
+
55
+ console.log('[myclaw-python-deps] → 安装缺失依赖: ' + missing.join(', '));
56
+
57
+ const installed = [];
58
+ const failed = [];
59
+
60
+ for (const pkg of missing) {
61
+ try {
62
+ execSync(`pip3 install -q ${pkg}`, { stdio: 'pipe' });
63
+ console.log('[myclaw-python-deps] ✅ 已安装: ' + pkg);
64
+ installed.push(pkg);
65
+ } catch (err) {
66
+ console.log('[myclaw-python-deps] ❌ 安装失败: ' + pkg + ' — ' + err.message);
67
+ failed.push(pkg);
68
+ }
69
+ }
70
+
71
+ if (failed.length > 0) {
72
+ console.log('[myclaw-python-deps] ⚠ 以下依赖安装失败,请手动运行:');
73
+ console.log(' pip3 install ' + failed.join(' '));
74
+ }
75
+
76
+ return { success: failed.length === 0, installed, failed };
77
+ }
78
+
79
+ module.exports = { patchPythonDeps };
@@ -0,0 +1,2 @@
1
+ volcengine
2
+ requests