@wendongfly/myhi 1.3.29 → 1.3.31

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.
Files changed (2) hide show
  1. package/dist/chat.html +130 -4
  2. package/package.json +1 -1
package/dist/chat.html CHANGED
@@ -452,6 +452,33 @@
452
452
  </div>
453
453
  </div>
454
454
 
455
+ <!-- 自定义 Slash Commands 弹窗 -->
456
+ <div id="cmd-sheet" class="action-sheet">
457
+ <div class="action-sheet-backdrop" onclick="closeCmdSheet()"></div>
458
+ <div class="action-sheet-box" style="max-height:75vh;display:flex;flex-direction:column">
459
+ <div class="action-sheet-title">自定义命令</div>
460
+ <div style="padding:0.3rem 0.2rem">
461
+ <input id="cmd-filter" class="slash-inp" placeholder="搜索命令..." autocomplete="off">
462
+ </div>
463
+ <div id="cmd-sheet-list" style="flex:1;overflow-y:auto;padding:0.3rem 0;scrollbar-width:thin"></div>
464
+ <button class="action-sheet-cancel" onclick="closeCmdSheet()">取消</button>
465
+ </div>
466
+ </div>
467
+
468
+ <!-- AskUserQuestion 弹窗 -->
469
+ <div id="ask-sheet" class="action-sheet">
470
+ <div class="action-sheet-backdrop" onclick="closeAskSheet()"></div>
471
+ <div class="action-sheet-box" style="max-height:70vh;display:flex;flex-direction:column">
472
+ <div class="action-sheet-title" id="ask-sheet-title">提问</div>
473
+ <div id="ask-sheet-body" style="flex:1;overflow-y:auto;padding:0.3rem 0;scrollbar-width:thin"></div>
474
+ <div style="padding:0.3rem 0.2rem">
475
+ <input id="ask-sheet-input" class="slash-inp" placeholder="输入自定义回答(可选)" autocomplete="off">
476
+ </div>
477
+ <button class="action-sheet-cancel" style="background:#7c3aed;color:#fff;font-weight:600;margin-bottom:0.4rem" onclick="submitAskReply()">发送自定义回答</button>
478
+ <button class="action-sheet-cancel" onclick="closeAskSheet()">取消</button>
479
+ </div>
480
+ </div>
481
+
455
482
  <div id="skill-sheet" class="action-sheet">
456
483
  <div class="action-sheet-backdrop" onclick="closeSkillSheet()"></div>
457
484
  <div class="action-sheet-box" style="max-height:85vh;display:flex;flex-direction:column">
@@ -1232,6 +1259,9 @@
1232
1259
  } else if (block.type === 'text' && block.text) {
1233
1260
  addAssistantMessage(block.text);
1234
1261
  } else if (block.type === 'tool_use') {
1262
+ if (block.name === 'AskUserQuestion' && block.input) {
1263
+ openAskSheet(block.input);
1264
+ }
1235
1265
  addToolMessage(JSON.stringify(block.input || {}, null, 2), block.name || '工具');
1236
1266
  } else if (block.type === 'tool_result') {
1237
1267
  const content = typeof block.content === 'string' ? block.content : JSON.stringify(block.content);
@@ -1282,6 +1312,9 @@
1282
1312
  break;
1283
1313
  case 'tool_use':
1284
1314
  // 独立工具调用消息
1315
+ if (msg.name === 'AskUserQuestion' && msg.input) {
1316
+ openAskSheet(msg.input);
1317
+ }
1285
1318
  addToolMessage(JSON.stringify(msg.input || {}, null, 2), msg.name || '工具');
1286
1319
  setWorkState('working');
1287
1320
  break;
@@ -1822,6 +1855,65 @@
1822
1855
  ];
1823
1856
  let currentModelId = '';
1824
1857
 
1858
+ // ── AskUserQuestion 弹窗 ──
1859
+ window.openAskSheet = function(input) {
1860
+ const questions = input?.questions || input?.question;
1861
+ const sheet = document.getElementById('ask-sheet');
1862
+ const title = document.getElementById('ask-sheet-title');
1863
+ const body = document.getElementById('ask-sheet-body');
1864
+ const inp = document.getElementById('ask-sheet-input');
1865
+ body.innerHTML = '';
1866
+ inp.value = '';
1867
+
1868
+ // 支持单个 question 或 questions 数组
1869
+ const qList = Array.isArray(questions) ? questions : [{ question: questions || input?.question || '请选择', options: input?.options }];
1870
+
1871
+ qList.forEach(q => {
1872
+ const qText = q.question || q.text || '';
1873
+ title.textContent = q.header || '提问';
1874
+ // 问题描述
1875
+ if (qText) {
1876
+ const desc = document.createElement('div');
1877
+ desc.style.cssText = 'padding:0.5rem 0.3rem;font-size:0.82rem;color:#c9d1d9;line-height:1.5;white-space:pre-wrap';
1878
+ desc.textContent = qText;
1879
+ body.appendChild(desc);
1880
+ }
1881
+ // 选项列表
1882
+ if (q.options?.length) {
1883
+ q.options.forEach(opt => {
1884
+ const item = document.createElement('div');
1885
+ item.className = 'action-sheet-item';
1886
+ item.innerHTML = `<div><div>${escHtml(opt.label || opt.value || opt)}</div>${opt.description ? `<div class="desc">${escHtml(opt.description)}</div>` : ''}</div>`;
1887
+ item.onclick = () => {
1888
+ closeAskSheet();
1889
+ const reply = opt.label || opt.value || String(opt);
1890
+ addInputMessage(reply);
1891
+ socket.emit('agent:query', { prompt: reply });
1892
+ showThinking();
1893
+ };
1894
+ body.appendChild(item);
1895
+ });
1896
+ }
1897
+ });
1898
+ sheet.classList.add('open');
1899
+ inp.focus();
1900
+ };
1901
+ window.closeAskSheet = function() {
1902
+ document.getElementById('ask-sheet').classList.remove('open');
1903
+ };
1904
+ window.submitAskReply = function() {
1905
+ const inp = document.getElementById('ask-sheet-input');
1906
+ const text = inp.value.trim();
1907
+ if (!text) return;
1908
+ closeAskSheet();
1909
+ addInputMessage(text);
1910
+ socket.emit('agent:query', { prompt: text });
1911
+ showThinking();
1912
+ };
1913
+ document.getElementById('ask-sheet-input').addEventListener('keydown', (e) => {
1914
+ if (e.key === 'Enter') { e.preventDefault(); submitAskReply(); }
1915
+ });
1916
+
1825
1917
  window.openModelSheet = function() {
1826
1918
  const list = document.getElementById('model-list');
1827
1919
  list.innerHTML = '';
@@ -1988,15 +2080,22 @@
1988
2080
  });
