WorkbenchState
public final class WorkbenchState
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:44–395Workbench 状态,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.examples.copilotkit.workbench 包。核心成员包括 getThreadId、getClientComponents、setClientComponents、snapshot、mergeFromClient、updateBrief。
Thread-scoped shared state backing the CopilotKit workbench.
Every mutation queues a CustomEvent. WorkbenchEventMiddleware drains the queue
while the agent is still streaming and WorkbenchAguiEventConverter turns each queued event
into the matching AG-UI frame (STATE_SNAPSHOT / STATE_DELTA /
STEP_STARTED / STEP_FINISHED / ACTIVITY_SNAPSHOT / CUSTOM). That
round trip is what makes plan progress and permission decisions appear in the browser mid-run
instead of after it.
All mutators are synchronized because AgentScope may execute tool calls in parallel.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
EVENT_STATE_UPDATEDstaticfinal | String | 事件状态已更新字段。 Carries a full workbench snapshot; converted to STATE_SNAPSHOT or STATE_DELTA. |
EVENT_STEP_STARTEDstaticfinal | String | 事件步骤已启动字段。 A plan task entered `in_progress`; converted to STEP_STARTED. |
EVENT_STEP_FINISHEDstaticfinal | String | 事件步骤 FINISHED字段。 A plan task reached `completed`; converted to STEP_FINISHED. |
EVENT_A2UI_SURFACEstaticfinal | String | 事件 A 2 UI SURFACE字段。 Carries A2UI operations; converted to an `a2ui-surface` ACTIVITY_SNAPSHOT. |
EVENT_PERMISSION_AUDITstaticfinal | String | 事件权限 AUDIT字段。 Carries a permission decision; converted to a CUSTOM event for the audit panel. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getThreadId() | 获取会话线程标识。 Returns the thread id. |
public Set<String> getClientComponents() | 获取 `getClientComponents`。 The custom A2UI components the browser declared it can paint. |
public void setClientComponents(Set<String> names) | 设置 `setClientComponents`。 Sets the client components. |
public synchronized Map<String, Object> snapshot()synchronized | 返回快照。 Immutable view of the state, shaped exactly like the browser's shared-state object. |
public synchronized void mergeFromClient(Map<String, Object> clientState)synchronized | 合并来自客户端。 Seeds the state from the `state` object the browser sent along with the run. |
public synchronized String updateBrief(String newTopic, String newPriority, String newStatus)synchronized | 更新 `updateBrief`。 Updates the brief. |
public synchronized void setPlanGoal(String goal)synchronized | 设置计划目标。 Sets the plan goal. |
public synchronized boolean syncTasks(List<Task> liveTasks)synchronized | 设置同步任务。 Mirrors AgentScope's live task list into the shared state. |
public synchronized void recordMetrics(Map<String, Object> newMetrics)synchronized | 设置该参数。 Performs the record metrics operation. |
public synchronized void recordA2uiSurface(String surfaceId, String catalogId, String intent, String generatedBy, int componentCount, List<Map<String, Object>> operations)synchronized | 执行 `recordA2uiSurface` 方法。 Publishes a freshly generated A2UI surface to the browser. |
public synchronized void queueSnapshot()synchronized | 执行队列快照相关操作。 Queues a state frame even when nothing changed; used at the start of every run. |
public synchronized void clearOpenSteps()synchronized | 清空打开步骤。 Drops any leftover open-step bookkeeping from a previous run without emitting events. |
public synchronized void closeOpenSteps()synchronized | 关闭打开步骤。 Emits `STEP_FINISHED` for every step still open. |
public List<CustomEvent> drainPendingEvents() | 返回 `drainPendingEvents` 结果。 Removes and returns everything queued since the previous drain. |
字段详情Field Detail
EVENT_STATE_UPDATED
public static final String EVENT_STATE_UPDATED
事件状态已更新字段。声明为 public static final String EVENT_STATE_UPDATED。
Carries a full workbench snapshot; converted to STATE_SNAPSHOT or STATE_DELTA.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:47EVENT_STEP_STARTED
public static final String EVENT_STEP_STARTED
事件步骤已启动字段。声明为 public static final String EVENT_STEP_STARTED。
A plan task entered in_progress; converted to STEP_STARTED.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:50EVENT_STEP_FINISHED
public static final String EVENT_STEP_FINISHED
事件步骤 FINISHED字段。声明为 public static final String EVENT_STEP_FINISHED。
A plan task reached completed; converted to STEP_FINISHED.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:53EVENT_A2UI_SURFACE
public static final String EVENT_A2UI_SURFACE
事件 A 2 UI SURFACE字段。声明为 public static final String EVENT_A2UI_SURFACE。
Carries A2UI operations; converted to an a2ui-surface ACTIVITY_SNAPSHOT.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:56EVENT_PERMISSION_AUDIT
public static final String EVENT_PERMISSION_AUDIT
事件权限 AUDIT字段。声明为 public static final String EVENT_PERMISSION_AUDIT。
Carries a permission decision; converted to a CUSTOM event for the audit panel.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:59方法详情Method Detail
getThreadId
public String getThreadId()
获取会话线程标识。
Returns the thread id.
Stringio/agentscope/examples/copilotkit/workbench/WorkbenchState.java:102–104getClientComponents
public Set<String> getClientComponents()
获取 getClientComponents。
The custom A2UI components the browser declared it can paint.
Set<String>io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:114–116setClientComponents
public void setClientComponents(Set<String> names)
设置 setClientComponents。
Sets the client components.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
names | Set<String> | names(类型 `Set`)。The names. |
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:118–122snapshot
public synchronized Map<String, Object> snapshot()
返回快照。
Immutable view of the state, shaped exactly like the browser's shared-state object.
Map<String, Object>io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:125–152mergeFromClient
public synchronized void mergeFromClient(Map<String, Object> clientState)
合并来自客户端。
Seeds the state from the state object the browser sent along with the run.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
clientState | Map<String, Object> | 客户端状态(类型 `Map`)。The client state. |
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:166–182updateBrief
public synchronized String updateBrief(String newTopic, String newPriority, String newStatus)
更新 updateBrief。
Updates the brief.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
newTopic | String | 新建主题(类型 `String`)。The new topic. |
newPriority | String | 新建优先级(类型 `String`)。The new priority. |
newStatus | String | 新建状态(类型 `String`)。The new status. |
Stringio/agentscope/examples/copilotkit/workbench/WorkbenchState.java:184–196setPlanGoal
public synchronized void setPlanGoal(String goal)
设置计划目标。
Sets the plan goal.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
goal | String | 目标(类型 `String`)。The goal. |
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:198–203syncTasks
public synchronized boolean syncTasks(List<Task> liveTasks)
设置同步任务。
Mirrors AgentScope's live task list into the shared state.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
liveTasks | List<Task> | 当前`AgentState.getTasksContext().getTasks()`。the current `AgentState.getTasksContext().getTasks()` |
booleanio/agentscope/examples/copilotkit/workbench/WorkbenchState.java:216–280recordMetrics
public synchronized void recordMetrics(Map<String, Object> newMetrics)
设置该参数。
Performs the record metrics operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
newMetrics | Map<String, Object> | 新建指标(类型 `Map`)。The new metrics. |
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:282–285recordA2uiSurface
public synchronized void recordA2uiSurface(String surfaceId, String catalogId, String intent, String generatedBy, int componentCount, List<Map<String, Object>> operations)
执行 recordA2uiSurface 方法。
Publishes a freshly generated A2UI surface to the browser.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
surfaceId | String | surface 标识(类型 `String`)。The surface id. |
catalogId | String | 目录标识(类型 `String`)。The catalog id. |
intent | String | intent(类型 `String`)。The intent. |
generatedBy | String | generated 通过(类型 `String`)。The generated by. |
componentCount | int | component 数量(类型 `int`)。The component count. |
operations | List<Map<String, Object>> | operations(类型 `List >`)。The operations. |
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:288–312queueSnapshot
public synchronized void queueSnapshot()
执行队列快照相关操作。
Queues a state frame even when nothing changed; used at the start of every run.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:315–317clearOpenSteps
public synchronized void clearOpenSteps()
清空打开步骤。
Drops any leftover open-step bookkeeping from a previous run without emitting events.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:325–327closeOpenSteps
public synchronized void closeOpenSteps()
关闭打开步骤。
Emits STEP_FINISHED for every step still open.
io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:335–339drainPendingEvents
public List<CustomEvent> drainPendingEvents()
返回 drainPendingEvents 结果。
Removes and returns everything queued since the previous drain.
List<CustomEvent>io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:387–394