Skip to content

Open-source, local-first AI agent for real work.

3.0 KB
Raw Blame
---
title: 架构与包边界
description: 理解 Vetta 应用、运行时和核心 Agent 包之间的依赖方向。
---

Vetta 使用 monorepo 管理桌面应用、配套服务和核心 TypeScript 包。依赖方向保持为单向:

```text
应用 → runtime-desktop → coding-agent → runtime-*(node、tools、mcp、storage 等)→ runtime-core → agent-core → ai
```

下层包不能反向依赖上层包;应用之间也不互相导入源码,只通过公开包入口或进程协议协作。

## 核心包

<Cards>
  <Card title="@vetta/ai" description="多模型服务协议、消息转换、流式事件和模型注册表。" />
  <Card title="@vetta/agent-core" description="有状态 Agent Loop、工具调用和事件流(源码目录 packages/agent)。" />
  <Card title="@vetta/runtime-core" description="宿主无关的运行时契约:RuntimeHost、Agent 安装与退役、观测事件和生命周期。" />
  <Card title="@vetta/coding-agent" description="会话、上下文、工具编排及 SDK/RPC 产品能力。" />
</Cards>

## 运行时包

运行时层把 Agent 能力组织成可复用的接口,按职责拆分:

| 包 | 职责 |
| --- | --- |
| `@vetta/runtime-core` | 运行时基础契约,其他 `runtime-*` 都依赖它 |
| `@vetta/runtime-node` | 共享的 Node.js 运行时适配器 |
| `@vetta/runtime-tools` | 平台无关的编码工具协议与工具目录 |
| `@vetta/runtime-mcp` | 平台无关的 MCP 协议与连接状态协调 |
| `@vetta/runtime-storage` | 会话与状态存储 |
| `@vetta/runtime-subagents` | 子 Agent 调度 |
| `@vetta/runtime-telemetry` | 遥测与观测 |
| `@vetta/runtime-knowledge` | 知识库处理 |
| `@vetta/runtime-ssh` | 远程项目的 SSH 运行环境 |
| `@vetta/runtime-desktop` | 把 Coding Agent 与上述运行时组合给桌面宿主使用 |

运行时包不依赖具体桌面界面。

## 应用层

仓库 `apps/` 下的应用:

| 应用 | 说明 |
| --- | --- |
| `desktop` | Electron 桌面应用,负责窗口生命周期、原生能力、IPC、用户界面、插件与主题宿主 |
| `cli-host` | 命令行与 RPC 宿主;桌面应用的 `--agent-rpc` 模式复用它 |
| `im-gateway` | 把本地 Agent 接到即时通讯平台的网关 |
| `remote-relay` | 手机远程控制使用的云端中继 |
| `ssh-helper` | 远程项目在目标主机上运行的辅助程序 |
| `mobile` | iOS 与 Android 远程控制客户端 |
| `docs-site` | 本文档站 |

## 对外发布的包

面向插件和主题作者的开发包以 `@vetta-org/*` 发布到 npm,例如 `@vetta-org/plugin-sdk`、`@vetta-org/plugin-cli`、`@vetta-org/plugin-vite`、`@vetta-org/theme-sdk` 和 `@vetta-org/theme-ui`。`@vetta/*` 下的核心与运行时包目前只在仓库内以 workspace 依赖使用,没有发布到 npm。

<Callout type="info" title="边界约束">
  核心库和运行时包不依赖桌面应用。新增能力时,应先确定契约属于核心、运行时还是宿主,避免把界面生命周期带入底层包。
</Callout>