该框架将 Agent 能力统一封装为「共享 Action」,LLM 工具调用和 UI 代码调用走同一套验证、权限和实现逻辑,适合需要人机协同审查的复杂工作流。
Agent-Native 是一个开源 TypeScript 框架,用于构建将自主工作与专用 UI 配对的 Agent。将每个能力定义为一个 action:Agent 将其作为工具使用,UI 从代码中调用它。
npx --yes @agent-native/core@latest create my-agent --standalone --template chat
按照入门指南获取框架的完整介绍。
编码 Agent 不只和一个文本框打交道。它的环境提供上下文、工具、文件、测试和预览,让它的能力和结果变得可见。
知识工作同样需要这种环境。UI 展示 Agent 能做什么,并为人们提供熟悉的方式来检查、编辑、批准和分享其工作成果。
共享 actions。 Agent 将每个能力作为工具调用,UI 从代码中调用它。两条路径使用相同的验证、权限和实现。
共享数据。 Agent 完成的工作显示在 UI 中,UI 中完成的工作可供 Agent 使用。
共享应用状态。 Agent 接收相关的 UI 状态,如当前页面、选中的记录或活动视图。
Agent 不通过 UI 点击操作。它通过与 UI 相同的 action 层来工作。
创建 actions/hello.ts:
import { defineAction } from "@agent-native/core/action";
import { z } from "zod";
// One action powers every app surface: UI, agent, HTTP, MCP, A2A, and CLI.
export default defineAction({
description: "Return a friendly greeting.",
schema: z.object({
name: z.string().default("world").describe("Name to greet"),
}),
http: { method: "GET" },
run: async ({ name }) => {
return { message: `Hello, ${name}!` };
},
});
Agent 将 hello 作为工具接收。React 用 useActionQuery("hello", { name: "Alex" }) 调用同一个函数。Agent-Native 还通过 HTTP、MCP、A2A 和 CLI 暴露它。
Agent 聊天: 让用户在同一个 UI 中委托工作、提问和查看结果。
认证与权限: 控制谁可以访问和修改共享工作。
技能与记忆: 为 Agent 提供可复用的专业知识和持久上下文。
自动化: 按计划或事件运行 Agent 工作。
Agent 团队: 在同一工作空间或跨连接的 Agent 中将工作委托给专业 Agent。
PostgreSQL 后端: 生产环境使用 PostgreSQL,本地开发使用 PGlite,可在任何兼容 Nitro 的主机上运行。
Bring your LLM, SQL database, tools, and infrastructure. Everything you build stays yours.
查看 Agent-Native 的实际运行效果:
从以下这些 Agent 开始,或将其作为自己项目的参考。
Explore the full app gallery, or start with the framework guide.
阅读文档。
加入 Discord 提问、分享你的作品并获取帮助。
Working on this repository itself? See DEVELOPMENT.md for local setup, workspace structure, and guard scripts.