跳到主要内容

Runtime 与 Gateway

Gateway 是 Anyy 工作的 long-lived owner。它让 TUI、CLI、dashboard、cron、channels 和 RPC clients 使用同一个 session runtime。

Runtime 组装

Runtime assembly 会连接 config、profile paths、repositories、provider runtime、tool registry、MCP runtime、skills resolver、channel registry、cron、heartbeat、dashboard 和 RPC server。

Assembly code 应保持窄。新 dependency 应注入 gateway.Dependencies 或对应 runtime builder,而不是 被 agent loop import。

Gateway 服务

internal/gateway.Service 拥有 session creation、session.send、active-turn tracking、toolset selection、context building、provider invocation、persistence、event publication 和 approval continuation。

它会在配置的 runtime tools 外追加 gateway-owned tools,例如 clarify、subagents 和 role onboarding。

Session Queue

当 session 忙碌时,channel 和 RPC callers 可以 enqueue input。Queue records 位于 state 中,并在 active turn 结束后由 gateway drain。

同一 session 的 follow-up input 使用 queue。独立工作使用 background jobs 或 subagents。

后台任务

Background jobs 是 session-scoped records。它们表示 async child agents、cron bridge output、workflows, 或 Anyy 创建的 managed processes。

Gateway 通过 RPC 暴露 job status、logs、wait、kill 和 clear。Managed process tools 不是通用主机进程查看器。

通知

Notifications 和 outbound messages 通过 delivery/runtime helpers 与 channel bindings 流动。notify_usersend_message 等工具限定在当前 user/origin,不向任意外部联系人发送。

生命周期

Gateway lifecycle 包括 service start/stop、socket/TCP listener setup、channel reload、MCP reload、 heartbeat ticks、cron scheduling 和 dashboard sidecar management。

修改 runtime contracts 前,用 statusdoctor 和 subsystem-specific commands 验证 lifecycle behavior。