AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.message_bus

MessageBusKeys

class MessageBusKeys
源码Source agentscope/app/message_bus/_keys.py:19–410

消息总线密钥,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.message_bus 包。核心成员包括 projection_namespace、projection_field、projection_field_prefix、session_events、session_event_checkpoint、session_event_checkpoint_lock。

A flat registry of key/namespace builders — it grows one method per business key, so the public-method count is expected to be high.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
WAKEUP_KIND_WAKEFinal
WAKEUP 种类 WAKE字段。
'wake'
WAKEUP_KIND_RESUMEFinal
WAKEUP 种类恢复字段。
'resume'
WAKEUP_KIND_MESSAGEFinal
WAKEUP 种类消息字段。
'message'
SESSION_REPLAY_MAX_LEN—
会话 REPLAY 最大 LEN字段。
1000
SESSION_EVENT_CURSOR_FIELDFinal
会话事件游标 FIELD字段。
'cursor'
SESSION_EVENT_CHECKPOINT_LOCK_TTL_SECS—
会话事件检查点锁存活时间 SECS字段。
30
SESSION_RUN_TTL_SECS—
会话运行存活时间 SECS字段。
600
SOP_RUN_TTL_SECS—
SOP 运行存活时间 SECS字段。
600
SOP_DISPATCH_FIELD—
SOP DISPATCH FIELD字段。
'step'
INBOX_LOCK_TTL_SECS—
收件箱锁存活时间 SECS字段。
30
INBOX_CONSUMER_FIELD—
收件箱消费者 FIELD字段。
'running'
BG_TASKS_TTL_SECS—
BG 任务存活时间 SECS字段。
86400
CREDENTIAL_BINDING_FIELD—
凭证绑定 FIELD字段。
'record'
CREDENTIAL_BINDING_CLAIM_TTL_SECS—
凭证绑定 CLAIM 存活时间 SECS字段。
300

方法摘要Method Summary

方法Method说明Description
def projection_namespace(target_session_id: str) -> str
设置该参数。
Return the registry namespace for a session's projections.
def projection_field(kind: str, entry_id: str) -> str
执行 `projection_field` 方法。
Return the hash field key for a single projected entry.
def projection_field_prefix(kind: str) -> str
设置该参数。
Return the field-key prefix that identifies one feed.
def session_events(session_id: str) -> str
设置会话事件。
Replay log + live pub/sub channel key for a session.
def session_event_checkpoint(session_id: str) -> str
设置会话事件检查点。
Registry namespace for the persisted replay cursor.
def session_event_checkpoint_lock(session_id: str) -> str
设置会话事件检查点锁。
Lock pairing a persisted message snapshot with its cursor.
def session_lock(session_id: str) -> str
设置会话锁。
Per-session distributed-lock key.
def sop_lock(sop_id: str) -> str
设置SOP 锁。
Per-procedure lock, held while a run is opened or the procedure deleted. Outermost of the three: procedure, run, session.
def sop_dispatch(session_id: str) -> str
设置该参数。
Registry namespace holding ``"<run id>:<step index>"`` while a step's turn is parked in this session. Per session and unleased, since a park can wait on a person indefinitely.
def sop_run_lock(sop_run_id: str) -> str
设置SOP 运行锁。
Per-run lock, taken after the procedure's and before any session's.
def inbox(session_id: str) -> str
设置收件箱。
Per-session inbox drain-queue key.
def inbox_lock(session_id: str) -> str
设置收件箱锁。
Per-session lock serialising inbox hand-off.
def inbox_consumer(session_id: str) -> str
设置收件箱消费者。
Per-session registry recording whether a run is currently consuming this inbox.
def wakeup_queue() -> str
返回 `wakeup_queue` 结果。
Shared run-trigger queue key.
def wakeup_signal() -> str
返回 `wakeup_signal` 结果。
Shared signal channel that nudges dispatchers to drain.
def session_cancel_channel() -> str
返回会话取消渠道。
Global session-cancel broadcast channel.
def task_cancel_channel() -> str
返回任务取消渠道。
Single-task cancel broadcast channel.
def session_interrupt_channel() -> str
返回会话中断渠道。
Global session-interrupt broadcast channel.
def bg_tasks(session_id: str) -> str
设置bg 任务。
Per-session background task registry key.
def index_tasks_queue() -> str
返回索引任务队列。
Shared, durable index-task queue.
def index_tasks_signal() -> str
返回 `index_tasks_signal` 结果。
Shared pub/sub channel that nudges every running index-task consumer to drain the queue.
def schedule_lifecycle() -> str
返回调度生命周期。
Pub/sub channel that nudges the timer-owning node to reconcile its schedule jobs against storage.
def channel_credential_binding(binding_id: str) -> str
设置渠道凭证绑定。
Registry namespace holding one credential-binding session.
def channel_lifecycle() -> str
返回渠道生命周期。
Pub/sub channel that nudges every node to reconcile its running channel instances against storage.
def channel_liveness(channel_id: str) -> str
设置渠道存活检查。
Per-channel per-node status heartbeat namespace.
def channel_media_buffer(channel_id: str, chat_id: str, user_id: str) -> str
执行 `channel_media_buffer` 方法。
Queue key buffering media until the next text message.
def channel_seen_chats(channel_id: str) -> str
设置该参数。
Registry namespace of chat_ids the bot has been messaged in.

