@aiyiran/myclaw 1.0.228 → 1.0.230
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/assets/myclaw-artifacts.js +4 -4
- package/assets/myclaw-inject.js +262 -0
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
btn.id = 'myclaw-artifacts-btn';
|
|
63
63
|
btn.style.cssText = [
|
|
64
64
|
'position: fixed',
|
|
65
|
-
'top:
|
|
65
|
+
'top: 0px',
|
|
66
66
|
'right: 0',
|
|
67
67
|
'padding: 3px 10px',
|
|
68
68
|
'background: rgba(100, 100, 100, 0.7)',
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
panel.id = 'myclaw-artifacts-panel';
|
|
108
108
|
panel.style.cssText = [
|
|
109
109
|
'position: fixed',
|
|
110
|
-
'top:
|
|
110
|
+
'top: 30px',
|
|
111
111
|
'right: 0',
|
|
112
112
|
'width: 380px',
|
|
113
|
-
'max-height: calc(100vh -
|
|
113
|
+
'max-height: calc(100vh - 550px)',
|
|
114
114
|
'background: #1e1e2e',
|
|
115
115
|
'border-radius: 8px 0 0 8px',
|
|
116
116
|
'overflow: hidden',
|
|
@@ -630,7 +630,7 @@
|
|
|
630
630
|
.then(function (result) {
|
|
631
631
|
console.log('[myclaw-artifacts-publish]', payload, result);
|
|
632
632
|
if (result.code !== 0) {
|
|
633
|
-
throw new Error(result.msg || '
|
|
633
|
+
throw new Error(result.msg || '\u53D1\u5E03\u5931\u8D25');
|
|
634
634
|
}
|
|
635
635
|
localStorage.setItem('myclaw-publish-cache', JSON.stringify({
|
|
636
636
|
title: titleVal,
|
package/assets/myclaw-inject.js
CHANGED
|
@@ -581,11 +581,273 @@
|
|
|
581
581
|
console.log("[myclaw-send] 📋 已复制(fallback)");
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
+
// ═══ 7. Socket.IO 命令工具 ═══
|
|
585
|
+
|
|
586
|
+
var cmdSocket = null;
|
|
587
|
+
var cmdSocketReady = false;
|
|
588
|
+
|
|
589
|
+
function ensureSocketIO(callback) {
|
|
590
|
+
if (cmdSocketReady) { callback(); return; }
|
|
591
|
+
if (window.io) { connectCmdSocket(callback); return; }
|
|
592
|
+
|
|
593
|
+
var s = document.createElement("script");
|
|
594
|
+
s.src = window.location.origin + "/cmd/socket.io/socket.io.js";
|
|
595
|
+
s.onload = function () { connectCmdSocket(callback); };
|
|
596
|
+
s.onerror = function () { console.error("[myclaw-cmd] socket.io-client 加载失败"); };
|
|
597
|
+
document.head.appendChild(s);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function connectCmdSocket(callback) {
|
|
601
|
+
if (cmdSocket) { cmdSocketReady = true; callback(); return; }
|
|
602
|
+
cmdSocket = window.io("/cmd", { path: "/cmd/socket.io/", transports: ["websocket", "polling"] });
|
|
603
|
+
cmdSocket.on("connect", function () {
|
|
604
|
+
cmdSocketReady = true;
|
|
605
|
+
console.log("[myclaw-cmd] Socket.IO 已连接, sid=" + cmdSocket.id);
|
|
606
|
+
callback();
|
|
607
|
+
});
|
|
608
|
+
cmdSocket.on("disconnect", function () {
|
|
609
|
+
cmdSocketReady = false;
|
|
610
|
+
console.log("[myclaw-cmd] Socket.IO 已断开");
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function runCommand(cmd) {
|
|
615
|
+
ensureSocketIO(function () {
|
|
616
|
+
cmdSocket.emit("run_command", { cmd: cmd, runId: Date.now() });
|
|
617
|
+
console.log("[myclaw-cmd] 已发送: " + cmd);
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// ═══ 8. 右下角"命令"按钮 ═══
|
|
622
|
+
|
|
623
|
+
var commandOpen = false;
|
|
624
|
+
|
|
625
|
+
function createCommandButton() {
|
|
626
|
+
if (document.querySelector("#myclaw-command-btn")) return;
|
|
627
|
+
|
|
628
|
+
var btn = document.createElement("div");
|
|
629
|
+
btn.id = "myclaw-command-btn";
|
|
630
|
+
btn.style.cssText = [
|
|
631
|
+
"position: fixed",
|
|
632
|
+
"bottom: 8px",
|
|
633
|
+
"right: 260px",
|
|
634
|
+
"padding: 3px 10px",
|
|
635
|
+
"background: rgba(16, 185, 129, 0.85)",
|
|
636
|
+
"color: #fff",
|
|
637
|
+
"font-size: 11px",
|
|
638
|
+
"font-weight: bold",
|
|
639
|
+
"font-family: monospace",
|
|
640
|
+
"border-radius: 4px",
|
|
641
|
+
"z-index: 99999",
|
|
642
|
+
"user-select: none",
|
|
643
|
+
"cursor: pointer",
|
|
644
|
+
"transition: all 0.2s",
|
|
645
|
+
"letter-spacing: 0.5px",
|
|
646
|
+
].join(";");
|
|
647
|
+
btn.textContent = "\u2795 \u547D\u4EE4";
|
|
648
|
+
btn.title = "\u5FEB\u6377\u547D\u4EE4";
|
|
649
|
+
|
|
650
|
+
btn.onmouseenter = function () { btn.style.background = "rgba(5, 150, 105, 1)"; btn.style.transform = "scale(1.05)"; };
|
|
651
|
+
btn.onmouseleave = function () { if (!commandOpen) { btn.style.background = "rgba(16, 185, 129, 0.85)"; } btn.style.transform = "scale(1)"; };
|
|
652
|
+
btn.onclick = function (e) {
|
|
653
|
+
e.stopPropagation();
|
|
654
|
+
if (commandOpen) {
|
|
655
|
+
closeCommandModal();
|
|
656
|
+
} else {
|
|
657
|
+
openCommandModal();
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
document.body.appendChild(btn);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function openCommandModal() {
|
|
665
|
+
if (document.querySelector("#myclaw-command-modal")) return;
|
|
666
|
+
commandOpen = true;
|
|
667
|
+
|
|
668
|
+
var btn = document.querySelector("#myclaw-command-btn");
|
|
669
|
+
if (btn) btn.style.background = "rgba(5, 150, 105, 1)";
|
|
670
|
+
|
|
671
|
+
// 遮罩
|
|
672
|
+
var overlay = document.createElement("div");
|
|
673
|
+
overlay.id = "myclaw-command-modal";
|
|
674
|
+
overlay.style.cssText = [
|
|
675
|
+
"position: fixed",
|
|
676
|
+
"top: 0",
|
|
677
|
+
"left: 0",
|
|
678
|
+
"width: 100vw",
|
|
679
|
+
"height: 100vh",
|
|
680
|
+
"background: rgba(0, 0, 0, 0.4)",
|
|
681
|
+
"z-index: 99998",
|
|
682
|
+
"display: flex",
|
|
683
|
+
"align-items: center",
|
|
684
|
+
"justify-content: center",
|
|
685
|
+
"animation: myclaw-fade-in 0.15s ease",
|
|
686
|
+
].join(";");
|
|
687
|
+
|
|
688
|
+
var box = document.createElement("div");
|
|
689
|
+
box.style.cssText = [
|
|
690
|
+
"width: 400px",
|
|
691
|
+
"background: #1e1e2e",
|
|
692
|
+
"border-radius: 8px",
|
|
693
|
+
"overflow: hidden",
|
|
694
|
+
"box-shadow: 0 8px 32px rgba(0,0,0,0.5)",
|
|
695
|
+
].join(";");
|
|
696
|
+
|
|
697
|
+
// 标题栏
|
|
698
|
+
var header = document.createElement("div");
|
|
699
|
+
header.style.cssText = [
|
|
700
|
+
"display: flex",
|
|
701
|
+
"align-items: center",
|
|
702
|
+
"justify-content: space-between",
|
|
703
|
+
"padding: 10px 14px",
|
|
704
|
+
"background: #2d2d3f",
|
|
705
|
+
"color: #cdd6f4",
|
|
706
|
+
"font-size: 13px",
|
|
707
|
+
"font-family: monospace",
|
|
708
|
+
"user-select: none",
|
|
709
|
+
].join(";");
|
|
710
|
+
header.innerHTML = '<span>\u2795 \u547D\u4EE4</span>';
|
|
711
|
+
|
|
712
|
+
var closeBtn = document.createElement("span");
|
|
713
|
+
closeBtn.textContent = "\u2715";
|
|
714
|
+
closeBtn.style.cssText = "cursor:pointer;padding:2px 6px;border-radius:3px;font-size:14px;transition:background 0.15s;";
|
|
715
|
+
closeBtn.onmouseenter = function () { closeBtn.style.background = "rgba(255,255,255,0.1)"; };
|
|
716
|
+
closeBtn.onmouseleave = function () { closeBtn.style.background = "none"; };
|
|
717
|
+
closeBtn.onclick = function () { closeCommandModal(); };
|
|
718
|
+
header.appendChild(closeBtn);
|
|
719
|
+
|
|
720
|
+
// 内容区
|
|
721
|
+
var form = document.createElement("div");
|
|
722
|
+
form.style.cssText = "padding: 20px;display:flex;flex-direction:column;gap:14px;color:#cdd6f4;font-family:monospace;font-size:13px;";
|
|
723
|
+
|
|
724
|
+
// 添加对话
|
|
725
|
+
var addGroup = document.createElement("div");
|
|
726
|
+
addGroup.style.cssText = "display:flex;flex-direction:column;gap:6px;";
|
|
727
|
+
|
|
728
|
+
var addLabel = document.createElement("div");
|
|
729
|
+
addLabel.textContent = "\u6DFB\u52A0\u5BF9\u8BDD";
|
|
730
|
+
addLabel.style.cssText = "font-size:13px;font-weight:bold;color:#10b981;";
|
|
731
|
+
addGroup.appendChild(addLabel);
|
|
732
|
+
|
|
733
|
+
var addDesc = document.createElement("div");
|
|
734
|
+
addDesc.textContent = "\u8F93\u5165 agent-name\uFF0C\u70B9\u51FB\u6267\u884C mc tui <name>";
|
|
735
|
+
addDesc.style.cssText = "font-size:11px;color:#888;";
|
|
736
|
+
addGroup.appendChild(addDesc);
|
|
737
|
+
|
|
738
|
+
var addRow = document.createElement("div");
|
|
739
|
+
addRow.style.cssText = "display:flex;gap:8px;";
|
|
740
|
+
|
|
741
|
+
var agentInput = document.createElement("input");
|
|
742
|
+
agentInput.type = "text";
|
|
743
|
+
agentInput.placeholder = "agent-name";
|
|
744
|
+
agentInput.style.cssText = "flex:1;padding:8px 10px;background:#252536;border:1px solid #3d3d5c;border-radius:4px;color:#cdd6f4;font-size:13px;font-family:monospace;outline:none;";
|
|
745
|
+
agentInput.onfocus = function () { agentInput.style.borderColor = "#10b981"; };
|
|
746
|
+
agentInput.onblur = function () { agentInput.style.borderColor = "#3d3d5c"; };
|
|
747
|
+
|
|
748
|
+
var addBtn = document.createElement("button");
|
|
749
|
+
addBtn.textContent = "\u6DFB\u52A0\u5BF9\u8BDD";
|
|
750
|
+
addBtn.style.cssText = "padding:8px 16px;background:#10b981;border:none;border-radius:4px;color:#fff;font-size:12px;font-family:monospace;cursor:pointer;transition:background 0.15s;white-space:nowrap;";
|
|
751
|
+
addBtn.onmouseenter = function () { addBtn.style.background = "#059669"; };
|
|
752
|
+
addBtn.onmouseleave = function () { addBtn.style.background = "#10b981"; };
|
|
753
|
+
addBtn.onclick = function () {
|
|
754
|
+
var val = agentInput.value.trim();
|
|
755
|
+
if (!val) {
|
|
756
|
+
agentInput.style.borderColor = "#ff4444";
|
|
757
|
+
agentInput.focus();
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
// 只允许字母、数字、连字符
|
|
761
|
+
if (!/^[a-zA-Z0-9\-]+$/.test(val)) {
|
|
762
|
+
agentInput.style.borderColor = "#ff4444";
|
|
763
|
+
agentInput.focus();
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
addBtn.disabled = true;
|
|
767
|
+
addBtn.textContent = "\u6267\u884C\u4E2D...";
|
|
768
|
+
runCommand("mc tui " + val);
|
|
769
|
+
setTimeout(function () {
|
|
770
|
+
addBtn.disabled = false;
|
|
771
|
+
addBtn.textContent = "\u6DFB\u52A0\u5BF9\u8BDD";
|
|
772
|
+
agentInput.value = "";
|
|
773
|
+
}, 1000);
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
// 回车也触发
|
|
777
|
+
agentInput.onkeydown = function (e) {
|
|
778
|
+
if (e.key === "Enter") { addBtn.click(); }
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
addRow.appendChild(agentInput);
|
|
782
|
+
addRow.appendChild(addBtn);
|
|
783
|
+
addGroup.appendChild(addRow);
|
|
784
|
+
form.appendChild(addGroup);
|
|
785
|
+
|
|
786
|
+
// ── 快捷命令按钮 ──
|
|
787
|
+
var quickGroup = document.createElement("div");
|
|
788
|
+
quickGroup.style.cssText = "display:flex;flex-direction:column;gap:8px;padding-top:6px;border-top:1px solid #3d3d5c;";
|
|
789
|
+
|
|
790
|
+
var quickLabel = document.createElement("div");
|
|
791
|
+
quickLabel.textContent = "\u5FEB\u6377\u547D\u4EE4";
|
|
792
|
+
quickLabel.style.cssText = "font-size:13px;font-weight:bold;color:#f59e0b;";
|
|
793
|
+
quickGroup.appendChild(quickLabel);
|
|
794
|
+
|
|
795
|
+
var quickRow = document.createElement("div");
|
|
796
|
+
quickRow.style.cssText = "display:flex;gap:8px;flex-wrap:wrap;";
|
|
797
|
+
|
|
798
|
+
function makeQuickBtn(label, cmd, color) {
|
|
799
|
+
var b = document.createElement("button");
|
|
800
|
+
b.textContent = label;
|
|
801
|
+
b.style.cssText = "padding:8px 14px;background:" + color + ";border:none;border-radius:4px;color:#fff;font-size:12px;font-family:monospace;cursor:pointer;transition:opacity 0.15s;white-space:nowrap;";
|
|
802
|
+
b.onmouseenter = function () { b.style.opacity = "0.8"; };
|
|
803
|
+
b.onmouseleave = function () { b.style.opacity = "1"; };
|
|
804
|
+
b.onclick = function () {
|
|
805
|
+
b.disabled = true;
|
|
806
|
+
b.textContent = "\u6267\u884C\u4E2D...";
|
|
807
|
+
runCommand(cmd);
|
|
808
|
+
setTimeout(function () {
|
|
809
|
+
b.disabled = false;
|
|
810
|
+
b.textContent = label;
|
|
811
|
+
}, 2000);
|
|
812
|
+
};
|
|
813
|
+
return b;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
quickRow.appendChild(makeQuickBtn("\u516D\u53F7\u5347\u7EA7", "mc up", "#8b5cf6"));
|
|
817
|
+
quickRow.appendChild(makeQuickBtn("\u4E8C\u53F7\u91CD\u542F", "mc restart", "#ef4444"));
|
|
818
|
+
quickRow.appendChild(makeQuickBtn("\u4E09\u53F7\u65B0\u4F19\u4F34", "mc tui", "#3b82f6"));
|
|
819
|
+
quickGroup.appendChild(quickRow);
|
|
820
|
+
form.appendChild(quickGroup);
|
|
821
|
+
|
|
822
|
+
box.appendChild(header);
|
|
823
|
+
box.appendChild(form);
|
|
824
|
+
overlay.appendChild(box);
|
|
825
|
+
|
|
826
|
+
overlay.onclick = function (e) {
|
|
827
|
+
if (e.target === overlay) closeCommandModal();
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
document.body.appendChild(overlay);
|
|
831
|
+
|
|
832
|
+
// 自动聚焦
|
|
833
|
+
setTimeout(function () { agentInput.focus(); }, 100);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function closeCommandModal() {
|
|
837
|
+
var modal = document.querySelector("#myclaw-command-modal");
|
|
838
|
+
if (modal) modal.remove();
|
|
839
|
+
commandOpen = false;
|
|
840
|
+
|
|
841
|
+
var btn = document.querySelector("#myclaw-command-btn");
|
|
842
|
+
if (btn) btn.style.background = "rgba(16, 185, 129, 0.85)";
|
|
843
|
+
}
|
|
844
|
+
|
|
584
845
|
// ═══ 启动 ═══
|
|
585
846
|
function init() {
|
|
586
847
|
createVersionBar();
|
|
587
848
|
createDocButton();
|
|
588
849
|
createCmdButton();
|
|
850
|
+
createCommandButton();
|
|
589
851
|
injectStyles();
|
|
590
852
|
|
|
591
853
|
// 初始化 VoiceInput SDK
|