# 上下文地图 ## 上下文 - [Zhin Plugin-first Target Architecture (SSOT)](./docs/target-architecture.md) - 定义 Plugin 树、Feature/Resource 边界、HMR、消息、Agent 和 Console 的规范性目标。 - [Plugin Runtime](./packages/im/plugin-runtime/CONTEXT.md) - 负责 Plugin tree、generation、Root lifecycle,以及与 Process Host 的 ownership 分工。 - [Core IM Runtime](./packages/im/core/CONTEXT.md) - 负责 IM 适配器、消息、调度、命令/AI 路由和出站发送链。 - [Agent Runtime](./packages/im/agent/CONTEXT.md) - 负责 ZhinAgent 编排、工具、技能、子代理、上下文预算,以及对 `@zhin.js/ai` 的策略适配。 - [HTTP Host](./packages/host/http/) - Node HTTP/WebSocket、Bearer、CORS、OpenAPI 与 Console transport。 - [Protocol Hosts](./packages/host/mcp/) / [A2A](./packages/host/a2a/) - 建立在最小 HTTP route contract 之上的 MCP 与 Agent-to-Agent 协议。 - [PageManager](./packages/console/pagemanager/CONTEXT.md) - 负责控制台页面目录、PageManager、入口注册和浏览器插件启动。 - [Toolkit Runtime](./packages/toolkit/CONTEXT.md) - 可选 peer:`@zhin.js/speech`、`@zhin.js/html-renderer`、脚手架与 Satori HTML;由 `zhin.js` setup 按配置注册,非 IM 核心。 ## 关系 - **全局装配关系**:Plugin 是唯一基础单元;Resource 与 Feature contribution 统一附着在 PluginScope,Runtime 只读 snapshot。详细关系以 [目标架构](./docs/target-architecture.md) 为准。 - **Process Host -> Plugin Runtime**:Process Host 独占操作系统信号和进程退出;Plugin Runtime 只执行可嵌入、幂等的 Runtime Stop。 - **Core IM Runtime -> Agent Runtime**:Core 分发符合条件的 IM 消息;Agent Runtime 处理 AI 触发回合,并通过 Core 的发送链回复。 - **Agent Runtime -> Core IM Runtime**:Agent 工具和回复在 IM 边界使用 Core 的 `Tool`、`Message`、`SendOptions` 概念。 - **Console Runtime -> Core IM Runtime**:ConsoleTopology 从 Page/Layout Feature projection 派生;适配器插件继续拥有平台相关的数据路由。 - **Console Runtime -> Agent Runtime**:面向 Agent 的控制台页面可以查看或操作 Agent Runtime 状态,但页面注册仍归 Console Runtime 管。 - **Toolkit Runtime -> Core IM Runtime**:composition root 将 HtmlRenderer Host 安装为 generation resource;Core 的统一出站规范化链路按 Endpoint 媒体能力渲染或降级 HTML,不在 Core 维护 optional peer loader。 - **Scaffold Wizard -> 用户项目**:`zhin setup` / `create-zhin-app` 写入配置并诊断 AI / speech / html-renderer 依赖,逻辑不在 CLI 内重复实现。