属性详情Attribute Detail

WAKEUP_KIND_WAKE

Final = 'wake'

WAKEUP 种类 WAKE字段。声明为 Final。

The WAKEUP KIND WAKE field.

源码Source agentscope/app/message_bus/_keys.py:33

WAKEUP_KIND_RESUME

Final = 'resume'

WAKEUP 种类恢复字段。声明为 Final。

The WAKEUP KIND RESUME field.

源码Source agentscope/app/message_bus/_keys.py:38

WAKEUP_KIND_MESSAGE

Final = 'message'

WAKEUP 种类消息字段。声明为 Final。

The WAKEUP KIND MESSAGE field.

源码Source agentscope/app/message_bus/_keys.py:45

SESSION_REPLAY_MAX_LEN

 = 1000

会话 REPLAY 最大 LEN字段。

The SESSION REPLAY MAX LEN field.

源码Source agentscope/app/message_bus/_keys.py:126

SESSION_EVENT_CURSOR_FIELD

Final = 'cursor'

会话事件游标 FIELD字段。声明为 Final。

The SESSION EVENT CURSOR FIELD field.

源码Source agentscope/app/message_bus/_keys.py:133

SESSION_EVENT_CHECKPOINT_LOCK_TTL_SECS

 = 30

会话事件检查点锁存活时间 SECS字段。

The SESSION EVENT CHECKPOINT LOCK TTL SECS field.

源码Source agentscope/app/message_bus/_keys.py:134

SESSION_RUN_TTL_SECS

 = 600

会话运行存活时间 SECS字段。

The SESSION RUN TTL SECS field.

源码Source agentscope/app/message_bus/_keys.py:157

SOP_RUN_TTL_SECS

 = 600

SOP 运行存活时间 SECS字段。

The SOP RUN TTL SECS field.

源码Source agentscope/app/message_bus/_keys.py:179

SOP_DISPATCH_FIELD

 = 'step'

SOP DISPATCH FIELD字段。

The SOP DISPATCH FIELD field.

源码Source agentscope/app/message_bus/_keys.py:184

INBOX_LOCK_TTL_SECS

 = 30

收件箱锁存活时间 SECS字段。

The INBOX LOCK TTL SECS field.

源码Source agentscope/app/message_bus/_keys.py:208

INBOX_CONSUMER_FIELD

 = 'running'

收件箱消费者 FIELD字段。

The INBOX CONSUMER FIELD field.

源码Source agentscope/app/message_bus/_keys.py:213

BG_TASKS_TTL_SECS

 = 86400

BG 任务存活时间 SECS字段。

The BG TASKS TTL SECS field.

源码Source agentscope/app/message_bus/_keys.py:299

CREDENTIAL_BINDING_FIELD

 = 'record'

凭证绑定 FIELD字段。

The CREDENTIAL BINDING FIELD field.

源码Source agentscope/app/message_bus/_keys.py:365

CREDENTIAL_BINDING_CLAIM_TTL_SECS

 = 300

凭证绑定 CLAIM 存活时间 SECS字段。

The CREDENTIAL BINDING CLAIM TTL SECS field.

源码Source agentscope/app/message_bus/_keys.py:368

方法详情Method Detail

projection_namespace

def projection_namespace(target_session_id: str) -> str

设置该参数。

Return the registry namespace for a session's projections.

参数Parameters
名称Name类型Type说明Description
target_session_idstr目标会话标识(类型 `str`)。The session the entries are projected onto (the session whose UI renders them).
返回Returns str
返回字符串结果。`str`:
源码Source agentscope/app/message_bus/_keys.py:67–79

projection_field

def projection_field(kind: str, entry_id: str) -> str

执行 projection_field 方法。

The kind prefix namespaces the field so different projection feeds sharing one target session never collide, and so a feed can be listed/purged by scanning for its prefix.

参数Parameters
名称Name类型Type说明Description
kindstr种类(类型 `str`)。The projection feed this entry belongs to (e.g. `"subagent_hitl"`).
entry_idstr条目标识(类型 `str`)。The entry's identity within the feed, unique per `kind` (e.g. `"{worker_session_id}:{reply_id}"`).
返回Returns str
返回字符串结果。`str`:
源码Source agentscope/app/message_bus/_keys.py:82–101

projection_field_prefix

def projection_field_prefix(kind: str) -> str

设置该参数。

Used to filter :meth:MessageBus.registry_getall down to a single kind when listing or purging.

参数Parameters
名称Name类型Type说明Description
kindstr种类(类型 `str`)。The projection feed.
返回Returns str
返回字符串结果。`str`:
源码Source agentscope/app/message_bus/_keys.py:104–118

session_events

def session_events(session_id: str) -> str

设置会话事件。

