@aiyiran/myclaw 1.1.143 → 1.1.145

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.
@@ -30,7 +30,7 @@
30
30
  var panelVisible = false;
31
31
  var cachedData = null;
32
32
  var pollTimer = null;
33
- var lastKnownClawName = null; // 本地环境下从 API 获取,remote 环境每次从 hostname 实时派生
33
+ var lastKnownClawName = null; // 统一从 /api/config 读取并缓存(本地与远程一致)
34
34
  var _preloadCache = {}; // url → Image 对象,防止重复预加载
35
35
  var showHiddenArtifacts = false; // 是否显示被过滤掉的系统/模板内部文件
36
36
  var MYCLAW_API_PORT = 18800;
@@ -60,33 +60,13 @@
60
60
 
61
61
  // ═══ 环境检测 ═══
62
62
  // 判断当前是远程服务器还是本地环境
63
- // 远程:https://claw.yiranlaoshi.com → { remote: true, clawName: 'clawdev' }
64
- // 远程:https://claw3.kekouen.cn → { remote: true, clawName: 'claw3' }
65
- // 本地:http://127.0.0.1:18789 → { remote: false, clawName: null }
66
- function detectEnvironment() {
67
- var hostname = window.location.hostname;
68
-
69
- // claw.yiranlaoshi.com → 特殊映射:clawdev
70
- if (hostname === 'claw.yiranlaoshi.com') {
71
- return { remote: true, clawName: 'clawdev' };
72
- }
73
-
74
- // *.kekouen.cn → 子域名即 clawName
75
- if (hostname.endsWith('.kekouen.cn')) {
76
- var clawName = hostname.split('.')[0];
77
- return { remote: true, clawName: clawName };
78
- }
79
-
80
- // 本地或无法判定
81
- return { remote: false, clawName: null };
63
+ function isRemote() {
64
+ var h = window.location.hostname;
65
+ return h.endsWith('.yiranlaoshi.com') || h.endsWith('.kekouen.cn');
82
66
  }
83
67
 
84
- // ═══ 获取 clawName(本地环境从 API 实时获取) ═══
68
+ // ═══ 获取 clawName(统一从 API 读取) ═══
85
69
  function resolveClawName() {
86
- var env = detectEnvironment();
87
- if (env.remote) {
88
- return Promise.resolve(env.clawName);
89
- }
90
70
  return fetch(MYCLAW_API_BASE + '/api/config')
91
71
  .then(function (res) {
92
72
  if (!res.ok) throw new Error('HTTP ' + res.status);
@@ -97,19 +77,15 @@
97
77
  return data.claw;
98
78
  })
99
79
  .catch(function (err) {
100
- console.warn('[myclaw-artifacts] ⚠ 本地 API 不可用:', err.message);
101
- return lastKnownClawName; // 降级用上次成功的值
80
+ console.warn('[myclaw-artifacts] ⚠ API 不可用:', err.message);
81
+ return lastKnownClawName;
102
82
  });
103
83
  }
104
84
 
105
85
  // ═══ 构建预览 URL ═══
106
- // 统一走 CDN,clawName 只从两个可信来源取:
107
- // 远程 → hostname 派生(detectEnvironment)
108
- // 本地 → resolveClawName() 缓存的 lastKnownClawName
109
86
  function buildPreviewUrl(data, assetPath) {
110
- var env = detectEnvironment();
111
87
  var wsPrefix = getWorkspaceId();
112
- var clawName = env.remote ? env.clawName : lastKnownClawName;
88
+ var clawName = lastKnownClawName;
113
89
 
114
90
  if (!clawName) {
115
91
  console.error('[myclaw-artifacts] ❌ clawName 未就绪,无法构建预览链接');
@@ -270,8 +246,7 @@
270
246
 
271
247
  // 展示间跳转(发布按钮左边)
272
248
  var showcaseLink = document.createElement('a');
273
- var _scEnv = detectEnvironment();
274
- var _scClaw = _scEnv.remote ? _scEnv.clawName : (lastKnownClawName || '');
249
+ var _scClaw = lastKnownClawName || '';
275
250
  var _scWs = getWorkspaceId();
276
251
  showcaseLink.href = 'https://www.yiranlaoshi.com/showcase?claw=' + _scClaw + '&workspace=' + _scWs + '&clawName=' + _scClaw;
277
252
  showcaseLink.target = '_blank';
@@ -812,8 +787,7 @@
812
787
  // 本地环境:走本地 API(文件尚未同步到 CDN)
813
788
  // CSP img-src 限制后续在服务端统一放行,此处不做 blob 绕行
814
789
  var img = document.createElement('img');
815
- var _imgEnv = detectEnvironment();
816
- img.src = _imgEnv.remote
790
+ img.src = isRemote()
817
791
  ? previewUrl + '?t=' + Date.now()
818
792
  : MYCLAW_API_BASE + '/api/file?path=' + encodeURIComponent(getWorkspaceId() + '/' + asset.path) + '&t=' + Date.now();
819
793
  img.alt = asset.name || asset.path;
@@ -1177,8 +1151,7 @@
1177
1151
  var video = document.createElement('video');
1178
1152
  video.controls = true;
1179
1153
  video.style.cssText = 'flex:1;width:100%;max-height:100%;background:#000;outline:none;';
1180
- var _videoEnv = detectEnvironment();
1181
- video.src = _videoEnv.remote
1154
+ video.src = isRemote()
1182
1155
  ? previewUrl + '?t=' + Date.now()
1183
1156
  : MYCLAW_API_BASE + '/api/file?path=' + encodeURIComponent(getWorkspaceId() + '/' + asset.path);
1184
1157
  box.appendChild(video);
@@ -1201,9 +1174,8 @@
1201
1174
  // HTML 作品已由服务端注入 debug probe,挂上调试记录收集器开始录制。
1202
1175
  // 其余类型(图片/视频/PDF…)不录制。collector 不存在时静默跳过。
1203
1176
  if (isHtml && typeof window.startDebugRecord === 'function') {
1204
- var _dbgEnv = detectEnvironment();
1205
1177
  var debugContext = {
1206
- claw: _dbgEnv.remote ? _dbgEnv.clawName : lastKnownClawName,
1178
+ claw: lastKnownClawName,
1207
1179
  workspace: getWorkspaceId(),
1208
1180
  entryFile: asset.path,
1209
1181
  apiBase: MYCLAW_API_BASE
@@ -2051,7 +2023,7 @@
2051
2023
  workspace: getWorkspaceId(),
2052
2024
  cover_path: coverSelect.value || '',
2053
2025
  entry_path: entrySelect.value || '',
2054
- claw: (function () { var e = detectEnvironment(); return e.remote ? e.clawName : (lastKnownClawName || ''); }()),
2026
+ claw: (lastKnownClawName || ''),
2055
2027
  };
2056
2028
  submitBtn.disabled = true;
2057
2029
  submitBtn.textContent = '\u53D1\u5E03\u4E2D...';
@@ -3084,8 +3056,7 @@
3084
3056
  // 本地环境:启动时获取一次 clawName 并缓存,轮询期间复用
3085
3057
  resolveClawName();
3086
3058
  startPolling();
3087
- var env = detectEnvironment();
3088
- console.log('[myclaw-artifacts] ✅ 初始化完成 (' + (env.remote ? '远程: ' + env.clawName : '本地') + ')');
3059
+ console.log('[myclaw-artifacts] 初始化完成 (clawName=' + (lastKnownClawName || 'pending') + ')');
3089
3060
  }
3090
3061
 
3091
3062
  if (document.readyState === 'loading') {
@@ -345,7 +345,35 @@
345
345
  return btn;
346
346
  }
347
347
 
348
+ function createLogButton() {
349
+ var btn = document.createElement("button");
350
+ btn.id = "myclaw-log-btn";
351
+ btn.className = "agent-chat__input-btn";
352
+ btn.title = "让 AI 帮你加运行提示";
353
+ btn.setAttribute("aria-label", "让 AI 帮你加运行提示");
354
+ btn.innerHTML = [
355
+ '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"',
356
+ ' viewBox="0 0 24 24" fill="none" stroke="currentColor"',
357
+ ' stroke-width="2" stroke-linecap="round" stroke-linejoin="round">',
358
+ ' <path d="M8 6h13"/>',
359
+ ' <path d="M8 12h13"/>',
360
+ ' <path d="M8 18h13"/>',
361
+ ' <path d="M3 6h.01"/>',
362
+ ' <path d="M3 12h.01"/>',
363
+ ' <path d="M3 18h.01"/>',
364
+ '</svg>',
365
+ ].join("");
366
+
367
+ btn.addEventListener("click", function (e) {
368
+ e.stopPropagation();
369
+ showLogModal();
370
+ });
371
+
372
+ return btn;
373
+ }
374
+
348
375
  var debugVoiceDestroyers = [];
376
+ var logVoiceDestroyers = [];
349
377
 
350
378
  function closeDebugModal() {
351
379
  debugVoiceDestroyers.forEach(function (destroy) {
@@ -356,6 +384,15 @@
356
384
  if (modal) modal.remove();
357
385
  }
358
386
 
387
+ function closeLogModal() {
388
+ logVoiceDestroyers.forEach(function (destroy) {
389
+ try { destroy(); } catch (e) {}
390
+ });
391
+ logVoiceDestroyers = [];
392
+ var modal = document.getElementById("myclaw-log-modal");
393
+ if (modal) modal.remove();
394
+ }
395
+
359
396
  function makeDebugLabel(text) {
360
397
  var label = document.createElement("div");
361
398
  label.textContent = text;
@@ -615,6 +652,110 @@
615
652
  descriptionField.focus();
616
653
  }
617
654
 
655
+ function showLogModal() {
656
+ if (document.getElementById("myclaw-log-modal")) return;
657
+
658
+ var state = { problem: "" };
659
+
660
+ function buildLogPrompt() {
661
+ var lines = [];
662
+ lines.push("我需要你帮我添加一些调试信息,我希望调试信息非常清晰、全面。");
663
+ lines.push("我正在解决的问题是关于:" + state.problem);
664
+ lines.push("");
665
+ lines.push("这些调试信息后续会给到你,用来帮我继续解决问题。");
666
+ lines.push("");
667
+ lines.push("请只添加调试信息,不要顺手修改功能逻辑。");
668
+ lines.push("请优先添加 console.log,文字要清楚,适合小学生看懂。");
669
+ lines.push("请在关键步骤都加上信息,比如:有没有点到、进入了哪一步、重要变量现在是多少、为什么没有继续。");
670
+ lines.push("改完后告诉我:你在哪些地方加了提示、每条提示能帮我看出什么。");
671
+ return lines.join("\n");
672
+ }
673
+
674
+ var overlay = document.createElement("div");
675
+ overlay.id = "myclaw-log-modal";
676
+ overlay.className = "myclaw-debug-modal";
677
+
678
+ var box = document.createElement("div");
679
+ box.className = "myclaw-debug-box";
680
+
681
+ var header = document.createElement("div");
682
+ header.className = "myclaw-debug-header myclaw-log-header";
683
+ header.innerHTML = "<span>🧭 让 AI 加运行提示</span>";
684
+ var closeX = document.createElement("span");
685
+ closeX.textContent = "✕";
686
+ closeX.className = "myclaw-debug-close";
687
+ closeX.onclick = function () { closeLogModal(); };
688
+ header.appendChild(closeX);
689
+
690
+ var scroll = document.createElement("div");
691
+ scroll.className = "myclaw-debug-scroll";
692
+
693
+ var guide = document.createElement("div");
694
+ guide.className = "myclaw-debug-steps";
695
+ ["我想查什么问题", "哪一步最不确定", "想看到哪些变化"].forEach(function (text, index) {
696
+ var item = document.createElement("div");
697
+ item.className = "myclaw-debug-step";
698
+ var num = document.createElement("span");
699
+ num.className = "myclaw-debug-step-num";
700
+ num.textContent = String(index + 1) + ".";
701
+ var label = document.createElement("span");
702
+ label.textContent = text;
703
+ item.appendChild(num);
704
+ item.appendChild(label);
705
+ guide.appendChild(item);
706
+ });
707
+
708
+ var inputSection = document.createElement("div");
709
+ inputSection.appendChild(makeDebugLabel("按 1、2、3 的顺序说"));
710
+ var problemField = makeDebugVoiceInputField(
711
+ "1. 我想查为什么按钮点了没反应\n2. 我不确定点击后有没有进入判断\n3. 我想看到按钮有没有被点到、分数有没有变化",
712
+ 240,
713
+ function (val) {
714
+ state.problem = val;
715
+ refresh();
716
+ }
717
+ );
718
+ inputSection.appendChild(problemField.el);
719
+ logVoiceDestroyers.push(problemField.destroy);
720
+
721
+ scroll.appendChild(guide);
722
+ scroll.appendChild(inputSection);
723
+
724
+ var footer = document.createElement("div");
725
+ footer.className = "myclaw-debug-footer";
726
+
727
+ var submitBtn = document.createElement("button");
728
+ submitBtn.className = "myclaw-debug-submit myclaw-log-submit";
729
+ submitBtn.textContent = "➤ 发给 AI 加提示";
730
+ submitBtn.addEventListener("click", function () {
731
+ if (!hasLogInput()) return;
732
+ setTextareaValue(buildLogPrompt());
733
+ closeLogModal();
734
+ trySend();
735
+ });
736
+
737
+ function hasLogInput() {
738
+ return !!state.problem.trim();
739
+ }
740
+
741
+ function refresh() {
742
+ var ready = hasLogInput();
743
+ submitBtn.disabled = !ready;
744
+ submitBtn.style.opacity = ready ? "1" : "0.4";
745
+ submitBtn.style.cursor = ready ? "pointer" : "not-allowed";
746
+ }
747
+
748
+ footer.appendChild(submitBtn);
749
+ box.appendChild(header);
750
+ box.appendChild(scroll);
751
+ box.appendChild(footer);
752
+ overlay.appendChild(box);
753
+ document.body.appendChild(overlay);
754
+
755
+ refresh();
756
+ problemField.focus();
757
+ }
758
+
618
759
  // ═══ 3.1 Prompt 小助手按钮(实现见 myclaw-iteration.js) ═══
619
760
 
620
761
  function createPromptButton() {
@@ -819,6 +960,7 @@ btn.addEventListener("click", function () {
819
960
  if (!toolbar) return;
820
961
  if (
821
962
  toolbar.querySelector("#myclaw-debug-btn") &&
963
+ toolbar.querySelector("#myclaw-log-btn") &&
822
964
  toolbar.querySelector("#myclaw-prompt-btn") &&
823
965
  toolbar.querySelector("#myclaw-voice-btn")
824
966
  ) {
@@ -831,16 +973,18 @@ btn.addEventListener("click", function () {
831
973
  }
832
974
 
833
975
  var debugBtn = document.querySelector("#myclaw-debug-btn") || createDebugButton();
976
+ var logBtn = document.querySelector("#myclaw-log-btn") || createLogButton();
834
977
  var promptBtn = document.querySelector("#myclaw-prompt-btn") || createPromptButton();
835
978
  var voiceBtn = document.querySelector("#myclaw-voice-btn") || createVoiceButton();
836
979
 
837
- // 插入到工具栏最前面:debug 按钮在最左,prompt 和语音按钮依次靠右
838
- toolbar.insertBefore(voiceBtn, toolbar.firstChild);
839
- toolbar.insertBefore(promptBtn, voiceBtn);
840
- toolbar.insertBefore(debugBtn, promptBtn);
980
+ // 插入到工具栏最前面:语音、debug、log、prompt 依次靠右
981
+ toolbar.insertBefore(promptBtn, toolbar.firstChild);
982
+ toolbar.insertBefore(logBtn, promptBtn);
983
+ toolbar.insertBefore(debugBtn, logBtn);
984
+ toolbar.insertBefore(voiceBtn, debugBtn);
841
985
 
842
986
  injected = true;
843
- console.log("[myclaw-inject] \u2705 debug\u6309\u94ae + \u8bed\u97f3\u6309\u94ae + prompt\u6309\u94ae\u5df2\u6ce8\u5165");
987
+ console.log("[myclaw-inject] \u2705 \u8bed\u97f3/debug/log/prompt\u6309\u94ae\u5df2\u6ce8\u5165");
844
988
  }
845
989
 
846
990
  // ═══ 注入录音态样式 ═══
@@ -910,7 +1054,7 @@ btn.addEventListener("click", function () {
910
1054
  " to { opacity: 1; }",
911
1055
  "}",
912
1056
  /* Debug 提交弹框 */
913
- "#myclaw-debug-modal {",
1057
+ "#myclaw-debug-modal, #myclaw-log-modal {",
914
1058
  " position: fixed; inset: 0; z-index: 99999;",
915
1059
  " background: rgba(0,0,0,0.45);",
916
1060
  " display: flex; align-items: center; justify-content: center;",
@@ -929,6 +1073,9 @@ btn.addEventListener("click", function () {
929
1073
  " color: #fff; font-size: 15px; font-weight: bold;",
930
1074
  " font-family: -apple-system,sans-serif; user-select: none; flex-shrink: 0;",
931
1075
  "}",
1076
+ ".myclaw-log-header {",
1077
+ " background: linear-gradient(135deg,#0ea5e9,#6366f1);",
1078
+ "}",
932
1079
  ".myclaw-debug-close {",
933
1080
  " cursor: pointer; padding: 2px 8px; border-radius: 4px; font-size: 15px;",
934
1081
  "}",
@@ -965,7 +1112,9 @@ btn.addEventListener("click", function () {
965
1112
  " font-family: -apple-system,sans-serif; cursor: pointer; transition: all 0.15s;",
966
1113
  "}",
967
1114
  ".myclaw-debug-submit { background: #10b981; }",
1115
+ ".myclaw-log-submit { background: #0ea5e9; }",
968
1116
  ".myclaw-debug-submit:hover:not(:disabled) { background: #059669; }",
1117
+ ".myclaw-log-submit:hover:not(:disabled) { background: #0284c7; }",
969
1118
  ".myclaw-debug-submit:disabled {",
970
1119
  " cursor: not-allowed;",
971
1120
  "}",
@@ -2164,6 +2313,7 @@ btn.addEventListener("click", function () {
2164
2313
  new MutationObserver(function () {
2165
2314
  if (
2166
2315
  !document.querySelector("#myclaw-debug-btn") ||
2316
+ !document.querySelector("#myclaw-log-btn") ||
2167
2317
  !document.querySelector("#myclaw-prompt-btn") ||
2168
2318
  !document.querySelector("#myclaw-voice-btn")
2169
2319
  ) {
package/index.js CHANGED
@@ -2105,6 +2105,12 @@ async function runServer(name) {
2105
2105
  if (fs.existsSync(sourceDebugRecordPath)) {
2106
2106
  fs.copyFileSync(sourceDebugRecordPath, path.join(targetDir, 'debug_record.py'));
2107
2107
  }
2108
+ const sourceProbeJsPath = path.join(__dirname, 'assets', 'debug-probe.js');
2109
+ const targetAssetsDir = path.join(os.homedir(), '.openclaw', 'myclaw', 'assets');
2110
+ if (!fs.existsSync(targetAssetsDir)) fs.mkdirSync(targetAssetsDir, { recursive: true });
2111
+ if (fs.existsSync(sourceProbeJsPath)) {
2112
+ fs.copyFileSync(sourceProbeJsPath, path.join(targetAssetsDir, 'debug-probe.js'));
2113
+ }
2108
2114
  console.log('[Server] 同步脚本: ' + targetPyPath);
2109
2115
  fs.copyFileSync(sourceGuardPath, targetGuardPath);
2110
2116
  fs.chmodSync(targetGuardPath, 0o755);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.143",
3
+ "version": "1.1.145",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {