AS AgentScopeAPI 手册 / API Reference

SessionEventLog

@Service public class SessionEventLog
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:48–410

会话事件日志,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.managed.service 包。核心成员包括 append、appendLocal、appendIdempotent、appendIdempotentLocal、list、listAfter。

Append-only session event log. Sequence numbers are allocated with conflict retry so control and data planes can append concurrently against the shared (session_id, seq) unique constraint. Live SSE fan-out is notification-driven and always reads from the durable sequence cursor, so events written by any plane or replica are visible without treating notifications as data.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SessionEventLog(SessionEventEntityRepository repository, ManagedJsonHelper jsonHelper, TransactionTemplate transactionTemplate, DeletedSessionRegistry deletedSessions, SessionEventNotifier notifier, List<SessionEventMirror> mirrors, long recoveryIntervalMs)
初始化 `SessionEventLog` 实例。
Creates a new instance.
public SessionEventLog(SessionEventEntityRepository repository, ManagedJsonHelper jsonHelper, TransactionTemplate transactionTemplate, DeletedSessionRegistry deletedSessions, SessionEventNotifier notifier, long recoveryIntervalMs)
初始化 `SessionEventLog` 实例。
Constructor retained for focused tests and embedders without event mirrors.

方法摘要Method Summary

方法Method说明Description
public SessionEventDto append(String sessionId, String type, Map<String, Object> payload)
执行追加相关操作。
Appends an event with the next monotonic sequence number.
public SessionEventDto appendLocal(String sessionId, String type, Map<String, Object> payload, String eventId)
追加本地。
Appends locally without invoking generic mirrors; caller supplies an immutable scope.
public SessionEventDto append(String sessionId, String type, Map<String, Object> payload, String eventId)
执行追加相关操作。
Appends an event, optionally reusing a pre-allocated `eventId` so stream previews can reconcile with the persisted row.
public SessionEventDto appendIdempotent(String sessionId, String type, Map<String, Object> payload, String eventId)
追加 `appendIdempotent`。
Appends an event once using a caller-owned stable id.
public SessionEventDto appendIdempotentLocal(String sessionId, String type, Map<String, Object> payload, String eventId)
追加 `appendIdempotentLocal`。
Appends/replays locally without an unscoped generic mirror.
public List<SessionEventDto> list(String sessionId)
设置列表。
Lists all events for a session in sequence order.
public List<SessionEventDto> list(String sessionId, Collection<String> types)
执行列表相关操作。
Lists events for a session, optionally restricted to `types`.
public List<SessionEventDto> listAfter(String sessionId, long afterSeq)
列出之后。
Lists events with sequence strictly greater than `afterSeq`.
public List<SessionEventDto> listAfter(String sessionId, long afterSeq, Collection<String> types)
列出之后。
Lists events after `afterSeq`, optionally restricted to `types`.
public SessionEventDto getByEventId(String eventId)
获取通过事件标识。
Looks up a single event by its public identifier.
public Flux<SessionEventDto> subscribe(String sessionId)
设置订阅。
Returns a live flux of events for SSE streaming, starting after sequence 0.
public Flux<SessionEventDto> subscribe(String sessionId, long afterSeq)
执行订阅相关操作。
Reads events with sequence strictly greater than `afterSeq` after an immediate, in-process, or PostgreSQL cross-replica notification.
public void deleteBySessionId(String sessionId)
删除通过会话标识。
Deletes all persisted events for a session that keeps running (transcript clear).
public void purgeDeletedSession(String sessionId)
设置该参数。
Deletes a session's events and refuses any later append for it.

构造器详情Constructor Detail

SessionEventLog

public SessionEventLog(SessionEventEntityRepository repository, ManagedJsonHelper jsonHelper, TransactionTemplate transactionTemplate, DeletedSessionRegistry deletedSessions, SessionEventNotifier notifier, List<SessionEventMirror> mirrors, long recoveryIntervalMs)

初始化 SessionEventLog 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
repositorySessionEventEntityRepository仓库(类型 `SessionEventEntityRepository`)。The repository.
jsonHelperManagedJsonHelperJSON Helper(类型 `ManagedJsonHelper`)。The json helper.
transactionTemplateTransactionTemplate事务模板(类型 `TransactionTemplate`)。The transaction template.
deletedSessionsDeletedSessionRegistry已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions.
notifierSessionEventNotifiernotifier(类型 `SessionEventNotifier`)。The notifier.
mirrorsList<SessionEventMirror>mirrors(类型 `List`)。The mirrors.
recoveryIntervalMslongrecovery 间隔 Ms(类型 `long`)。The recovery interval ms.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:62–78

SessionEventLog

public SessionEventLog(SessionEventEntityRepository repository, ManagedJsonHelper jsonHelper, TransactionTemplate transactionTemplate, DeletedSessionRegistry deletedSessions, SessionEventNotifier notifier, long recoveryIntervalMs)

初始化 SessionEventLog 实例。

Constructor retained for focused tests and embedders without event mirrors.

