WorkbenchAguiEventConverter
@Component public class WorkbenchAguiEventConverter implements AgentEventConverter
io/agentscope/examples/copilotkit/workbench/WorkbenchAguiEventConverter.java:54–175Workbench AGUI 事件转换器,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.examples.copilotkit.workbench 包,实现 AgentEventConverter。核心成员包括 eventTypes、convert、forgetRun、ACTIVITY_A2UI_SURFACE。
Maps the workbench's CustomEvents onto the AG-UI frames a CopilotKit client understands.
This is the one place where the example decides which AG-UI event best expresses each piece of agent progress:
-
state_updated→STATE_SNAPSHOTfor the first frame of a run, thenSTATE_DELTA(RFC 6902) for every later change, so the browser only pays for what actually moved -
plan_step_started/plan_step_finished→STEP_STARTED/STEP_FINISHED, giving plan tasks a first-class lifecycle on the wire -
a2ui_surface→ACTIVITY_SNAPSHOTof typea2ui-surface, which is how generated UI reaches the A2UI renderer -
permission_audit→CUSTOM, consumed by the audit panel
Snapshot bookkeeping is keyed by threadId:runId. Entries are dropped as soon as a run
finishes, so a long-lived server does not accumulate them.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
ACTIVITY_A2UI_SURFACEstaticfinal | String | ACTIVITY A 2 UI SURFACE字段。 AG-UI activity type paired with `useRenderActivity("a2ui-surface")` in the browser. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Set<Class<? extends AgentEvent>> eventTypes() | 返回事件类型。 Returns the event types. |
public void convert(AgentEvent event, AguiStreamContext context) | 执行转换相关操作。 Performs the convert operation. |
public void forgetRun(String threadId, String runId) | 执行 `forgetRun` 方法。 Drops the per-run snapshot baseline; called when the run ends. |
字段详情Field Detail
ACTIVITY_A2UI_SURFACE
public static final String ACTIVITY_A2UI_SURFACE
ACTIVITY A 2 UI SURFACE字段。声明为 public static final String ACTIVITY_A2UI_SURFACE。
AG-UI activity type paired with useRenderActivity("a2ui-surface") in the browser.
io/agentscope/examples/copilotkit/workbench/WorkbenchAguiEventConverter.java:58方法详情Method Detail
eventTypes
public Set<Class<? extends AgentEvent>> eventTypes()
返回事件类型。
Returns the event types.
Set<Class<? extends AgentEvent>>io/agentscope/examples/copilotkit/workbench/WorkbenchAguiEventConverter.java:62–65convert
public void convert(AgentEvent event, AguiStreamContext context)
执行转换相关操作。
Performs the convert operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | AgentEvent | 事件(类型 `AgentEvent`)。The event. |
context | AguiStreamContext | 上下文(类型 `AguiStreamContext`)。The context. |
io/agentscope/examples/copilotkit/workbench/WorkbenchAguiEventConverter.java:67–89forgetRun
public void forgetRun(String threadId, String runId)
执行 forgetRun 方法。
Drops the per-run snapshot baseline; called when the run ends.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。The thread id. |
runId | String | 运行标识(类型 `String`)。The run id. |
io/agentscope/examples/copilotkit/workbench/WorkbenchAguiEventConverter.java:92–94