Replay log + live pub/sub channel key for a session.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:137–139

session_event_checkpoint

def session_event_checkpoint(session_id: str) -> str

设置会话事件检查点。

Registry namespace for the persisted replay cursor.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:142–144

session_event_checkpoint_lock

def session_event_checkpoint_lock(session_id: str) -> str

设置会话事件检查点锁。

Lock pairing a persisted message snapshot with its cursor.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:147–149

session_lock

def session_lock(session_id: str) -> str

设置会话锁。

Per-session distributed-lock key.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:161–163

sop_lock

def sop_lock(sop_id: str) -> str

设置SOP 锁。

Per-procedure lock, held while a run is opened or the procedure deleted.

参数Parameters
名称Name类型Type说明Description
sop_idstrSOP 标识(类型 `str`)。The sop id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:172–175

sop_dispatch

def sop_dispatch(session_id: str) -> str

设置该参数。

Registry namespace holding " : " while a step's turn is parked in this session.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:188–192

sop_run_lock

def sop_run_lock(sop_run_id: str) -> str

设置SOP 运行锁。

Per-run lock, taken after the procedure's and before any session's.

参数Parameters
名称Name类型Type说明Description
sop_run_idstrSOP 运行标识(类型 `str`)。The sop run id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:195–198

inbox

def inbox(session_id: str) -> str

设置收件箱。

Per-session inbox drain-queue key.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:217–219

inbox_lock

def inbox_lock(session_id: str) -> str

设置收件箱锁。

Held only around two tiny critical sections — the producer's "push then read consumer flag" and the consumer's "drain then clear consumer flag".

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:222–232

inbox_consumer

def inbox_consumer(session_id: str) -> str

设置收件箱消费者。

Deliberately not derived from :meth:session_lock — the lock is still held while a finished run persists its state, and during that window no further drain will happen, so producers must already treat the session as having no consumer.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:235–245

wakeup_queue

def wakeup_queue() -> str

返回 wakeup_queue 结果。

Shared run-trigger queue key.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:255–257

wakeup_signal

def wakeup_signal() -> str

返回 wakeup_signal 结果。

Shared signal channel that nudges dispatchers to drain.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:260–262

session_cancel_channel

def session_cancel_channel() -> str

返回会话取消渠道。

Global session-cancel broadcast channel.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:273–275

task_cancel_channel

def task_cancel_channel() -> str

返回任务取消渠道。

Single-task cancel broadcast channel.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:278–280

session_interrupt_channel

def session_interrupt_channel() -> str

返回会话中断渠道。

Used by the interrupt API endpoint to request graceful interruption of a running agent.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:283–291

bg_tasks

def bg_tasks(session_id: str) -> str

设置bg 任务。

Per-session background task registry key.

参数Parameters
名称Name类型Type说明Description
session_idstr会话标识(类型 `str`)。The session id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:303–305

index_tasks_queue

def index_tasks_queue() -> str

返回索引任务队列。

The producer-side :class:~agentscope.app._service.KnowledgeBaseService queue_push\ es here through :func:~agentscope.app._bus_ops.enqueue_index_task; the consumer-side :class:~agentscope.app._service.IndexTaskConsumer queue_drain\ s it on each signal — plus once eagerl…

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:315–328

index_tasks_signal

def index_tasks_signal() -> str

返回 index_tasks_signal 结果。

Payload is opaque — only its arrival matters.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:331–340

schedule_lifecycle

def schedule_lifecycle() -> str

返回调度生命周期。

Pub/sub channel that nudges the timer-owning node to reconcile its schedule jobs against storage.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:350–353

channel_credential_binding

def channel_credential_binding(binding_id: str) -> str

设置渠道凭证绑定。

Registry namespace holding one credential-binding session.

参数Parameters
名称Name类型Type说明Description
binding_idstr绑定标识(类型 `str`)。The binding id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:373–375

channel_lifecycle

def channel_lifecycle() -> str

返回渠道生命周期。

Pub/sub channel that nudges every node to reconcile its running channel instances against storage.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:383–386

channel_liveness

def channel_liveness(channel_id: str) -> str

设置渠道存活检查。

Per-channel per-node status heartbeat namespace.

参数Parameters
名称Name类型Type说明Description
channel_idstr渠道标识(类型 `str`)。The channel id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:389–391

channel_media_buffer

def channel_media_buffer(channel_id: str, chat_id: str, user_id: str) -> str

执行 channel_media_buffer 方法。

Queue key buffering media until the next text message.

参数Parameters
名称Name类型Type说明Description
channel_idstr渠道标识(类型 `str`)。The channel id.
chat_idstr聊天标识(类型 `str`)。The chat id.
user_idstr用户标识(类型 `str`)。The user id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:394–405

channel_seen_chats

def channel_seen_chats(channel_id: str) -> str

设置该参数。

Registry namespace of chat_ids the bot has been messaged in.

参数Parameters
名称Name类型Type说明Description
channel_idstr渠道标识(类型 `str`)。The channel id.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/message_bus/_keys.py:408–410
基于官方固定版本源码静态生成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.