SessionBridge
public final class SessionBridge implements ContractProvider, AutoCloseable
io/agentscope/extensions/aistio/SessionBridge.java:68–1276会话 Bridge,承载智能体的部署、调度与服务化运行。位于 io.agentscope.extensions.aistio 包,实现 ContractProvider、AutoCloseable。核心成员包括 attach、getAdapter、getConfig、getRegisteredIdentity、getContractPort、start。
The reporting engine that sits between a framework adapter and the aistio control plane.
It owns everything the adapter should not care about: sequence numbering, the Level-2 event durable event outbox, incremental context tracking, Level-1 aggregation, debounced Level-4 pushes, inventory, command dispatch from both channels, and the in-process contract server.
Bypass principle: every reporting path swallows its own failures. Nothing here may propagate into the agent's conversation path.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
SDK_VERSIONstaticfinal | String | SDK 版本字段。 The SDK VERSION field. |
CONTRACT_LEVELstaticfinal | int | 契约级别字段。 Contract level 3: discovery, sessions, and commands. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SessionBridge(AistioConfig config) | 初始化 `SessionBridge` 实例。 Creates a new instance. |
方法摘要Method Summary
字段详情Field Detail
SDK_VERSION
public static final String SDK_VERSION
SDK 版本字段。声明为 public static final String SDK_VERSION。
The SDK VERSION field.
io/agentscope/extensions/aistio/SessionBridge.java:72CONTRACT_LEVEL
public static final int CONTRACT_LEVEL
契约级别字段。声明为 public static final int CONTRACT_LEVEL。
Contract level 3: discovery, sessions, and commands.
io/agentscope/extensions/aistio/SessionBridge.java:75构造器详情Constructor Detail
SessionBridge
public SessionBridge(AistioConfig config)
初始化 SessionBridge 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | AistioConfig | 配置对象(类型 `AistioConfig`)。The config. |
io/agentscope/extensions/aistio/SessionBridge.java:128–143方法详情Method Detail
attach
public SessionBridge attach(Object target, FrameworkAdapter adapter)
执行 attach 方法。
Mounts adapter onto target; must be called before #start().
| 名称Name | 类型Type | 说明Description |
|---|---|---|
target | Object | 目标(类型 `Object`)。The target. |
adapter | FrameworkAdapter | 适配器(类型 `FrameworkAdapter`)。The adapter. |
SessionBridgeio/agentscope/extensions/aistio/SessionBridge.java:148–157getAdapter
public FrameworkAdapter getAdapter()
获取适配器。
Returns the adapter.
FrameworkAdapterio/agentscope/extensions/aistio/SessionBridge.java:159–161getConfig
public AistioConfig getConfig()
获取配置。
Returns the config.
AistioConfigio/agentscope/extensions/aistio/SessionBridge.java:163–165getRegisteredIdentity
public HttpSelfRegistration.RegisteredIdentity getRegisteredIdentity()
获取已注册身份。
Returns the stable Catalog identity issued by the latest successful self-registration.
HttpSelfRegistration.RegisteredIdentityio/agentscope/extensions/aistio/SessionBridge.java:172–174getContractPort
public int getContractPort()
获取 getContractPort。
Actual contract HTTP port, which matters when the configured port was 0.
intio/agentscope/extensions/aistio/SessionBridge.java:177–179start
public synchronized SessionBridge start()
返回启动。
Returns the start.
SessionBridgeio/agentscope/extensions/aistio/SessionBridge.java:183–315close
public synchronized void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/extensions/aistio/SessionBridge.java:329–362capabilities
public Set<String> capabilities()
返回能力。
Returns the capabilities.
Set<String>io/agentscope/extensions/aistio/SessionBridge.java:366–375onEvent
public void onEvent(SessionEvent event)
处理事件事件。
Adapter callback.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | SessionEvent | 事件(类型 `SessionEvent`)。The event. |
io/agentscope/extensions/aistio/SessionBridge.java:380–432describeSession
public void describeSession(String sessionId, String systemPrompt, List<ContextSnapshot.ToolInfo> tools, int maxTokens)
执行 describeSession 方法。
Lets the adapter seed the tracker with data the event stream does not carry.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
systemPrompt | String | 系统提示词(类型 `String`)。The system prompt. |
tools | List<ContextSnapshot.ToolInfo> | 工具列表(类型 `List`)。The tools. |
maxTokens | int | 最大令牌数(类型 `int`)。The max tokens. |
io/agentscope/extensions/aistio/SessionBridge.java:435–441describeSession
public void describeSession(String sessionId, String systemPrompt, List<ContextSnapshot.ToolInfo> tools, int maxTokens, String model)
执行 describeSession 方法。
Lets the adapter seed the tracker, including the model name when known.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
systemPrompt | String | 系统提示词(类型 `String`)。The system prompt. |
tools | List<ContextSnapshot.ToolInfo> | 工具列表(类型 `List`)。The tools. |
maxTokens | int | 最大令牌数(类型 `int`)。The max tokens. |
model | String | 模型实例(类型 `String`)。The model. |
io/agentscope/extensions/aistio/SessionBridge.java:444–468setEffectiveSystemPrompt
public void setEffectiveSystemPrompt(String sessionId, String prompt)
设置 setEffectiveSystemPrompt。
Stores the last middleware-composed system prompt for a session.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
prompt | String | 提示词(类型 `String`)。The prompt. |
io/agentscope/extensions/aistio/SessionBridge.java:471–481effectiveSystemPrompt
public String effectiveSystemPrompt(String sessionId)
设置该参数。
Last effective system prompt for the session, or empty.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Stringio/agentscope/extensions/aistio/SessionBridge.java:484–492setBusy
public void setBusy(String sessionId, boolean busy)
设置 setBusy。
Records whether a turn is in progress by driving phase: active while busy, idle when the turn ends.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
busy | boolean | busy(类型 `boolean`)。The busy. |
io/agentscope/extensions/aistio/SessionBridge.java:498–513setPhase
public void setPhase(String sessionId, String phase)
设置阶段。
Sets operational phase explicitly (e.g.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
phase | String | 阶段(类型 `String`)。The phase. |
io/agentscope/extensions/aistio/SessionBridge.java:516–524setContextUsedTokens
public void setContextUsedTokens(String sessionId, int usedTokens)
设置 setContextUsedTokens。
Updates context-window occupancy used for Level-1 contextPressure.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
usedTokens | int | used 令牌数(类型 `int`)。The used tokens. |
io/agentscope/extensions/aistio/SessionBridge.java:527–537info
public Map<String, Object> info()
返回信息。
Returns the info.
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:872–892sessions
public List<Map<String, Object>> sessions()
返回会话。
Returns the sessions.
List<Map<String, Object>>io/agentscope/extensions/aistio/SessionBridge.java:894–949sessionState
public Map<String, Object> sessionState(String sessionId)
设置会话状态。
Performs the session state operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:951–999context
public Map<String, Object> context(String sessionId)
设置上下文。
Performs the context operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:1001–1022messages
public Map<String, Object> messages(String sessionId, int offset, int limit)
执行消息相关操作。
Performs the messages operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
offset | int | 偏移量(类型 `int`)。The offset. |
limit | int | 数量上限(类型 `int`)。The limit. |
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:1024–1035subagents
public List<Map<String, Object>> subagents()
返回 subagents 结果。
Returns the subagents.
List<Map<String, Object>>io/agentscope/extensions/aistio/SessionBridge.java:1037–1049workspaces
public List<Map<String, Object>> workspaces()
返回 workspaces 结果。
Returns the workspaces.
List<Map<String, Object>>io/agentscope/extensions/aistio/SessionBridge.java:1051–1063compress
public void compress(String sessionId)
设置压缩。
Performs the compress operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/extensions/aistio/SessionBridge.java:1065–1079terminate
public void terminate(String sessionId)
设置该参数。
Performs the terminate operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/extensions/aistio/SessionBridge.java:1081–1085abort
public void abort(String sessionId)
设置中止。
Performs the abort operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/extensions/aistio/SessionBridge.java:1087–1091tasks
public Map<String, Object> tasks(String sessionId)
设置任务。
Performs the tasks operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:1093–1115subagentTasks
public Map<String, Object> subagentTasks(String sessionId)
设置子智能体任务。
Performs the subagent tasks operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:1117–1127cancelSubagentTask
public void cancelSubagentTask(String sessionId, String taskId)
执行取消子智能体任务相关操作。
Performs the cancel subagent task operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
taskId | String | 任务标识(类型 `String`)。The task id. |
io/agentscope/extensions/aistio/SessionBridge.java:1129–1135planMode
public void planMode(String sessionId, byte[] body)
执行计划模式相关操作。
Performs the plan mode operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
body | byte[] | 正文(类型 `byte[]`)。The body. |
io/agentscope/extensions/aistio/SessionBridge.java:1137–1143postMessage
public void postMessage(String sessionId, byte[] body)
执行后置消息相关操作。
Performs the post message operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
body | byte[] | 正文(类型 `byte[]`)。The body. |
io/agentscope/extensions/aistio/SessionBridge.java:1145–1159exportTranscript
public Map<String, Object> exportTranscript(String sessionId)
设置该参数。
Performs the export transcript operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Map<String, Object>io/agentscope/extensions/aistio/SessionBridge.java:1177–1185sessionPhase
public String sessionPhase(String sessionId)
设置会话阶段。
Performs the session phase operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Stringio/agentscope/extensions/aistio/SessionBridge.java:1187–1190