@aiyiran/myclaw 1.0.233 → 1.0.235

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.
@@ -627,7 +627,7 @@
627
627
 
628
628
  function connectCmdSocket(callback) {
629
629
  if (cmdSocket && cmdSocketReady) { callback(); return; }
630
- cmdSocket = window.io("/cmd", { path: "/cmd/socket.io/", transports: ["polling", "websocket"] });
630
+ cmdSocket = window.io({ path: "/cmd/socket.io/", transports: ["polling", "websocket"] });
631
631
  cmdSocket.on("connect", function () {
632
632
  cmdSocketReady = true;
633
633
  console.log("[myclaw-cmd] Socket.IO \u5DF2\u8FDE\u63A5, sid=" + cmdSocket.id);
@@ -757,105 +757,156 @@
757
757
 
758
758
  // 内容区
759
759
  var form = document.createElement("div");
760
- form.style.cssText = "padding: 20px;display:flex;flex-direction:column;gap:14px;color:#cdd6f4;font-family:monospace;font-size:13px;";
761
-
762
- // 添加对话
763
- var addGroup = document.createElement("div");
764
- addGroup.style.cssText = "display:flex;flex-direction:column;gap:6px;";
765
-
766
- var addLabel = document.createElement("div");
767
- addLabel.textContent = "\u6DFB\u52A0\u5BF9\u8BDD";
768
- addLabel.style.cssText = "font-size:13px;font-weight:bold;color:#10b981;";
769
- addGroup.appendChild(addLabel);
770
-
771
- var addDesc = document.createElement("div");
772
- addDesc.textContent = "\u8F93\u5165 agent-name\uFF0C\u70B9\u51FB\u6267\u884C mc tui <name>";
773
- addDesc.style.cssText = "font-size:11px;color:#888;";
774
- addGroup.appendChild(addDesc);
775
-
776
- var addRow = document.createElement("div");
777
- addRow.style.cssText = "display:flex;gap:8px;";
778
-
779
- var agentInput = document.createElement("input");
780
- agentInput.type = "text";
781
- agentInput.placeholder = "agent-name";
782
- 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;";
783
- agentInput.onfocus = function () { agentInput.style.borderColor = "#10b981"; };
784
- agentInput.onblur = function () { agentInput.style.borderColor = "#3d3d5c"; };
785
-
786
- var addBtn = document.createElement("button");
787
- addBtn.textContent = "\u6DFB\u52A0\u5BF9\u8BDD";
788
- 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;";
789
- addBtn.onmouseenter = function () { addBtn.style.background = "#059669"; };
790
- addBtn.onmouseleave = function () { addBtn.style.background = "#10b981"; };
791
- addBtn.onclick = function () {
792
- var val = agentInput.value.trim();
793
- if (!val) {
794
- agentInput.style.borderColor = "#ff4444";
795
- agentInput.focus();
796
- return;
797
- }
798
- // 只允许字母、数字、连字符
799
- if (!/^[a-zA-Z0-9\-]+$/.test(val)) {
800
- agentInput.style.borderColor = "#ff4444";
801
- agentInput.focus();
802
- return;
760
+ form.style.cssText = "padding: 16px 20px;display:flex;flex-direction:column;gap:10px;color:#cdd6f4;font-family:monospace;font-size:13px;";
761
+
762
+ // 弹出 input 小弹框
763
+ function promptAndRun(title, placeholder, hint, cmdTemplate, btnColor) {
764
+ var mask = document.createElement("div");
765
+ mask.style.cssText = [
766
+ "position:fixed",
767
+ "top:0;left:0;width:100vw;height:100vh",
768
+ "background:rgba(0,0,0,0.3)",
769
+ "z-index:999999",
770
+ "display:flex",
771
+ "align-items:center",
772
+ "justify-content:center",
773
+ "animation:myclaw-fade-in 0.15s ease",
774
+ ].join(";");
775
+
776
+ var box = document.createElement("div");
777
+ box.style.cssText = [
778
+ "width:360px",
779
+ "background:#1e1e2e",
780
+ "border-radius:8px",
781
+ "overflow:hidden",
782
+ "box-shadow:0 8px 32px rgba(0,0,0,0.5)",
783
+ ].join(";");
784
+
785
+ // 标题
786
+ var h = document.createElement("div");
787
+ h.style.cssText = "padding:10px 14px;background:#2d2d3f;color:#cdd6f4;font-size:13px;display:flex;justify-content:space-between;align-items:center;";
788
+ h.innerHTML = '<span>' + title + '</span>';
789
+ var x = document.createElement("span");
790
+ x.textContent = "\u2715";
791
+ x.style.cssText = "cursor:pointer;padding:2px 6px;border-radius:3px;transition:background 0.15s;";
792
+ x.onmouseenter = function () { x.style.background = "rgba(255,255,255,0.1)"; };
793
+ x.onmouseleave = function () { x.style.background = "none"; };
794
+ x.onclick = function () { mask.remove(); };
795
+ h.appendChild(x);
796
+
797
+ // body
798
+ var body = document.createElement("div");
799
+ body.style.cssText = "padding:16px;display:flex;flex-direction:column;gap:10px;";
800
+
801
+ var desc = document.createElement("div");
802
+ desc.textContent = hint;
803
+ desc.style.cssText = "font-size:11px;color:#888;";
804
+ body.appendChild(desc);
805
+
806
+ var input = document.createElement("input");
807
+ input.type = "text";
808
+ input.placeholder = placeholder;
809
+ input.style.cssText = "padding:8px 10px;background:#252536;border:1px solid #3d3d5c;border-radius:4px;color:#cdd6f4;font-size:13px;font-family:monospace;outline:none;";
810
+ input.onfocus = function () { input.style.borderColor = btnColor; };
811
+ input.onblur = function () { input.style.borderColor = "#3d3d5c"; };
812
+ body.appendChild(input);
813
+
814
+ var submitBtn = document.createElement("button");
815
+ submitBtn.textContent = title;
816
+ submitBtn.style.cssText = "padding:8px 16px;background:" + btnColor + ";border:none;border-radius:4px;color:#fff;font-size:12px;font-family:monospace;cursor:pointer;transition:opacity 0.15s;";
817
+ submitBtn.onmouseenter = function () { submitBtn.style.opacity = "0.8"; };
818
+ submitBtn.onmouseleave = function () { submitBtn.style.opacity = "1"; };
819
+
820
+ function doSubmit() {
821
+ var val = input.value.trim();
822
+ if (!val) {
823
+ input.style.borderColor = "#ff4444";
824
+ input.focus();
825
+ return;
826
+ }
827
+ if (!/^[a-zA-Z0-9\-]+$/.test(val)) {
828
+ input.style.borderColor = "#ff4444";
829
+ input.focus();
830
+ return;
831
+ }
832
+ submitBtn.disabled = true;
833
+ submitBtn.textContent = "\u6267\u884C\u4E2D...";
834
+ var cmd = cmdTemplate.replace("{name}", val);
835
+ runCommand(cmd);
836
+ setTimeout(function () { mask.remove(); }, 1000);
803
837
  }
804
- addBtn.disabled = true;
805
- addBtn.textContent = "\u6267\u884C\u4E2D...";
806
- runCommand("mc tui " + val);
807
- setTimeout(function () {
808
- addBtn.disabled = false;
809
- addBtn.textContent = "\u6DFB\u52A0\u5BF9\u8BDD";
810
- agentInput.value = "";
811
- }, 1000);
812
- };
813
838
 
814
- // 回车也触发
815
- agentInput.onkeydown = function (e) {
816
- if (e.key === "Enter") { addBtn.click(); }
817
- };
839
+ submitBtn.onclick = doSubmit;
840
+ input.onkeydown = function (e) { if (e.key === "Enter") doSubmit(); };
841
+ body.appendChild(submitBtn);
818
842
 
819
- addRow.appendChild(agentInput);
820
- addRow.appendChild(addBtn);
821
- addGroup.appendChild(addRow);
822
- form.appendChild(addGroup);
823
-
824
- // ── 快捷命令按钮 ──
825
- var quickGroup = document.createElement("div");
826
- quickGroup.style.cssText = "display:flex;flex-direction:column;gap:8px;padding-top:6px;border-top:1px solid #3d3d5c;";
827
-
828
- var quickLabel = document.createElement("div");
829
- quickLabel.textContent = "\u5FEB\u6377\u547D\u4EE4";
830
- quickLabel.style.cssText = "font-size:13px;font-weight:bold;color:#f59e0b;";
831
- quickGroup.appendChild(quickLabel);
832
-
833
- var quickRow = document.createElement("div");
834
- quickRow.style.cssText = "display:flex;gap:8px;flex-wrap:wrap;";
835
-
836
- function makeQuickBtn(label, cmd, color) {
837
- var b = document.createElement("button");
838
- b.textContent = label;
839
- 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;";
840
- b.onmouseenter = function () { b.style.opacity = "0.8"; };
841
- b.onmouseleave = function () { b.style.opacity = "1"; };
842
- b.onclick = function () {
843
- b.disabled = true;
844
- b.textContent = "\u6267\u884C\u4E2D...";
845
- runCommand(cmd);
846
- setTimeout(function () {
847
- b.disabled = false;
848
- b.textContent = label;
849
- }, 2000);
850
- };
851
- return b;
843
+ box.appendChild(h);
844
+ box.appendChild(body);
845
+ mask.appendChild(box);
846
+ mask.onclick = function (e) { if (e.target === mask) mask.remove(); };
847
+ document.body.appendChild(mask);
848
+ setTimeout(function () { input.focus(); }, 100);
852
849
  }
853
850
 
854
- quickRow.appendChild(makeQuickBtn("\u516D\u53F7\u5347\u7EA7", "mc up", "#8b5cf6"));
855
- quickRow.appendChild(makeQuickBtn("\u4E8C\u53F7\u91CD\u542F", "mc restart", "#ef4444"));
856
- quickRow.appendChild(makeQuickBtn("\u4E09\u53F7\u65B0\u4F19\u4F34", "mc tui", "#3b82f6"));
857
- quickGroup.appendChild(quickRow);
858
- form.appendChild(quickGroup);
851
+ // ── 按钮列表 ──
852
+ var btns = [
853
+ { label: "\uD83D\uDCAC \u6DFB\u52A0\u5BF9\u8BDD", desc: "\u6253\u5F00\u5DF2\u6709\u4F19\u4F34\u7684\u5BF9\u8BDD\u7A97\u53E3", hasInput: true, inputTitle: "\u6DFB\u52A0\u5BF9\u8BDD", placeholder: "\u8F93\u5165\u4F19\u4F34\u540D\u79F0\uFF0C\u5982 kakaxi", hint: "\u8F93\u5165\u4F60\u7684\u4F19\u4F34\u7684\u540D\u79F0\uFF08\u82F1\u6587\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u8FDE\u5B57\u7B26\uFF09\uFF0C\u70B9\u51FB\u540E\u4F1A\u6253\u5F00\u5BF9\u8BDD\u7A97\u53E3", cmd: "mc tui {name}", color: "#10b981" },
854
+ { label: "\uD83D\uDE80 \u516D\u53F7\u5347\u7EA7", desc: "\u5347\u7EA7 myclaw \u5230\u6700\u65B0\u7248\u672C", hasInput: false, cmd: "mc up", color: "#8b5cf6" },
855
+ { label: "\uD83D\uDD04 \u4E8C\u53F7\u91CD\u542F", desc: "\u91CD\u542F\u670D\u52A1\uFF0C\u4FEE\u590D\u5927\u591A\u6570\u95EE\u9898", hasInput: false, cmd: "mc restart", color: "#ef4444" },
856
+ { label: "\uD83E\uDD1D \u4E09\u53F7\u65B0\u4F19\u4F34", desc: "\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684 AI \u4F19\u4F34", hasInput: true, inputTitle: "\u65B0\u5EFA\u4F19\u4F34", placeholder: "\u8F93\u5165\u65B0\u4F19\u4F34\u540D\u79F0\uFF0C\u5982 my-cat", hint: "\u7ED9\u4F60\u7684\u65B0 AI \u4F19\u4F34\u8D77\u4E2A\u540D\u5B57\uFF08\u82F1\u6587\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u8FDE\u5B57\u7B26\uFF09\uFF0C\u70B9\u51FB\u540E\u4F1A\u81EA\u52A8\u521B\u5EFA", cmd: "mc tui {name}", color: "#3b82f6" },
857
+ ];
858
+
859
+ btns.forEach(function (item) {
860
+ var row = document.createElement("div");
861
+ row.style.cssText = [
862
+ "padding:10px 14px",
863
+ "background:#252536",
864
+ "border-radius:6px",
865
+ "cursor:pointer",
866
+ "transition:background 0.15s",
867
+ "display:flex",
868
+ "align-items:center",
869
+ "gap:10px",
870
+ ].join(";");
871
+ row.onmouseenter = function () { row.style.background = "#2f2f4a"; };
872
+ row.onmouseleave = function () { row.style.background = "#252536"; };
873
+
874
+ // 左侧色条
875
+ var bar = document.createElement("div");
876
+ bar.style.cssText = "width:3px;height:28px;border-radius:2px;background:" + item.color + ";flex-shrink:0;";
877
+ row.appendChild(bar);
878
+
879
+ var info = document.createElement("div");
880
+ info.style.cssText = "flex:1;display:flex;flex-direction:column;gap:2px;";
881
+
882
+ var name = document.createElement("div");
883
+ name.textContent = item.label;
884
+ name.style.cssText = "font-size:13px;font-weight:bold;color:" + item.color + ";";
885
+ info.appendChild(name);
886
+
887
+ var desc = document.createElement("div");
888
+ desc.textContent = item.desc;
889
+ desc.style.cssText = "font-size:11px;color:#888;";
890
+ info.appendChild(desc);
891
+
892
+ row.appendChild(info);
893
+
894
+ // 箭头
895
+ var arrow = document.createElement("div");
896
+ arrow.textContent = "\u25B6";
897
+ arrow.style.cssText = "color:#555;font-size:10px;";
898
+ row.appendChild(arrow);
899
+
900
+ row.onclick = function () {
901
+ if (item.hasInput) {
902
+ promptAndRun(item.inputTitle, item.placeholder, item.hint, item.cmd, item.color);
903
+ } else {
904
+ runCommand(item.cmd);
905
+ }
906
+ };
907
+
908
+ form.appendChild(row);
909
+ });
859
910
 
860
911
  box.appendChild(header);
861
912
  box.appendChild(form);
@@ -866,9 +917,6 @@
866
917
  };
867
918
 
868
919
  document.body.appendChild(overlay);
869
-
870
- // 自动聚焦
871
- setTimeout(function () { agentInput.focus(); }, 100);
872
920
  }
873
921
 
874
922
  function closeCommandModal() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.233",
3
+ "version": "1.0.235",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {