@wendongfly/myhi 1.0.37 → 1.0.39

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/dist/chat.html CHANGED
@@ -760,6 +760,14 @@
760
760
  if (actions) actions.innerHTML = answer === 'y' ? '<span style="color:#3fb950">已允许</span>' : '<span style="color:#f85149">已拒绝</span>';
761
761
  };
762
762
 
763
+ window.respondAgentPermission = function(requestId, allow, btn) {
764
+ if (!isController) { addStatusMessage('你没有控制权,无法操作'); return; }
765
+ socket.emit('agent:permission', { requestId, allow });
766
+ const actions = btn.closest('.perm-actions');
767
+ if (actions) actions.innerHTML = allow ? '<span style="color:#3fb950">已允许</span>' : '<span style="color:#f85149">已拒绝</span>';
768
+ setWorkState('working');
769
+ };
770
+
763
771
  // ── 输出处理 ──────────────────────────────────
764
772
  function flushOutput() {
765
773
  if (!outputBuffer) return;
@@ -962,6 +970,29 @@
962
970
  }
963
971
  setWorkState('working');
964
972
  break;
973
+ case 'control_request':
974
+ removeThinking();
975
+ if (msg.request?.subtype === 'can_use_tool') {
976
+ const toolName = msg.request.tool_name || '未知工具';
977
+ const input = msg.request.input || {};
978
+ const detail = toolName === 'Bash' ? (input.command || JSON.stringify(input))
979
+ : toolName === 'Edit' ? `${input.file_path || ''}`
980
+ : toolName === 'Write' ? `${input.file_path || ''}`
981
+ : JSON.stringify(input, null, 2);
982
+ const reqId = msg.request_id;
983
+ const el = document.createElement('div');
984
+ el.className = 'msg msg-permission';
985
+ el.innerHTML = `<div class="perm-title">${escHtml(toolName)} 请求权限</div><div class="perm-detail">${escHtml(detail)}</div>
986
+ <div class="perm-actions" data-reqid="${escHtml(reqId)}">
987
+ <button class="btn-allow" onclick="respondAgentPermission('${escHtml(reqId)}', true, this)">允许</button>
988
+ <button class="btn-deny" onclick="respondAgentPermission('${escHtml(reqId)}', false, this)">拒绝</button>
989
+ </div>`;
990
+ chatArea.appendChild(el);
991
+ trimMessages();
992
+ scrollToBottom();
993
+ setWorkState('waiting');
994
+ }
995
+ break;
965
996
  case 'result':
966
997
  removeThinking();
967
998
  setWorkState('idle');
@@ -972,7 +1003,7 @@
972
1003
  break; // 忽略
973
1004
  default:
974
1005
  // 未知消息类型,显示为原始 JSON
975
- if (msg.type !== 'user') {
1006
+ if (msg.type !== 'user' && msg.type !== 'control_response') {
976
1007
  addRawOutput(JSON.stringify(msg, null, 2));
977
1008
  }
978
1009
  }