1989
2081
 
1990
2082
  // ── 动态加载 Skill 按钮 ──────────────────────────
2083
+ let _customSkills = [];
1991
2084
  async function loadSkills() {
1992
2085
  try {
1993
2086
  const resp = await fetch(`/api/skills?sessionId=${SESSION_ID}`);
1994
2087
  const data = await resp.json();
1995
2088
  const container = document.getElementById('sk-custom-skills');
1996
- if (!data.skills || !data.skills.length) { container.innerHTML = ''; return; }
1997
- container.innerHTML = data.skills.map(s =>
1998
- `<button class="sk sk-claude" onclick="runSkill('${escHtml(s.name)}')" title="${escHtml(s.desc)}" style="color:#9d5cf5">/${escHtml(s.name)}</button>`
1999
- ).join('');
2089
+ _customSkills = data.skills || [];
2090
+ if (!_customSkills.length) { container.innerHTML = ''; return; }
2091
+ // ≤3 个:直接显示按钮;>3 个:显示 "/命令 (N)" 入口
2092
+ if (_customSkills.length <= 3) {
2093
+ container.innerHTML = _customSkills.map(s =>
2094
+ `<button class="sk sk-claude" onclick="runSkill('${escHtml(s.name)}')" title="${escHtml(s.desc)}" style="color:#9d5cf5">/${escHtml(s.name)}</button>`
2095
+ ).join('');
2096
+ } else {
2097
+ container.innerHTML = `<button class="sk sk-claude" onclick="openCmdSheet()" style="color:#9d5cf5">/命令 (${_customSkills.length})</button>`;
2098
+ }
2000
2099
  } catch {}
2001
2100
  }
2002
2101
  window.runSkill = function(name) {
@@ -2006,6 +2105,33 @@
2006
2105
  addInputMessage(cmd);
2007
2106
  showThinking();
2008
2107
  };
2108
+ window.openCmdSheet = function() {
2109
+ const sheet = document.getElementById('cmd-sheet');
2110
+ const listEl = document.getElementById('cmd-sheet-list');
2111
+ const filterInp = document.getElementById('cmd-filter');
2112
+ filterInp.value = '';
2113
+ const render = (keyword = '') => {
2114
+ const kw = keyword.toLowerCase();
2115
+ const filtered = _customSkills.filter(s =>
2116
+ !kw || s.name.toLowerCase().includes(kw) || (s.desc || '').toLowerCase().includes(kw));
2117
+ listEl.innerHTML = filtered.length
2118
+ ? filtered.map(s => `<div class="action-sheet-item" onclick="runSkillAndClose('${escHtml(s.name)}')">
2119
+ <div><div style="color:#d2a8ff">/${escHtml(s.name)}</div>${s.desc ? `<div class="desc">${escHtml(s.desc)}</div>` : ''}</div>
2120
+ </div>`).join('')
2121
+ : '<div style="text-align:center;color:#8b949e;padding:1.5rem 0;font-size:0.82rem">无匹配命令</div>';
2122
+ };
2123
+ render();
2124
+ filterInp.oninput = (e) => render(e.target.value);
2125
+ sheet.classList.add('open');
2126
+ setTimeout(() => filterInp.focus(), 100);
2127
+ };
2128
+ window.closeCmdSheet = function() {
2129
+ document.getElementById('cmd-sheet').classList.remove('open');
2130
+ };
2131
+ window.runSkillAndClose = function(name) {
2132
+ closeCmdSheet();
2133
+ runSkill(name);
2134
+ };
2009
2135
  // 加入会话后加载 skill
2010
2136
  socket.on('joined', () => { if (currentSession?.mode === 'agent') loadSkills(); });
2011
2137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wendongfly/myhi",
3
- "version": "1.3.29",
3
+ "version": "1.3.31",
4
4
  "description": "Web-based terminal sharing with chat UI — control your terminal from phone via LAN/Tailscale",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",