AgentThinkingPanel.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script setup>
  2. /**
  3. * v1.1:Hermes Agent 思考过程展示容器(深色风格)
  4. *
  5. * 整合 3 个区域(ThinkingLive 已提到 WorkflowEditor.vue 的 .nrc-thinking 上方):
  6. * ③ TodoListPanel —— 待办清单(位于工具调用上方)
  7. * ④ ToolCalls —— 工具调用(current + history)
  8. * ⑤ AskforPanel —— 全局唯一用户确认(内嵌)
  9. *
  10. * 还包含 RunReconnectBadge 显示断线重连状态。
  11. */
  12. import { computed } from 'vue'
  13. import ToolCalls from './ToolCalls.vue'
  14. import TodoListPanel from './TodoListPanel.vue'
  15. import AskforPanel from './AskforPanel.vue'
  16. import RunReconnectBadge from './RunReconnectBadge.vue'
  17. const props = defineProps({
  18. // 当前节点结果对象(必填)
  19. node: { type: Object, required: true },
  20. // v1.1:全局 Askfor 暂停点(来自 runner.pendingAsk)
  21. pendingAsk: { type: Object, default: null },
  22. // v1.1:全局重连状态(来自 runner.reconnecting)
  23. reconnecting: { type: Boolean, default: false },
  24. })
  25. const emit = defineEmits(['submit-clarify'])
  26. // M-9:仅当至少一项子内容可展示时才渲染容器,避免空 div(含 RunReconnectBadge)占位
  27. const hasAnyContent = computed(() => {
  28. return (props.node?.todos?.length > 0)
  29. || (props.node?.toolHistory?.length > 0)
  30. || !!props.node?.currentTool
  31. || !!props.pendingAsk
  32. || !!props.reconnecting
  33. })
  34. </script>
  35. <template>
  36. <div v-if="hasAnyContent" class="agent-thinking-panel">
  37. <RunReconnectBadge :reconnecting="reconnecting" />
  38. <!-- ③ 待办清单:放在工具调用上方,running 时强制展开,完成后自动收起 -->
  39. <TodoListPanel
  40. :todos="node.todos || []"
  41. :node-running="node.status === 'running'"
  42. />
  43. <!-- ④ 工具调用:传节点状态,running 时强制展开历史 -->
  44. <ToolCalls
  45. :current-tool="node.currentTool || null"
  46. :history="node.toolHistory || []"
  47. :node-running="node.status === 'running'"
  48. />
  49. <!-- ⑤ Askfor 内嵌(pendingAsk 与当前节点绑定时显示) -->
  50. <AskforPanel :pending="pendingAsk" @submit="answer => emit('submit-clarify', answer)" />
  51. </div>
  52. </template>
  53. <style scoped>
  54. /* v1.1:Agent 思考过程容器,深色风格(与 .nrc-thinking 视觉一致)
  55. 容器本身不占额外 padding/margin,让子组件(ToolCalls/TodoList/Askfor)
  56. 的 margin 直接生效,与 .nrc-thinking 在 .node-result-card 中对齐 */
  57. .agent-thinking-panel {
  58. font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  59. }
  60. </style>