@aiyiran/myclaw 1.1.76 → 1.1.78

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.
@@ -0,0 +1,652 @@
1
+ /**
2
+ * ============================================================================
3
+ * myclaw-iteration.js — 我卡住了,帮我继续改
4
+ * ============================================================================
5
+ *
6
+ * 功能:
7
+ * - 在聊天工具栏注入「🤔」按钮
8
+ * - 弹出两级选择面板(问题 → 行动),动态联动
9
+ * - 根据选择生成针对性提示词发给 AI
10
+ *
11
+ * 依赖:
12
+ * - window.VoiceInput(讯飞 SDK,可选,用于语音补充输入)
13
+ * - window.myclawIteration.init({ trySend }) 在 myclaw-inject.js 初始化时注入
14
+ * ============================================================================
15
+ */
16
+ (function () {
17
+ "use strict";
18
+
19
+ // ══════════ 配置 ══════════
20
+
21
+ var ITERATION_CONFIG = {
22
+ problems: ["样子不对", "逻辑不对", "不够好玩", "缺少创意玩法", "救命我卡住了"],
23
+ actionsByProblem: {
24
+ "样子不对": ["更好看", "更像我想的", "更清楚", "我还没想好"],
25
+ "逻辑不对": ["让它有反应", "让它运行正确", "先只改一个功能", "我还没想好"],
26
+ "不够好玩": ["加一个东西", "加一点互动", "加一个角色", "我还没想好"],
27
+ "缺少创意玩法": ["加一个新机制", "加一个有趣挑战", "加一个惊喜元素", "我还没想好"],
28
+ "救命我卡住了": ["先鼓励我一下", "帮我找卡点", "帮我缩成一步", "直接给我最简单版本"],
29
+ },
30
+ };
31
+
32
+ // ══════════ 提示词生成 ══════════
33
+
34
+ function buildIterationPrompt(problem, action, extraNote) {
35
+ var note = extraNote && extraNote.trim()
36
+ ? "\n补充说明:" + extraNote.trim()
37
+ : "";
38
+
39
+ if (!problem || !action) return "";
40
+
41
+ // 第二列选了"我还没想好":发散模式
42
+ if (action === "我还没想好") {
43
+ return "你是一个帮助学生继续推进项目的助手。\n"
44
+ + "我现在这个作品的问题是【" + problem + "】,\n"
45
+ + "但我还没想好具体要怎么改。\n\n"
46
+ + "请结合我当前正在做的内容,给我 3 个具体、容易执行的改进方向。\n"
47
+ + "要求:\n"
48
+ + "- 每条都要很短\n"
49
+ + "- 每条都要能马上动手\n"
50
+ + "- 不要太复杂\n"
51
+ + "- 最后帮我选 1 个最容易成功的方向\n\n"
52
+ + "输出格式:\n"
53
+ + "方向1:...\n"
54
+ + "方向2:...\n"
55
+ + "方向3:...\n"
56
+ + "建议我先做:..." + note;
57
+ }
58
+
59
+ // 逻辑类
60
+ if (problem === "逻辑不对") {
61
+ return "你是一个帮助学生继续推进项目的助手。\n"
62
+ + "我现在这个作品的问题是【" + problem + "】。\n"
63
+ + "我下一步想先【" + action + "】。\n\n"
64
+ + "请根据我当前正在做的内容,只帮我解决一个最小的问题。\n"
65
+ + "要求:\n"
66
+ + "- 只改一个点\n"
67
+ + "- 优先选择最容易成功的做法\n"
68
+ + "- 不要重构,不要大改\n"
69
+ + "- 如果你认为现在应该先缩小范围,也请直接告诉我最小版本应该怎么做\n\n"
70
+ + "输出格式:\n"
71
+ + "先改什么:...\n"
72
+ + "为什么先改这个:...\n"
73
+ + "我可以直接照着做的一句话:..." + note;
74
+ }
75
+
76
+ // 样子类
77
+ if (problem === "样子不对") {
78
+ return "你是一个帮助学生继续推进项目的助手。\n"
79
+ + "我现在这个作品的问题是【" + problem + "】。\n"
80
+ + "我下一步想先【" + action + "】。\n\n"
81
+ + "请根据我当前正在做的内容,只帮我做一个最小的视觉改进。\n"
82
+ + "要求:\n"
83
+ + "- 优先改样式、布局、文案、配色、画面感觉\n"
84
+ + "- 不要顺便改很多功能\n"
85
+ + "- 只给我一个最容易成功的下一步\n\n"
86
+ + "输出格式:\n"
87
+ + "先改什么:...\n"
88
+ + "为什么先改这个:...\n"
89
+ + "我可以直接发给 AI 的一句话:..." + note;
90
+ }
91
+
92
+ // 好玩类
93
+ if (problem === "不够好玩") {
94
+ return "你是一个帮助学生继续推进项目的助手。\n"
95
+ + "我现在这个作品的问题是【" + problem + "】。\n"
96
+ + "我下一步想先【" + action + "】。\n\n"
97
+ + "请根据我当前正在做的内容,只帮我增加一个最小的有趣点。\n"
98
+ + "要求:\n"
99
+ + "- 只加一个\n"
100
+ + "- 要容易实现\n"
101
+ + "- 不要把项目复杂度一下拉高\n"
102
+ + "- 优先选择能马上看到效果的改动\n\n"
103
+ + "输出格式:\n"
104
+ + "先加什么:...\n"
105
+ + "为什么先加这个:...\n"
106
+ + "我可以直接照着做的一句话:..." + note;
107
+ }
108
+
109
+ // 创意类
110
+ if (problem === "缺少创意玩法") {
111
+ return "你是一个帮助学生继续推进项目的助手。\n"
112
+ + "我现在这个作品的问题是【" + problem + "】。\n"
113
+ + "我下一步想先【" + action + "】。\n\n"
114
+ + "请根据我当前正在做的内容,帮我加一个最有创意、又最容易实现的新点子。\n"
115
+ + "要求:\n"
116
+ + "- 只加一个\n"
117
+ + "- 要让人眼前一亮\n"
118
+ + "- 不要做太复杂\n"
119
+ + "- 优先选择不需要大改就能看到效果的\n\n"
120
+ + "输出格式:\n"
121
+ + "先加什么:...\n"
122
+ + "为什么先加这个:...\n"
123
+ + "我可以直接照着做的一句话:..." + note;
124
+ }
125
+
126
+ // 卡住类
127
+ if (problem === "救命我卡住了") {
128
+ return "你是一个帮助学生继续推进项目的助手。\n"
129
+ + "学生现在卡住了,下一步想【" + action + "】。\n\n"
130
+ + "请根据当前项目内容,用最温和、最清楚的方式帮他继续推进。\n"
131
+ + "要求:\n"
132
+ + "- 不要给太多任务\n"
133
+ + "- 不要让他大改\n"
134
+ + "- 只给一个最小、最容易成功的下一步\n"
135
+ + "- 用孩子也能看懂的话说\n\n"
136
+ + "输出格式:\n"
137
+ + "我现在最该先做:...\n"
138
+ + "为什么:...\n"
139
+ + "我现在就可以开始做的一句话:..." + note;
140
+ }
141
+
142
+ // 兜底
143
+ return "你是一个帮助学生继续推进项目的助手。\n"
144
+ + "我现在这个作品的问题是【" + problem + "】。\n"
145
+ + "我下一步想先【" + action + "】。\n\n"
146
+ + "请根据我当前正在做的内容,帮我只改一个点,\n"
147
+ + "给我一个最简单、最容易成功的下一步方案。\n\n"
148
+ + "要求:\n"
149
+ + "- 只给一个方向\n"
150
+ + "- 不要太复杂\n"
151
+ + "- 不要大改\n"
152
+ + "- 要让我马上能动手\n\n"
153
+ + "输出格式:\n"
154
+ + "先改什么:...\n"
155
+ + "为什么先改这个:...\n"
156
+ + "我可以直接照着做的一句话:..." + note;
157
+ }
158
+
159
+ // ══════════ 状态 ══════════
160
+
161
+ var promptOpen = false;
162
+ var modalVoiceDestroy = null;
163
+ var _trySend = null; // 由 myclaw-inject.js 注入
164
+
165
+ // ══════════ 工具组件 ══════════
166
+
167
+ function makeLabel(text) {
168
+ var el = document.createElement("div");
169
+ el.textContent = text;
170
+ el.style.cssText = "font-size:13px;font-weight:bold;color:#cdd6f4;margin-bottom:8px;font-family:-apple-system,sans-serif;";
171
+ return el;
172
+ }
173
+
174
+ function makeChipGroup(items, activeColor, onChange) {
175
+ var wrap = document.createElement("div");
176
+ wrap.style.cssText = "display:flex;flex-wrap:wrap;gap:7px;";
177
+ var chips = [];
178
+ items.forEach(function (label) {
179
+ var chip = document.createElement("button");
180
+ chip.textContent = label;
181
+ chip.dataset.selected = "0";
182
+ chip.style.cssText = [
183
+ "padding:6px 13px",
184
+ "border-radius:20px",
185
+ "border:1.5px solid #3d3d5c",
186
+ "background:#252536",
187
+ "color:#888",
188
+ "font-size:13px",
189
+ "font-family:-apple-system,sans-serif",
190
+ "cursor:pointer",
191
+ "transition:all 0.15s",
192
+ "white-space:nowrap",
193
+ ].join(";");
194
+
195
+ function applyStyle(sel) {
196
+ if (sel) {
197
+ chip.style.background = activeColor;
198
+ chip.style.borderColor = activeColor;
199
+ chip.style.color = "#fff";
200
+ chip.style.fontWeight = "bold";
201
+ } else {
202
+ chip.style.background = "#252536";
203
+ chip.style.borderColor = "#3d3d5c";
204
+ chip.style.color = "#888";
205
+ chip.style.fontWeight = "normal";
206
+ }
207
+ }
208
+
209
+ chip.onmouseenter = function () {
210
+ if (chip.dataset.selected !== "1") chip.style.borderColor = activeColor;
211
+ };
212
+ chip.onmouseleave = function () {
213
+ if (chip.dataset.selected !== "1") chip.style.borderColor = "#3d3d5c";
214
+ };
215
+ chip.onclick = function () {
216
+ var nowOn = chip.dataset.selected !== "1";
217
+ chips.forEach(function (c) {
218
+ if (c !== chip) {
219
+ c.style.background = "#252536";
220
+ c.style.borderColor = "#3d3d5c";
221
+ c.style.color = "#888";
222
+ c.style.fontWeight = "normal";
223
+ c.dataset.selected = "0";
224
+ }
225
+ });
226
+ chip.dataset.selected = nowOn ? "1" : "0";
227
+ applyStyle(nowOn);
228
+ onChange(nowOn ? label : "");
229
+ };
230
+
231
+ chips.push(chip);
232
+ wrap.appendChild(chip);
233
+ });
234
+ return wrap;
235
+ }
236
+
237
+ function makeVoiceInputField(placeholder, maxLength, onChange) {
238
+ var lVoice = null;
239
+ var lRecording = false;
240
+ var lStopping = false;
241
+
242
+ var wrap = document.createElement("div");
243
+ wrap.style.cssText = "display:flex;gap:8px;align-items:center;width:100%;box-sizing:border-box;";
244
+
245
+ var input = document.createElement("input");
246
+ input.type = "text";
247
+ input.maxLength = maxLength || 60;
248
+ input.placeholder = placeholder || "";
249
+ input.style.cssText = [
250
+ "flex:1", "min-width:0", "padding:9px 12px",
251
+ "background:#252536",
252
+ "border:1.5px solid #3d3d5c",
253
+ "border-radius:8px",
254
+ "color:#cdd6f4",
255
+ "font-size:13px",
256
+ "font-family:-apple-system,sans-serif",
257
+ "outline:none",
258
+ "transition:border-color 0.15s, border-left-width 0.1s",
259
+ ].join(";");
260
+ input.onfocus = function () { if (!lRecording) input.style.borderColor = "#6366f1"; };
261
+ input.onblur = function () { if (!lRecording) input.style.borderColor = "#3d3d5c"; };
262
+ input.oninput = function () { if (onChange) onChange(input.value); };
263
+
264
+ var micBtn = document.createElement("button");
265
+ micBtn.type = "button";
266
+ micBtn.title = "语音输入";
267
+ micBtn.style.cssText = [
268
+ "width:34px", "height:34px", "flex-shrink:0",
269
+ "border-radius:50%",
270
+ "border:1.5px solid #3d3d5c",
271
+ "background:#252536",
272
+ "color:#888",
273
+ "cursor:pointer",
274
+ "display:flex", "align-items:center", "justify-content:center",
275
+ "transition:all 0.15s",
276
+ "position:relative",
277
+ ].join(";");
278
+ micBtn.innerHTML = [
279
+ '<svg width="14" height="14" viewBox="0 0 24 24" fill="none"',
280
+ ' stroke="currentColor" stroke-width="2"',
281
+ ' stroke-linecap="round" stroke-linejoin="round">',
282
+ ' <path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/>',
283
+ ' <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>',
284
+ ' <line x1="12" x2="12" y1="19" y2="22"/>',
285
+ '</svg>',
286
+ ].join("");
287
+
288
+ function setUI(recording) {
289
+ if (recording) {
290
+ micBtn.style.background = "#ff4444";
291
+ micBtn.style.borderColor = "#ff4444";
292
+ micBtn.style.color = "#fff";
293
+ micBtn.title = "停止录音";
294
+ input.style.borderColor = "#ff4444";
295
+ input.style.borderLeftWidth = "3px";
296
+ } else {
297
+ micBtn.style.background = "#252536";
298
+ micBtn.style.borderColor = "#3d3d5c";
299
+ micBtn.style.color = "#888";
300
+ micBtn.title = "语音输入";
301
+ input.style.borderColor = "#3d3d5c";
302
+ input.style.borderLeftWidth = "1.5px";
303
+ }
304
+ }
305
+
306
+ function initLVoice() {
307
+ if (typeof window.VoiceInput === "undefined") return false;
308
+ lVoice = new window.VoiceInput({
309
+ onResult: function (text) {
310
+ if (!lRecording && !lStopping) return;
311
+ input.value = text;
312
+ if (onChange) onChange(text);
313
+ },
314
+ onStatusChange: function (oldS, newS) {
315
+ if (newS === "idle" && lRecording && !lStopping) {
316
+ setTimeout(function () {
317
+ if (lRecording && lVoice) lVoice.start();
318
+ }, 300);
319
+ }
320
+ },
321
+ onError: function (err) {
322
+ console.error("[myclaw-iteration] voice error:", err);
323
+ lRecording = false; lStopping = false;
324
+ setUI(false);
325
+ },
326
+ });
327
+ return true;
328
+ }
329
+
330
+ function startLocal() {
331
+ if (!lVoice && !initLVoice()) {
332
+ console.warn("[myclaw-iteration] VoiceInput SDK 未加载");
333
+ return;
334
+ }
335
+ lRecording = true;
336
+ setUI(true);
337
+ lVoice.start();
338
+ }
339
+
340
+ function stopLocal() {
341
+ if (!lRecording) return;
342
+ lStopping = true;
343
+ lRecording = false;
344
+ setUI(false);
345
+ setTimeout(function () {
346
+ lStopping = false;
347
+ if (lVoice) lVoice.stop();
348
+ }, 1500);
349
+ }
350
+
351
+ micBtn.onclick = function () {
352
+ if (lRecording) { stopLocal(); } else { startLocal(); }
353
+ };
354
+
355
+ wrap.appendChild(input);
356
+ wrap.appendChild(micBtn);
357
+
358
+ return {
359
+ el: wrap,
360
+ getValue: function () { return input.value; },
361
+ setValue: function (v) { input.value = v; if (onChange) onChange(v); },
362
+ destroy: function () { if (lRecording) stopLocal(); },
363
+ };
364
+ }
365
+
366
+ function insertPromptText(text) {
367
+ var ta = document.querySelector(".agent-chat__input textarea");
368
+ if (!ta) return;
369
+
370
+ var start = ta.selectionStart || 0;
371
+ var end = ta.selectionEnd || 0;
372
+ var current = ta.value;
373
+ var newValue = current.substring(0, start) + text + current.substring(end);
374
+
375
+ var setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value").set;
376
+ setter.call(ta, newValue);
377
+ ta.dispatchEvent(new Event("input", { bubbles: true }));
378
+
379
+ var newCursor = start + text.length;
380
+ try { ta.setSelectionRange(newCursor, newCursor); } catch (e) {}
381
+ ta.focus();
382
+ }
383
+
384
+ // ══════════ Modal ══════════
385
+
386
+ function openPromptModal() {
387
+ if (document.querySelector("#myclaw-prompt-modal")) return;
388
+ promptOpen = true;
389
+
390
+ var iconBtn = document.querySelector("#myclaw-prompt-btn");
391
+ if (iconBtn) iconBtn.style.color = "#6366f1";
392
+
393
+ var state = { problem: "", action: "", note: "" };
394
+
395
+ function buildText() {
396
+ return buildIterationPrompt(state.problem, state.action, state.note);
397
+ }
398
+
399
+ function buildPayload() {
400
+ return {
401
+ type: "iteration_helper",
402
+ problem: state.problem,
403
+ next_action: state.action,
404
+ extra_note: state.note,
405
+ generated_text: buildText(),
406
+ };
407
+ }
408
+
409
+ var previewEl, actionSendBtn, actionInsertBtn;
410
+ function refresh() {
411
+ var text = buildText();
412
+ var ready = !!(state.problem && state.action);
413
+ if (previewEl) {
414
+ previewEl.textContent = text || "先选上面两项,这里会自动生成要发给 AI 的内容 ✨";
415
+ previewEl.style.color = ready ? "#cdd6f4" : "#555";
416
+ }
417
+ if (actionSendBtn) {
418
+ actionSendBtn.disabled = !ready;
419
+ actionSendBtn.style.opacity = ready ? "1" : "0.4";
420
+ actionSendBtn.style.cursor = ready ? "pointer" : "not-allowed";
421
+ }
422
+ if (actionInsertBtn) {
423
+ actionInsertBtn.disabled = !ready;
424
+ actionInsertBtn.style.opacity = ready ? "1" : "0.4";
425
+ actionInsertBtn.style.cursor = ready ? "pointer" : "not-allowed";
426
+ }
427
+ }
428
+
429
+ // ── 遮罩 ──
430
+ var overlay = document.createElement("div");
431
+ overlay.id = "myclaw-prompt-modal";
432
+ overlay.style.cssText = [
433
+ "position:fixed", "top:0", "left:0",
434
+ "width:100vw", "height:100vh",
435
+ "background:rgba(0,0,0,0.45)",
436
+ "z-index:99998",
437
+ "display:flex", "align-items:center", "justify-content:center",
438
+ "animation:myclaw-fade-in 0.15s ease",
439
+ ].join(";");
440
+
441
+ // ── 弹框 ──
442
+ var box = document.createElement("div");
443
+ box.style.cssText = [
444
+ "width:560px", "max-width:96vw", "max-height:92vh",
445
+ "background:#1e1e2e",
446
+ "border-radius:12px",
447
+ "overflow:hidden",
448
+ "display:flex", "flex-direction:column",
449
+ "box-shadow:0 12px 48px rgba(0,0,0,0.6)",
450
+ ].join(";");
451
+
452
+ // ── 标题栏 ──
453
+ var header = document.createElement("div");
454
+ header.style.cssText = [
455
+ "display:flex", "align-items:center", "justify-content:space-between",
456
+ "padding:13px 18px",
457
+ "background:linear-gradient(135deg,#6366f1,#8b5cf6)",
458
+ "color:#fff",
459
+ "font-size:15px", "font-weight:bold",
460
+ "font-family:-apple-system,sans-serif",
461
+ "user-select:none", "flex-shrink:0",
462
+ ].join(";");
463
+ header.innerHTML = "<span>🤔 我卡住了,帮我继续改</span>";
464
+ var closeX = document.createElement("span");
465
+ closeX.textContent = "✕";
466
+ closeX.style.cssText = "cursor:pointer;padding:2px 8px;border-radius:4px;font-size:15px;transition:background 0.15s;";
467
+ closeX.onmouseenter = function () { closeX.style.background = "rgba(255,255,255,0.2)"; };
468
+ closeX.onmouseleave = function () { closeX.style.background = "none"; };
469
+ closeX.onclick = function () { closePromptModal(); };
470
+ header.appendChild(closeX);
471
+
472
+ // ── 内容区 ──
473
+ var scroll = document.createElement("div");
474
+ scroll.style.cssText = "flex:1;overflow-y:auto;padding:20px 20px 8px;display:flex;flex-direction:column;gap:20px;";
475
+
476
+ // 第1区:问题
477
+ var sec1 = document.createElement("div");
478
+ sec1.appendChild(makeLabel("只改一点选什么?"));
479
+ sec1.appendChild(makeChipGroup(ITERATION_CONFIG.problems, "#f59e0b", function (val) {
480
+ state.problem = val;
481
+ state.action = "";
482
+ renderActionChips();
483
+ refresh();
484
+ }));
485
+ scroll.appendChild(sec1);
486
+
487
+ // 第2区:行动(动态联动)
488
+ var sec2 = document.createElement("div");
489
+ sec2.appendChild(makeLabel("你想怎么改?"));
490
+ var actionChipsWrap = document.createElement("div");
491
+ sec2.appendChild(actionChipsWrap);
492
+ sec2.style.display = "none";
493
+ scroll.appendChild(sec2);
494
+
495
+ function renderActionChips() {
496
+ actionChipsWrap.innerHTML = "";
497
+ var actions = ITERATION_CONFIG.actionsByProblem[state.problem];
498
+ if (!actions) { sec2.style.display = "none"; return; }
499
+ sec2.style.display = "";
500
+ actionChipsWrap.appendChild(makeChipGroup(actions, "#6366f1", function (val) {
501
+ state.action = val; refresh();
502
+ }));
503
+ }
504
+
505
+ // 第3区:补充
506
+ var sec3 = document.createElement("div");
507
+ sec3.appendChild(makeLabel("你的补充很关键!"));
508
+ var placeholders = ["比如:我想做成飞行射击", "比如:我想更像小猫主题", "比如:按钮点了以后想有变化"];
509
+ var noteField = makeVoiceInputField(
510
+ placeholders[Math.floor(Math.random() * placeholders.length)],
511
+ 60,
512
+ function (val) { state.note = val; refresh(); }
513
+ );
514
+ modalVoiceDestroy = noteField.destroy;
515
+ sec3.appendChild(noteField.el);
516
+ scroll.appendChild(sec3);
517
+
518
+ // 预览区
519
+ var previewWrap = document.createElement("div");
520
+ previewWrap.style.cssText = [
521
+ "padding:12px 14px",
522
+ "background:#252536",
523
+ "border-radius:8px",
524
+ "border-left:3px solid #6366f1",
525
+ ].join(";");
526
+ var previewLabel = document.createElement("div");
527
+ previewLabel.textContent = "将要发给 AI 的内容:";
528
+ previewLabel.style.cssText = "font-size:11px;color:#6366f1;font-weight:bold;margin-bottom:6px;font-family:monospace;letter-spacing:0.3px;";
529
+ previewEl = document.createElement("div");
530
+ previewEl.style.cssText = "font-size:13px;line-height:1.7;white-space:pre-wrap;font-family:-apple-system,sans-serif;word-break:break-all;";
531
+ previewWrap.appendChild(previewLabel);
532
+ previewWrap.appendChild(previewEl);
533
+ scroll.appendChild(previewWrap);
534
+
535
+ // ── 底部按钮 ──
536
+ var footer = document.createElement("div");
537
+ footer.style.cssText = [
538
+ "display:flex", "gap:10px",
539
+ "padding:14px 20px",
540
+ "border-top:1px solid #2d2d3f",
541
+ "flex-shrink:0",
542
+ "background:#1e1e2e",
543
+ ].join(";");
544
+
545
+ actionSendBtn = document.createElement("button");
546
+ actionSendBtn.textContent = "➤ 直接发给 AI";
547
+ actionSendBtn.disabled = true;
548
+ actionSendBtn.style.cssText = [
549
+ "flex:1", "padding:11px 0",
550
+ "background:#10b981", "color:#fff",
551
+ "border:none", "border-radius:8px",
552
+ "font-size:14px", "font-weight:bold",
553
+ "font-family:-apple-system,sans-serif",
554
+ "cursor:not-allowed", "transition:all 0.15s", "opacity:0.4",
555
+ ].join(";");
556
+ actionSendBtn.onmouseenter = function () { if (!actionSendBtn.disabled) actionSendBtn.style.background = "#059669"; };
557
+ actionSendBtn.onmouseleave = function () { if (!actionSendBtn.disabled) actionSendBtn.style.background = "#10b981"; };
558
+ actionSendBtn.onclick = function () {
559
+ if (actionSendBtn.disabled) return;
560
+ var payload = buildPayload();
561
+ console.log("[myclaw-iteration] onSendDirect", payload);
562
+ insertPromptText(payload.generated_text);
563
+ closePromptModal();
564
+ setTimeout(function () { if (_trySend) _trySend(); }, 50);
565
+ };
566
+
567
+ actionInsertBtn = document.createElement("button");
568
+ actionInsertBtn.textContent = "⬇ 先放到聊天框";
569
+ actionInsertBtn.disabled = true;
570
+ actionInsertBtn.style.cssText = [
571
+ "flex:1", "padding:11px 0",
572
+ "background:#6366f1", "color:#fff",
573
+ "border:none", "border-radius:8px",
574
+ "font-size:14px", "font-weight:bold",
575
+ "font-family:-apple-system,sans-serif",
576
+ "cursor:not-allowed", "transition:all 0.15s", "opacity:0.4",
577
+ ].join(";");
578
+ actionInsertBtn.onmouseenter = function () { if (!actionInsertBtn.disabled) actionInsertBtn.style.background = "#4f46e5"; };
579
+ actionInsertBtn.onmouseleave = function () { if (!actionInsertBtn.disabled) actionInsertBtn.style.background = "#6366f1"; };
580
+ actionInsertBtn.onclick = function () {
581
+ if (actionInsertBtn.disabled) return;
582
+ var payload = buildPayload();
583
+ console.log("[myclaw-iteration] onInsertToInput", payload);
584
+ insertPromptText(payload.generated_text);
585
+ closePromptModal();
586
+ };
587
+
588
+ footer.appendChild(actionSendBtn);
589
+ footer.appendChild(actionInsertBtn);
590
+
591
+ box.appendChild(header);
592
+ box.appendChild(scroll);
593
+ box.appendChild(footer);
594
+ overlay.appendChild(box);
595
+ overlay.onclick = function (e) { if (e.target === overlay) closePromptModal(); };
596
+ document.body.appendChild(overlay);
597
+
598
+ refresh();
599
+ }
600
+
601
+ function closePromptModal() {
602
+ if (modalVoiceDestroy) { modalVoiceDestroy(); modalVoiceDestroy = null; }
603
+ var modal = document.querySelector("#myclaw-prompt-modal");
604
+ if (modal) modal.remove();
605
+ promptOpen = false;
606
+
607
+ var btn = document.querySelector("#myclaw-prompt-btn");
608
+ if (btn) btn.style.color = "";
609
+ }
610
+
611
+ // ══════════ 触发按钮 ══════════
612
+
613
+ function createPromptButton() {
614
+ var btn = document.createElement("button");
615
+ btn.id = "myclaw-prompt-btn";
616
+ btn.className = "agent-chat__input-btn";
617
+ btn.title = "我卡住了,帮我继续改";
618
+ btn.setAttribute("aria-label", "我卡住了,帮我继续改");
619
+ btn.innerHTML = [
620
+ '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"',
621
+ ' viewBox="0 0 24 24" fill="none" stroke="currentColor"',
622
+ ' stroke-width="2" stroke-linecap="round" stroke-linejoin="round">',
623
+ ' <circle cx="12" cy="12" r="10"/>',
624
+ ' <path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>',
625
+ ' <line x1="12" y1="17" x2="12.01" y2="17"/>',
626
+ '</svg>',
627
+ ].join("");
628
+
629
+ btn.addEventListener("click", function (e) {
630
+ e.stopPropagation();
631
+ if (promptOpen) {
632
+ closePromptModal();
633
+ } else {
634
+ openPromptModal();
635
+ }
636
+ });
637
+
638
+ return btn;
639
+ }
640
+
641
+ // ══════════ 对外接口 ══════════
642
+
643
+ window.myclawIteration = {
644
+ init: function (deps) {
645
+ if (deps && deps.trySend) _trySend = deps.trySend;
646
+ },
647
+ createButton: createPromptButton,
648
+ open: openPromptModal,
649
+ close: closePromptModal,
650
+ isOpen: function () { return promptOpen; },
651
+ };
652
+ })();
package/index.js CHANGED
@@ -1505,7 +1505,7 @@ const MACHINE_CONFIG = [
1505
1505
  { name: 'Mo靖宇', claw: 'claw4', desc: 'Mo靖宇 的机器' },
1506
1506
  { name: '高兴', claw: 'claw5', desc: '高兴 的机器' },
1507
1507
  { name: '伊伊', claw: 'claw6', desc: '伊伊 的机器' },
1508
- { name: 'Thomas', claw: 'claw7', desc: 'Thomas 的机器' },
1508
+ { name: '梓浩', claw: 'claw7', desc: '梓浩 的机器' },
1509
1509
  { name: 'Eric', claw: 'claw8', desc: 'Eric 的机器' },
1510
1510
  { name: 'Mia', claw: 'claw9', desc: 'Mia 的机器' },
1511
1511
  { name: '雨熙', claw: 'claw10', desc: '雨熙 的机器' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.76",
3
+ "version": "1.1.78",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {