WorkspaceMessageBus
public class WorkspaceMessageBus implements MessageBus
io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:55–277工作区消息总线,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.bus 包,实现 MessageBus。核心成员包括 queuePush、queueDrain、queueDelete、queuePeek、logAppend、logRead。
MessageBus implementation backed by AbstractFilesystem.
Works with any filesystem backend (local, remote, sandbox). Cross-process delivery only works when the filesystem backend is actually shared (for example a remote/KV-backed store); a pure local disk backend remains single-process.
Mode D (pub/sub) is degraded to polling: #subscribe returns a Flux that emits
an empty signal every 3 seconds; #publish is a no-op.
File layout under busRoot:
{busRoot}/
queues/{key-hash}/
{entryId}.json — Mode A entries (drain = ls + read + delete)
logs/{key-hash}/
{entryId}.json — Mode C entries (append-only)
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public WorkspaceMessageBus(AbstractFilesystem filesystem, String busRoot) | 初始化 `WorkspaceMessageBus` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<String> queuePush(String key, Map<String, Object> payload) | 执行队列推送相关操作。 Performs the queue push operation. |
public Mono<List<BusEntry>> queueDrain(String key, int maxCount) | 执行 `queueDrain` 方法。 Performs the queue drain operation. |
public Mono<Void> queueDelete(String key) | 设置队列删除。 Performs the queue delete operation. |
public Mono<Boolean> queuePeek(String key) | 设置该参数。 Performs the queue peek operation. |
public Mono<String> logAppend(String key, Map<String, Object> payload, int maxLen) | 执行日志追加相关操作。 Performs the log append operation. |
public Mono<List<BusEntry>> logRead(String key, String since, int maxCount) | 执行日志读取相关操作。 Performs the log read operation. |
public Mono<Void> logTrim(String key) | 设置日志裁剪。 Performs the log trim operation. |
public Mono<Void> publish(String key, Map<String, Object> payload) | 执行发布相关操作。 Performs the publish operation. |
public Flux<Map<String, Object>> subscribe(String key) | 设置订阅。 Performs the subscribe operation. |
构造器详情Constructor Detail
WorkspaceMessageBus
public WorkspaceMessageBus(AbstractFilesystem filesystem, String busRoot)
初始化 WorkspaceMessageBus 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
filesystem | AbstractFilesystem | 文件系统(类型 `AbstractFilesystem`)。any `AbstractFilesystem` implementation |
busRoot | String | 总线根(类型 `String`)。absolute path within the filesystem for bus data (e.g. `"/bus"`) |
io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:69–72方法详情Method Detail
queuePush
public Mono<String> queuePush(String key, Map<String, Object> payload)
执行队列推送相关操作。
Performs the queue push operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
Mono<String>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:76–88queueDrain
public Mono<List<BusEntry>> queueDrain(String key, int maxCount)
执行 queueDrain 方法。
Performs the queue drain operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
maxCount | int | 最大数量(类型 `int`)。The max count. |
Mono<List<BusEntry>>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:90–130queueDelete
public Mono<Void> queueDelete(String key)
设置队列删除。
Performs the queue delete operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
Mono<Void>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:132–135queuePeek
public Mono<Boolean> queuePeek(String key)
设置该参数。
Performs the queue peek operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
Mono<Boolean>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:137–140logAppend
public Mono<String> logAppend(String key, Map<String, Object> payload, int maxLen)
执行日志追加相关操作。
Performs the log append operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
maxLen | int | 最大 Len(类型 `int`)。The max len. |
Mono<String>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:144–166logRead
public Mono<List<BusEntry>> logRead(String key, String since, int maxCount)
执行日志读取相关操作。
Performs the log read operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
since | String | since(类型 `String`)。The since. |
maxCount | int | 最大数量(类型 `int`)。The max count. |
Mono<List<BusEntry>>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:168–203logTrim
public Mono<Void> logTrim(String key)
设置日志裁剪。
Performs the log trim operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
Mono<Void>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:205–208publish
public Mono<Void> publish(String key, Map<String, Object> payload)
执行发布相关操作。
Performs the publish operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
Mono<Void>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:212–215subscribe
public Flux<Map<String, Object>> subscribe(String key)
设置订阅。
Performs the subscribe operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
Flux<Map<String, Object>>io/agentscope/harness/agent/bus/WorkspaceMessageBus.java:217–221