AS AgentScopeAPI 手册 / API Reference

AgentScopeAdapter

public final class AgentScopeAdapter implements FrameworkAdapter
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:80–1012

AgentScope 适配器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.extensions.aistio.adapter 包,实现 FrameworkAdapter。核心成员包括 middleware、setHistorySource、setRuntimeSource、setAgentTaskStarter、frameworkName、frameworkVersion。

Bypass-observation adapter for a self-deployed AgentScope Java agent.

This is the BYO path: the user writes and runs their own agent, and aistio observes it from the side. It is unrelated to managed-agents mode, where the data plane service implements the /agentscope/* contract directly because it owns the runtime.

Observation rides on AistioObserverMiddleware, which passes every input and event through untouched. Context and history are read from AgentState, which is the same buffer the agent will hand to its next model call, so what the console shows is what the model sees.

Middlewares are fixed when a ReActAgent is built, so the event stream requires registering #middleware() at build time:

`AgentScopeAdapter adapter = new AgentScopeAdapter();
ReActAgent agent = ReActAgent.builder()
.middleware(adapter.middleware())
.build();
SessionBridge bridge = Aistio.instrument(agent, config, adapter);
`

An already-built agent can still be instrumented — snapshots, context, history and commands all read live state — but it produces no Level-2 events.

字段摘要Field Summary

字段Field类型Type说明Description
FRAMEWORK
staticfinal
String
FRAMEWORK字段。
The FRAMEWORK field.

构造器摘要Constructor Summary

构造器Constructor说明Description
public AgentScopeAdapter()
初始化 `AgentScopeAdapter` 实例。
Creates a new instance.
public AgentScopeAdapter(SessionCompactor compactor)
初始化 `AgentScopeAdapter` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public AistioObserverMiddleware middleware()
中间件到注册 on 智能体构建器到启用 Level-2 事件流。
The middleware to register on the agent builder to enable the Level-2 event stream.
public void setHistorySource(SessionHistorySource historySource)
设置历史来源。
Optional full-history reader (e.g.
public void setRuntimeSource(AgentRuntimeSource runtimeSource)
设置运行时来源。
Optional harness-/app hooks for inventory, plan files, subagent tasks and Definition enrich.
public void setAgentTaskStarter(AgentTaskStarter agentTaskStarter)
设置智能体任务启动器。
Installs the host hook that materializes ASDP AgentTask deliveries.
public String frameworkName()
返回 `frameworkName` 结果。
Returns the framework name.
public String frameworkVersion()
返回 `frameworkVersion` 结果。
Returns the framework version.
public boolean canHandle(Object target)
判断是否可以 `canHandle`。
Returns whether the handle.
public Set<String> capabilities()
返回能力。
Returns the capabilities.
public void attach(Object target, Consumer<SessionEvent> emit)
执行 `attach` 方法。
Performs the attach operation.
public void detach()
执行 `detach` 方法。
Returns the detach.
public void onBridgeAttached(SessionBridge bridge)
处理 `onBridgeAttached` 事件。
Performs the on bridge attached operation.
public Mono<ContextSnapshot> extractContext(String sessionId)
设置该参数。
Performs the extract context operation.
public Mono<MessagePage> listMessages(String sessionId, int offset, int limit)
列出消息。
Lists the messages.
public Mono<Void> handleCommand(String sessionId, String command, byte[] params)
处理命令。
Performs the handle command operation.
public Mono<Void> handleAgentTask(io.agentscope.extensions.aistio.model.AgentTaskAssignment assignment)
处理智能体任务。
Performs the handle agent task operation.
public Mono<Void> injectUserMessage(String sessionId, String content)
执行 `injectUserMessage` 方法。
Performs the inject user message operation.
public Mono<String> runConversationTurn(String sessionId, String content)
运行会话轮次。
Runs the conversation turn.
public Mono<List<Map<String, Object>>> listTasks(String sessionId)
列出任务。
Lists the tasks.
public Mono<List<Inventory.SubagentInfo>> listSubagents()
列出 `listSubagents`。
Lists the subagents.
public Mono<List<Inventory.WorkspaceInfo>> listWorkspaces()
列出 `listWorkspaces`。
Lists the workspaces.
public Mono<List<Map<String, Object>>> listSubagentTasks(String sessionId)
列出子智能体任务。
Lists the subagent tasks.
public Mono<Void> cancelSubagentTask(String sessionId, String taskId)
执行取消子智能体任务相关操作。
Performs the cancel subagent task operation.
public Mono<Void> setPlanMode(String sessionId, byte[] params)
设置计划模式。
Sets the plan mode.
public Map<String, Object> buildAgentConfig()
构建智能体配置。
Builds the agent config.

字段详情Field Detail

FRAMEWORK

public static final String FRAMEWORK
staticfinal

FRAMEWORK字段。声明为 public static final String FRAMEWORK。

The FRAMEWORK field.

源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:84

构造器详情Constructor Detail

AgentScopeAdapter

public AgentScopeAdapter()

初始化 AgentScopeAdapter 实例。

Creates a new instance.

源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:107–109

AgentScopeAdapter

public AgentScopeAdapter(SessionCompactor compactor)

初始化 AgentScopeAdapter 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
compactorSessionCompactorcompactor(类型 `SessionCompactor`)。handles `compress`; `null` leaves that command unsupported
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:114–117

方法详情Method Detail

middleware

public AistioObserverMiddleware middleware()

中间件到注册 on 智能体构建器到启用 Level-2 事件流。

The middleware to register on the agent builder to enable the Level-2 event stream.

返回Returns AistioObserverMiddleware
返回AistioObserverMiddleware。Returns aistio observer middleware.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:120–122

setHistorySource

public void setHistorySource(SessionHistorySource historySource)

设置历史来源。

Optional full-history reader (e.g.

参数Parameters
名称Name类型Type说明Description
historySourceSessionHistorySource历史来源(类型 `SessionHistorySource`)。The history source.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:128–130

setRuntimeSource

public void setRuntimeSource(AgentRuntimeSource runtimeSource)

设置运行时来源。

Optional harness-/app hooks for inventory, plan files, subagent tasks and Definition enrich.

参数Parameters
名称Name类型Type说明Description
runtimeSourceAgentRuntimeSource运行时来源(类型 `AgentRuntimeSource`)。The runtime source.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:135–137

setAgentTaskStarter

public void setAgentTaskStarter(AgentTaskStarter agentTaskStarter)

设置智能体任务启动器。

Installs the host hook that materializes ASDP AgentTask deliveries.

参数Parameters
名称Name类型Type说明Description
agentTaskStarterAgentTaskStarter智能体任务启动器(类型 `AgentTaskStarter`)。The agent task starter.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:140–142

frameworkName

public String frameworkName()

返回 frameworkName 结果。

Returns the framework name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:146–149

frameworkVersion

public String frameworkVersion()

返回 frameworkVersion 结果。

Returns the framework version.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:151–155

canHandle

public boolean canHandle(Object target)

判断是否可以 canHandle。

Returns whether the handle.

参数Parameters
名称Name类型Type说明Description
targetObject目标(类型 `Object`)。The target.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:157–160

capabilities

public Set<String> capabilities()

返回能力。

Returns the capabilities.

返回Returns Set<String>
返回设置。Returns set.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:162–185

attach

public void attach(Object target, Consumer<SessionEvent> emit)

执行 attach 方法。

Performs the attach operation.

参数Parameters
名称Name类型Type说明Description
targetObject目标(类型 `Object`)。The target.
emitConsumer<SessionEvent>发出(类型 `Consumer`)。The emit.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:189–193

detach

public void detach()

执行 detach 方法。

Returns the detach.

源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:195–201

onBridgeAttached

public void onBridgeAttached(SessionBridge bridge)

处理 onBridgeAttached 事件。

Performs the on bridge attached operation.

参数Parameters
名称Name类型Type说明Description
bridgeSessionBridgebridge(类型 `SessionBridge`)。The bridge.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:203–206

extractContext

public Mono<ContextSnapshot> extractContext(String sessionId)

设置该参数。

Performs the extract context operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Mono<ContextSnapshot>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:336–394

listMessages

public Mono<MessagePage> listMessages(String sessionId, int offset, int limit)

列出消息。

Lists the messages.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
offsetint偏移量(类型 `int`)。The offset.
limitint数量上限(类型 `int`)。The limit.
返回Returns Mono<MessagePage>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:455–490

handleCommand

public Mono<Void> handleCommand(String sessionId, String command, byte[] params)

处理命令。

Performs the handle command operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
commandString命令(类型 `String`)。The command.
paramsbyte[]参数(类型 `byte[]`)。The params.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:494–526

handleAgentTask

public Mono<Void> handleAgentTask(io.agentscope.extensions.aistio.model.AgentTaskAssignment assignment)

处理智能体任务。

Performs the handle agent task operation.

参数Parameters
名称Name类型Type说明Description
assignmentio.agentscope.extensions.aistio.model.AgentTaskAssignmentassignment(类型 `io.agentscope.extensions.aistio.model.AgentTaskAssignment`)。The assignment.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:528–543

injectUserMessage

public Mono<Void> injectUserMessage(String sessionId, String content)

执行 injectUserMessage 方法。

Performs the inject user message operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
contentString内容(类型 `String`)。The content.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:545–548

runConversationTurn

public Mono<String> runConversationTurn(String sessionId, String content)

运行会话轮次。

Runs the conversation turn.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
contentString内容(类型 `String`)。The content.
返回Returns Mono<String>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:550–553

listTasks

public Mono<List<Map<String, Object>>> listTasks(String sessionId)

列出任务。

Lists the tasks.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Mono<List<Map<String, Object>>>
返回Mono>>。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:571–586

listSubagents

public Mono<List<Inventory.SubagentInfo>> listSubagents()

列出 listSubagents。

Lists the subagents.

返回Returns Mono<List<Inventory.SubagentInfo>>
返回Mono>。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:620–631

listWorkspaces

public Mono<List<Inventory.WorkspaceInfo>> listWorkspaces()

列出 listWorkspaces。

Lists the workspaces.

返回Returns Mono<List<Inventory.WorkspaceInfo>>
返回Mono>。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:633–644

listSubagentTasks

public Mono<List<Map<String, Object>>> listSubagentTasks(String sessionId)

列出子智能体任务。

Lists the subagent tasks.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Mono<List<Map<String, Object>>>
返回Mono>>。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:646–658

cancelSubagentTask

public Mono<Void> cancelSubagentTask(String sessionId, String taskId)

执行取消子智能体任务相关操作。

Performs the cancel subagent task operation.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
taskIdString任务标识(类型 `String`)。The task id.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:660–682

setPlanMode

public Mono<Void> setPlanMode(String sessionId, byte[] params)

设置计划模式。

Sets the plan mode.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
paramsbyte[]参数(类型 `byte[]`)。The params.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:684–705

buildAgentConfig

public Map<String, Object> buildAgentConfig()

构建智能体配置。

Builds the agent config.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/extensions/aistio/adapter/AgentScopeAdapter.java:744–792

继承成员Inherited Members

基于官方固定版本源码静态生成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.