Skip to content

AgentWorkspace ​

组合来源授权、会话版本、执行区和输入框的双端 Agent Block。

基础用法 ​

vue
<script setup lang="ts">
import { shallowRef } from 'vue'
import AgentWorkspace from '@/components/blocks/agent-workspace.vue'

const open = shallowRef(true)
const prompt = shallowRef('')

function submit(value: string) {
  console.log(value)
}
</script>

<template>
  <AgentWorkspace
    v-model:prompt="prompt"
    :open="open"
    placement="docked"
    title="问题分析"
    @close="open = false"
    @submit="submit"
  />
</template>

Props ​

Prop类型默认值说明
activeVersionIdstringundefined当前会话版本
busybooleanfalse执行中状态
contextUsagenumber0上下文占用比例
messagesAgentConversationMessage[][]对话消息
openbooleantrue是否显示
placement'page' | 'docked' | 'sheet''page'布局模式
promptstring''输入内容
receiptsAgentSourceReceiptItem[][]来源回执
retrievalAgentRetrievalItem[][]检索进度
sourcesAgentContextSource[][]可用来源
subtitlestring'先确认可访问来源,再提交任务'副标题
tasksAgentTask[][]执行任务
titlestring'Agent 工作区'标题
versionsreadonly AgentThreadVersion[][]会话版本

Events ​

EventPayload说明
submitstring提交输入
update:promptstring同步输入内容
closevoid关闭工作区
toggleSource(AgentContextSource, boolean)切换来源
connectSourceAgentContextSource连接来源
retryRetrievalAgentRetrievalItem重试检索
retryTaskAgentTask重试任务
approveTaskAgentTask批准任务
cancelTaskvoid取消任务
selectVersionAgentThreadVersion选择版本
branchVersionAgentThreadVersion创建分支
pinVersionAgentThreadVersion固定版本
openReceiptAgentSourceReceiptItem打开回执
connectReceiptAgentSourceReceiptItem连接回执来源

Slots ​

Slot说明
execution替换默认对话、检索、任务和回执区

Weapp 插槽配置

使用无参数 #execution 时,在 weapp-vite 中设置 weapp.vue.template.scopedSlotsRequireProps: true,避免父级状态被泛型插槽转换遗漏。

平台导入

H5 使用 vue;小程序将示例中的 vue 替换为 wevu。两端都默认导入安装后的 @/components/blocks/agent-workspace.vue。