开源 · Pre-GA · Apache 2.0
Agentrail 提供可组合的运行时、面向托管场景的服务层、多 Agent 编排能力,以及清晰的扩展模型,同时保留自托管与自行组合的空间。
import { defineAgent } from "@agentrail/core"; import { defineProfile } from "@agentrail/app"; export const researchAgent = defineAgent({ id: "researcher", model: { provider: "anthropic", modelId: "claude-sonnet-4-5", apiKey: process.env.ANTHROPIC_API_KEY, }, system: "You are a research assistant.", }); // stream a response const result = await researchAgent.stream( "What are the latest advances in agentic AI?", );
为什么是 Agentrail
很多团队会落在两个极端之间:一边是难以扩展的脚本集合,另一边是带来强绑定的平台。Agentrail 位于两者之间。
结构过少
恰当的结构
绑定过强
包含内容
文档与包结构按职责划分。每个包职责明确,也可以单独使用。
@agentrail/core
用于定义 Agent 与类型化工具契约。LLM 循环、工具调度、LLM Provider 抽象、Prompt SDK 与用量统计都位于这一层。
@agentrail/capabilities
提供沙箱文件系统与浏览器工具、知识库检索、技能注册以及多 Agent 编排,可通过 defineProfile({ capabilities: [...] }) 组合到 Profile 中。
@agentrail/app
createAgentApp 一次挂载聊天与流式接口,defineProfile 负责连接模型、Prompt 与能力。Session 管理、Plugin、Slash Command 与配置加载也位于这一层。
@agentrail/capabilities · orchestration
用于创建子 Agent、分发结构化任务、等待条件完成,并在失败后恢复。状态可通过基于 JSONL 的邮箱机制跨重启保留。
@agentrail/app · SessionManager
基于文件系统的 Session 存储,使用追加式 JSONL 历史记录,并支持自动上下文压缩与会话分支。
@agentrail/capabilities · sandbox
基于 Docker 的隔离执行环境,用于浏览器自动化、Shell 命令与文件读写,并按 Session 维度隔离。
架构
优先使用推荐的 SDK 入口;需要更细控制时,再下探到底层原语。