@aiyiran/myclaw 1.0.189 → 1.0.191

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.
@@ -94,6 +94,140 @@
94
94
  document.body.appendChild(btn);
95
95
  }
96
96
 
97
+ // ═══ 1.2 右下角 CMD 按钮(弹框 iframe) ═══
98
+ var cmdOpen = false;
99
+
100
+ function createCmdButton() {
101
+ if (document.querySelector("#myclaw-cmd-btn")) return;
102
+
103
+ var btn = document.createElement("div");
104
+ btn.id = "myclaw-cmd-btn";
105
+ btn.style.cssText = [
106
+ "position: fixed",
107
+ "bottom: 8px",
108
+ "right: 130px",
109
+ "padding: 3px 10px",
110
+ "background: rgba(59, 130, 246, 0.85)",
111
+ "color: #fff",
112
+ "font-size: 11px",
113
+ "font-weight: bold",
114
+ "font-family: monospace",
115
+ "border-radius: 4px",
116
+ "z-index: 99999",
117
+ "user-select: none",
118
+ "cursor: pointer",
119
+ "transition: all 0.2s",
120
+ "letter-spacing: 0.5px",
121
+ ].join(";");
122
+ btn.textContent = "\u2328 CMD";
123
+ btn.title = "\u6253\u5F00\u547D\u4EE4\u884C";
124
+
125
+ btn.onmouseenter = function () { btn.style.background = "rgba(37, 99, 235, 1)"; btn.style.transform = "scale(1.05)"; };
126
+ btn.onmouseleave = function () { if (!cmdOpen) { btn.style.background = "rgba(59, 130, 246, 0.85)"; } btn.style.transform = "scale(1)"; };
127
+ btn.onclick = function (e) {
128
+ e.stopPropagation();
129
+ if (cmdOpen) {
130
+ closeCmdModal();
131
+ } else {
132
+ openCmdModal();
133
+ }
134
+ };
135
+
136
+ document.body.appendChild(btn);
137
+ }
138
+
139
+ function openCmdModal() {
140
+ if (document.querySelector("#myclaw-cmd-modal")) return;
141
+ cmdOpen = true;
142
+
143
+ // 按钮 active 态
144
+ var btn = document.querySelector("#myclaw-cmd-btn");
145
+ if (btn) btn.style.background = "rgba(37, 99, 235, 1)";
146
+
147
+ // 遮罩
148
+ var overlay = document.createElement("div");
149
+ overlay.id = "myclaw-cmd-modal";
150
+ overlay.style.cssText = [
151
+ "position: fixed",
152
+ "top: 0",
153
+ "left: 0",
154
+ "width: 100vw",
155
+ "height: 100vh",
156
+ "background: rgba(0, 0, 0, 0.3)",
157
+ "z-index: 99998",
158
+ "display: flex",
159
+ "align-items: center",
160
+ "justify-content: center",
161
+ "animation: myclaw-fade-in 0.15s ease",
162
+ ].join(";");
163
+
164
+ // 弹框容器 — 尽可能大,只留小边距
165
+ var box = document.createElement("div");
166
+ box.style.cssText = [
167
+ "width: 98vw",
168
+ "height: 96vh",
169
+ "background: #1e1e2e",
170
+ "border-radius: 8px",
171
+ "overflow: hidden",
172
+ "display: flex",
173
+ "flex-direction: column",
174
+ "box-shadow: 0 8px 32px rgba(0,0,0,0.4)",
175
+ ].join(";");
176
+
177
+ // 标题栏
178
+ var header = document.createElement("div");
179
+ header.style.cssText = [
180
+ "display: flex",
181
+ "align-items: center",
182
+ "justify-content: space-between",
183
+ "padding: 8px 14px",
184
+ "background: #2d2d3f",
185
+ "color: #cdd6f4",
186
+ "font-size: 13px",
187
+ "font-family: monospace",
188
+ "user-select: none",
189
+ ].join(";");
190
+ header.innerHTML = '<span>\u2328 Terminal</span>';
191
+
192
+ var closeBtn = document.createElement("span");
193
+ closeBtn.textContent = "\u2715";
194
+ closeBtn.style.cssText = "cursor:pointer;padding:2px 6px;border-radius:3px;font-size:14px;transition:background 0.15s;";
195
+ closeBtn.onmouseenter = function () { closeBtn.style.background = "rgba(255,255,255,0.1)"; };
196
+ closeBtn.onmouseleave = function () { closeBtn.style.background = "none"; };
197
+ closeBtn.onclick = function () { closeCmdModal(); };
198
+ header.appendChild(closeBtn);
199
+
200
+ // iframe
201
+ var iframe = document.createElement("iframe");
202
+ iframe.src = window.location.origin + "/cmd";
203
+ iframe.style.cssText = [
204
+ "flex: 1",
205
+ "width: 100%",
206
+ "border: none",
207
+ "background: #1e1e2e",
208
+ ].join(";");
209
+
210
+ box.appendChild(header);
211
+ box.appendChild(iframe);
212
+ overlay.appendChild(box);
213
+
214
+ // 点击遮罩关闭
215
+ overlay.onclick = function (e) {
216
+ if (e.target === overlay) closeCmdModal();
217
+ };
218
+
219
+ document.body.appendChild(overlay);
220
+ }
221
+
222
+ function closeCmdModal() {
223
+ var modal = document.querySelector("#myclaw-cmd-modal");
224
+ if (modal) modal.remove();
225
+ cmdOpen = false;
226
+
227
+ var btn = document.querySelector("#myclaw-cmd-btn");
228
+ if (btn) btn.style.background = "rgba(59, 130, 246, 0.85)";
229
+ }
230
+
97
231
  // \u6D4B\u8BD5\u9EA6\u514B\u98CE\u51FD\u6570
