AS AgentScopeAPI 手册 / API Reference

WorkbenchState

public final class WorkbenchState
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:44–395

Workbench 状态,把智能体接入外部消息渠道与企业平台。位于 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_UPDATED
staticfinal
String
事件状态已更新字段。
Carries a full workbench snapshot; converted to STATE_SNAPSHOT or STATE_DELTA.
EVENT_STEP_STARTED
staticfinal
String
事件步骤已启动字段。
A plan task entered `in_progress`; converted to STEP_STARTED.
EVENT_STEP_FINISHED
staticfinal
String
事件步骤 FINISHED字段。
A plan task reached `completed`; converted to STEP_FINISHED.
EVENT_A2UI_SURFACE
staticfinal
String
事件 A 2 UI SURFACE字段。
Carries A2UI operations; converted to an `a2ui-surface` ACTIVITY_SNAPSHOT.
EVENT_PERMISSION_AUDIT
staticfinal
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
staticfinal

事件状态已更新字段。声明为 public static final String EVENT_STATE_UPDATED。

Carries a full workbench snapshot; converted to STATE_SNAPSHOT or STATE_DELTA.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:47

EVENT_STEP_STARTED

public static final String EVENT_STEP_STARTED
staticfinal

事件步骤已启动字段。声明为 public static final String EVENT_STEP_STARTED。

A plan task entered in_progress; converted to STEP_STARTED.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:50

EVENT_STEP_FINISHED

public static final String EVENT_STEP_FINISHED
staticfinal

事件步骤 FINISHED字段。声明为 public static final String EVENT_STEP_FINISHED。

A plan task reached completed; converted to STEP_FINISHED.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:53

EVENT_A2UI_SURFACE

public static final String EVENT_A2UI_SURFACE
staticfinal

事件 A 2 UI SURFACE字段。声明为 public static final String EVENT_A2UI_SURFACE。

Carries A2UI operations; converted to an a2ui-surface ACTIVITY_SNAPSHOT.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:56

EVENT_PERMISSION_AUDIT

public static final String EVENT_PERMISSION_AUDIT
staticfinal

事件权限 AUDIT字段。声明为 public static final String EVENT_PERMISSION_AUDIT。

Carries a permission decision; converted to a CUSTOM event for the audit panel.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:59

方法详情Method Detail

getThreadId

public String getThreadId()

获取会话线程标识。

Returns the thread id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:102–104

getClientComponents

public Set<String> getClientComponents()

获取 getClientComponents。

The custom A2UI components the browser declared it can paint.

返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:114–116

setClientComponents

public void setClientComponents(Set<String> names)

设置 setClientComponents。

Sets the client components.

参数Parameters
名称Name类型Type说明Description
namesSet<String>names(类型 `Set`)。The names.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:118–122

snapshot

public synchronized Map<String, Object> snapshot()
synchronized

返回快照。

Immutable view of the state, shaped exactly like the browser's shared-state object.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:125–152

mergeFromClient

public synchronized void mergeFromClient(Map<String, Object> clientState)
synchronized

合并来自客户端。

Seeds the state from the state object the browser sent along with the run.

参数Parameters
名称Name类型Type说明Description
clientStateMap<String, Object>客户端状态(类型 `Map`)。The client state.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:166–182

updateBrief

public synchronized String updateBrief(String newTopic, String newPriority, String newStatus)
synchronized

更新 updateBrief。

Updates the brief.

参数Parameters
名称Name类型Type说明Description
newTopicString新建主题(类型 `String`)。The new topic.
newPriorityString新建优先级(类型 `String`)。The new priority.
newStatusString新建状态(类型 `String`)。The new status.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:184–196

setPlanGoal

public synchronized void setPlanGoal(String goal)
synchronized

设置计划目标。

Sets the plan goal.

参数Parameters
名称Name类型Type说明Description
goalString目标(类型 `String`)。The goal.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:198–203

syncTasks

public synchronized boolean syncTasks(List<Task> liveTasks)
synchronized

设置同步任务。

Mirrors AgentScope's live task list into the shared state.

参数Parameters
名称Name类型Type说明Description
liveTasksList<Task>当前`AgentState.getTasksContext().getTasks()`。the current `AgentState.getTasksContext().getTasks()`
返回Returns boolean
返回布尔值,表示判断结果。true when anything changed and a state frame was queued
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:216–280

recordMetrics

public synchronized void recordMetrics(Map<String, Object> newMetrics)
synchronized

设置该参数。

Performs the record metrics operation.

参数Parameters
名称Name类型Type说明Description
newMetricsMap<String, Object>新建指标(类型 `Map`)。The new metrics.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:282–285

recordA2uiSurface

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.

参数Parameters
名称Name类型Type说明Description
surfaceIdStringsurface 标识(类型 `String`)。The surface id.
catalogIdString目录标识(类型 `String`)。The catalog id.
intentStringintent(类型 `String`)。The intent.
generatedByStringgenerated 通过(类型 `String`)。The generated by.
componentCountintcomponent 数量(类型 `int`)。The component count.
operationsList<Map<String, Object>>operations(类型 `List >`)。The operations.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:288–312

queueSnapshot

public synchronized void queueSnapshot()
synchronized

执行队列快照相关操作。

Queues a state frame even when nothing changed; used at the start of every run.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:315–317

clearOpenSteps

public synchronized void clearOpenSteps()
synchronized

清空打开步骤。

Drops any leftover open-step bookkeeping from a previous run without emitting events.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:325–327

closeOpenSteps

public synchronized void closeOpenSteps()
synchronized

关闭打开步骤。

Emits STEP_FINISHED for every step still open.

源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:335–339

drainPendingEvents

public List<CustomEvent> drainPendingEvents()

返回 drainPendingEvents 结果。

Removes and returns everything queued since the previous drain.

返回Returns List<CustomEvent>
返回列出。Returns list.
源码Source io/agentscope/examples/copilotkit/workbench/WorkbenchState.java:387–394
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.