参数Parameters
名称Name类型Type说明Description
repositorySessionEventEntityRepository仓库(类型 `SessionEventEntityRepository`)。The repository.
jsonHelperManagedJsonHelperJSON Helper(类型 `ManagedJsonHelper`)。The json helper.
transactionTemplateTransactionTemplate事务模板(类型 `TransactionTemplate`)。The transaction template.
deletedSessionsDeletedSessionRegistry已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions.
notifierSessionEventNotifiernotifier(类型 `SessionEventNotifier`)。The notifier.
recoveryIntervalMslongrecovery 间隔 Ms(类型 `long`)。The recovery interval ms.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:81–96

方法详情Method Detail

append

public SessionEventDto append(String sessionId, String type, Map<String, Object> payload)

执行追加相关操作。

Appends an event with the next monotonic sequence number.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
typeString类型(类型 `String`)。The type.
payloadMap<String, Object>负载(类型 `Map`)。The payload.
返回Returns SessionEventDto
返回SessionEventDto。Returns session event dto.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:103–105

appendLocal

public SessionEventDto appendLocal(String sessionId, String type, Map<String, Object> payload, String eventId)

追加本地。

Appends locally without invoking generic mirrors; caller supplies an immutable scope.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
typeString类型(类型 `String`)。The type.
payloadMap<String, Object>负载(类型 `Map`)。The payload.
eventIdString事件标识(类型 `String`)。The event id.
返回Returns SessionEventDto
返回SessionEventDto。Returns session event dto.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:108–111

append

public SessionEventDto append(String sessionId, String type, Map<String, Object> payload, String eventId)

执行追加相关操作。

Appends an event, optionally reusing a pre-allocated eventId so stream previews can reconcile with the persisted row.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
typeString类型(类型 `String`)。The type.
payloadMap<String, Object>负载(类型 `Map`)。The payload.
eventIdString事件标识(类型 `String`)。The event id.
返回Returns SessionEventDto
返回SessionEventDto。Returns session event dto.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:117–120

appendIdempotent

public SessionEventDto appendIdempotent(String sessionId, String type, Map<String, Object> payload, String eventId)

追加 appendIdempotent。

Appends an event once using a caller-owned stable id.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
typeString类型(类型 `String`)。The type.
payloadMap<String, Object>负载(类型 `Map`)。The payload.
eventIdString事件标识(类型 `String`)。The event id.
返回Returns SessionEventDto
返回SessionEventDto。Returns session event dto.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:169–172

appendIdempotentLocal

public SessionEventDto appendIdempotentLocal(String sessionId, String type, Map<String, Object> payload, String eventId)

追加 appendIdempotentLocal。

Appends/replays locally without an unscoped generic mirror.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
typeString类型(类型 `String`)。The type.
payloadMap<String, Object>负载(类型 `Map`)。The payload.
eventIdString事件标识(类型 `String`)。The event id.
返回Returns SessionEventDto
返回SessionEventDto。Returns session event dto.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:175–178

list

public List<SessionEventDto> list(String sessionId)

设置列表。

Lists all events for a session in sequence order.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns List<SessionEventDto>
返回列出。Returns list.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:263–266

list

public List<SessionEventDto> list(String sessionId, Collection<String> types)

执行列表相关操作。

Lists events for a session, optionally restricted to types.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
typesCollection<String>类型(类型 `Collection`)。The types.
返回Returns List<SessionEventDto>
返回列出。Returns list.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:272–282

listAfter

public List<SessionEventDto> listAfter(String sessionId, long afterSeq)

列出之后。

Lists events with sequence strictly greater than afterSeq.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
afterSeqlong之后 Seq(类型 `long`)。The after seq.
返回Returns List<SessionEventDto>
返回列出。Returns list.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:285–288

listAfter

public List<SessionEventDto> listAfter(String sessionId, long afterSeq, Collection<String> types)

列出之后。

Lists events after afterSeq, optionally restricted to types.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
afterSeqlong之后 Seq(类型 `long`)。The after seq.
typesCollection<String>类型(类型 `Collection`)。The types.
返回Returns List<SessionEventDto>
返回列出。Returns list.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:293–305

getByEventId

public SessionEventDto getByEventId(String eventId)

获取通过事件标识。

Looks up a single event by its public identifier.

参数Parameters
名称Name类型Type说明Description
eventIdString事件标识(类型 `String`)。The event id.
返回Returns SessionEventDto
返回SessionEventDto。Returns session event dto.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:308–317

subscribe

public Flux<SessionEventDto> subscribe(String sessionId)

设置订阅。

Returns a live flux of events for SSE streaming, starting after sequence 0.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns Flux<SessionEventDto>
返回Flux。Returns flux.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:320–322

subscribe

public Flux<SessionEventDto> subscribe(String sessionId, long afterSeq)

执行订阅相关操作。

Reads events with sequence strictly greater than afterSeq after an immediate, in-process, or PostgreSQL cross-replica notification.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
afterSeqlong之后 Seq(类型 `long`)。The after seq.
返回Returns Flux<SessionEventDto>
返回Flux。Returns flux.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:333–356

deleteBySessionId

public void deleteBySessionId(String sessionId)

删除通过会话标识。

Deletes all persisted events for a session that keeps running (transcript clear).

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:368–371

purgeDeletedSession

public void purgeDeletedSession(String sessionId)

设置该参数。

Deletes a session's events and refuses any later append for it.

参数Parameters
名称Name类型Type说明Description
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/builder/web/managed/service/SessionEventLog.java:378–384
基于官方固定版本源码静态生成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.