98
232
  function testMicrophone() {
99
233
  console.log("[myclaw] \u5F00\u59CB\u6D4B\u8BD5\u9EA6\u514B\u98CE...");
@@ -378,6 +512,11 @@
378
512
  " 0% { transform: scale(0.8); opacity: 0.8; }",
379
513
  " 100% { transform: scale(1.6); opacity: 0; }",
380
514
  "}",
515
+ /* CMD 弹框淡入 */
516
+ "@keyframes myclaw-fade-in {",
517
+ " from { opacity: 0; }",
518
+ " to { opacity: 1; }",
519
+ "}",
381
520
  ].join("\n");
382
521
  document.head.appendChild(style);
383
522
  }
@@ -446,6 +585,7 @@
446
585
  function init() {
447
586
  createVersionBar();
448
587
  createDocButton();
588
+ createCmdButton();
449
589
  injectStyles();
450
590
 
451
591
  // 初始化 VoiceInput SDK
package/gateway.js CHANGED
@@ -164,7 +164,11 @@ function start() {
164
164
  function restart() {
165
165
  stop();
166
166
  console.log('');
167
- return start();
167
+ const result = start();
168
+ try {
169
+ execSync('mc up', { stdio: 'inherit' });
170
+ } catch {}
171
+ return result;
168
172
  }
169
173
 
170
174
  module.exports = { stop, start, restart, PORT };
@@ -104,15 +104,6 @@ const SOUL_CONTENT = `# 角色定义
104
104
 
105
105
  ---
106
106
 
107
- # 资源路径规范
108
-
109
- 生成的所有文件资源(如图片、音频、视频、附件等),必须统一存放在用户工作空间的 \`myclaw\` 子目录下:
110
-
111
- - **路径规则**:\`~/.openclaw/workspace/myclaw/\`
112
- - **说明**:用户只会去 \`myclaw\` 文件夹查找和查看生成的文件,不要把资源放在其他位置。
113
- - **示例**:生成的图片路径应为 \`~/.openclaw/workspace/myclaw/图片名称.png\`,而不是 \`~/.openclaw/workspace/图片名称.png\`。
114
-
115
- ---
116
107
 
117
108
  # 风格示例
118
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.189",
3
+ "version": "1.0.191",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {