@aiyiran/myclaw 1.0.238 → 1.0.240

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.
@@ -47,11 +47,19 @@
47
47
  return '';
48
48
  }
49
49
 
50
- // ═══ 构建预览 URL ═══
50
+ // ═══ 构建预览 URL(CDN) ═══
51
51
  function buildPreviewUrl(data, assetPath) {
52
- var base = data.base_url || '';
53
- var wsName = data.workspace_id || '';
54
- return base + '/' + wsName + '/' + assetPath;
52
+ var claw = window.location.hostname.split('.')[0];
53
+ if (!claw.includes('claw')) {
54
+ claw = localStorage.getItem(CLAW_STORAGE_KEY);
55
+ }
56
+ if (!claw) {
57
+ console.error('[myclaw-artifacts] ❌ 未配置 claw 名称,无法构建预览链接');
58
+ return null;
59
+ }
60
+ var wsName = data.workspace_id || 'main';
61
+ var wsPrefix = wsName === 'main' ? 'workspace' : 'workspace-' + wsName;
62
+ return 'https://cdn.yiranlaoshi.com/' + claw + '/' + wsPrefix + '/' + assetPath;
55
63
  }
56
64
 
57
65
  // ═══ 创建按钮 ═══
@@ -199,7 +207,7 @@
199
207
  claw = localStorage.getItem(CLAW_STORAGE_KEY);
200
208
  if (!claw) {
201
209
  console.log('[myclaw-artifacts] ❌ 未配置 claw 名称');
202
- console.log('[myclaw-artifacts] 请运行: myclaw set claw <你的claw名称>');
210
+ console.log('[myclaw-artifacts] 请在控制台执行: localStorage.setItem("myclaw-claw-name", "你的claw名称")');
203
211
  return null;
204
212
  }
205
213
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.238",
3
+ "version": "1.0.240",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import sys
3
3
  import argparse
4
+ import platform
4
5
  from datetime import datetime, timezone, timedelta
5
6
  import json
6
7
  import time
@@ -8,6 +9,12 @@ from watchdog.observers import Observer
8
9
  from watchdog.events import FileSystemEventHandler
9
10
  from qiniu import Auth, put_file_v2, CdnManager
10
11
 
12
+ # 跨平台获取 openclaw 目录
13
+ def get_openclaw_path():
14
+ if platform.system() == 'Windows' or os.path.exists('/root/.openclaw'):
15
+ return '/root/.openclaw'
16
+ return os.path.expanduser('~/.openclaw')
17
+
11
18
  claw = os.environ.get("CLAW_NAME", "claw")
12
19
 
13
20
  BASE_URL = f"https://cdn.yiranlaoshi.com/{claw}"
@@ -71,7 +78,8 @@ def get_type(file_path):
71
78
 
72
79
 
73
80
  def init_config(workspace_id, file_path, method="add"):
74
- file = f"/root/.openclaw/{workspace_id}/.myclaw/__MY_ARTIFACTS__.json"
81
+ base_path = get_openclaw_path()
82
+ file = f"{base_path}/{workspace_id}/.myclaw/__MY_ARTIFACTS__.json"
75
83
 
76
84
  # 确保目录存在
77
85
  os.makedirs(os.path.dirname(file), exist_ok=True)
@@ -197,7 +205,8 @@ def file_gen(path, method):
197
205
 
198
206
  def sync_all(workspace_id):
199
207
  """全量同步指定 workspace 下所有文件"""
200
- workspace_path = f"/root/.openclaw/{workspace_id}"
208
+ base_path = get_openclaw_path()
209
+ workspace_path = f"{base_path}/{workspace_id}"
201
210
 
202
211
  if not os.path.exists(workspace_path):
203
212
  print(f"[错误] workspace 不存在: {workspace_path}")
@@ -264,7 +273,8 @@ if __name__ == "__main__":
264
273
  parser.add_argument("--agent", help="启动前先全量同步指定 workspace")
265
274
  args = parser.parse_args()
266
275
 
267
- path = "/root/.openclaw"
276
+ base_path = get_openclaw_path()
277
+ path = base_path
268
278
 
269
279
  # 如果指定了 --agent,先全量同步
270
280
  if args.agent: