项目介绍
Agent 开发框架 · 2026-11-09 更新 · 本站尚未实测
agent-express 是一个用 TypeScript 编写的极简 AI Agent 框架,作者把 Express.js 的中间件思路引入智能体开发,整个框架只围绕 Agent、Session、Middleware 三个概念展开。官方 README 将其定位为“Minimalist middleware framework for building AI agents in TypeScript”,并强调任何熟悉 Express 的后端开发者都能复用 use() 的心智模型。仓库以 MIT 许可证公开代码,主页为 https://agent-express.ai,文档和 Getting Started 均指向该站点。
该仓库是框架,不是可下载的成品工作流,也不是 MCP 服务器或客户端插件。收录时应按“框架”理解,而不是把它当作某个具体 Agent 或技能包。
核心能力
点击能力名称查看输入、输出和原文依据。
- 中间件架构:提供
agent、session、turn、model、tool五层洋葱钩子,统一使用(ctx, next)模式。 - 内置守卫:README 列出
guard命名空间下的预算上限、输入/输出校验、超时、迭代限制、人工审批(HITL)、PII 脱敏和限流等中间件。 - 可观测性:
observe命名空间提供用量统计、工具记录、耗时、日志、指标与 OpenTelemetry 追踪。 - 模型接入:README 称可通过
"provider/model"字符串接入任意 AI SDK 提供方,并示例列出 Anthropic、OpenAI、Google、Mistral、Groq 等 12 个以上提供方;还支持按复杂度选择模型的路由。 - 记忆与持久化:提供上下文压缩的 5 种策略,并可通过适配器把会话保存到 SQLite、Redis 或 Postgres。
- 工具与 MCP:
tools.function用于注册函数工具,tools.mcp可将 MCP 服务器作为工具来源接入。 - HTTP 与流式输出:
agent-express/http提供 SSE 适配器,会话可迭代输出类型化事件。 - 测试工具包:
agent-express/test包含 TestModel、FunctionModel、录制/回放与快照等能力。 - CLI:提供交互式脚手架、开发调试与测试命令。
实际应用场景
适用场景
适合熟悉 TypeScript 与 Express 的后端团队,用于搭建带预算控制、审批流、可观测性和会话持久化的服务型 Agent;也适合需要把 MCP 服务器作为工具来源、并通过 SSE 对外提供流式响应的应用。README 中另有一个独立的 support bot 预设包,面向客服类机器人场景,但该预设的能力细节与是否稳定需以官方文档为准。
安装与接入
README 给出的安装命令为:
npm install agent-express
脚手架与本地开发命令为:
README 另列 npx create-agent-express 交互式脚手架,以及开发和测试命令。具体入口文件与参数请按当前版本的 CLI 说明配置。
基本用法是在代码中创建 Agent,指定 model 与 instructions,再用 agent.use() 叠加工具和中间件,最后调用 agent.run()。持久化、向量检索和搜索等能力需要额外安装对应的 @agent-express/* 适配器包,具体包名以 README 的 Packages 表为准。README 说明该项目使用严格 TypeScript 且仅支持 ESM。
使用条件与限制
- 是否需要部署
- 需自行准备运行环境,具体要求见正文
- 是否需要注册
- 账号和认证要求见正文;未明确说明的项目仍待核验
- 是否需要 API Key
- 待核验
- 费用与额度
- 费用边界见正文,项目许可不代表模型或托管服务免费
- 所需权限
- 待核验
- 许可证与服务条款
- 待核验
权限费用与限制
框架代码本身以 MIT 发布,但调用 Anthropic、OpenAI、Google 等模型需要用户自行申请 API Key 并承担相应模型费用;Brave、Tavily、Exa 等搜索服务以及向量数据库同样可能涉及独立账号与计费。README 未说明这些第三方服务的价格,也未说明是否存在商业模块或托管服务。guard.budget({ limit: 1.00 }) 只是运行时成本上限控制,不代表模型免费。PII 脱敏、审批等中间件能降低风险,但不能替代安全审计。是否支持国内模型、国内网络环境下的可用性、Windows 兼容性,README 均未说明,需待核验。仓库未见归档或停止维护的声明,但维护活跃度需另行核查。
国内使用情况
网友核验 用户经验分享
与站长实测独立,不代表官方认证或本站已实测。
最近核验:暂无有效核验。参与人数按当前项目有效身份去重;不同核验项分别统计,不合并成用户总结果。仅统计审核通过且未过期的记录。
分项统计、有效期与样本量
| 核验项目 | 有效人数 | 成功 / 部分 / 失败 / 无法判断 | 成功率 | 最近核验 / 有效期 |
|---|---|---|---|---|
| 官方网站访问 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 7 天 |
| GitHub 仓库访问 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 7 天 |
| 安装与运行 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 官方服务国内连接 / MCP 连接 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 国内网络情况 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 7 天 |
| 国内模型兼容性 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 自定义 API | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 海外服务依赖 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 海外账号要求 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 中文界面 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 客户端兼容性 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
| 账号及费用信息 | 0 | 0 / 0 / 0 / 0 | 样本不足 | 暂无 / 30 天 |
成功率 = 成功 ÷(成功 + 部分成功 + 失败);无法判断不计入分母。至少 5 份可判断结果才显示成功率。账号、费用、海外依赖与语言等事实项,成功表示核查结论与资料吻合,具体观察另行统计;不表示免费或没有海外依赖。不同网络、客户端和版本的结果不能直接等同。
最近有效核验
暂无审核通过且未过期的网友核验。欢迎提交真实使用记录。
查看全部有效核验 →国内实测状态:国内可用性待核验。协议兼容和官方资料说明不等于国内网络可用。
- 官方网站访问
- 尚未实测 待核验
- GitHub 仓库访问
- 尚未实测 待核验
- 官方服务国内连接
- 尚未实测 待核验
- 国内网络情况
- 尚未实测 待核验
- 国内模型兼容性
- 尚未实测 待核验
- 自定义 API
- 尚未实测 待核验
- 海外服务依赖
- 尚未实测 待核验
- 海外账号要求
- 尚未实测 待核验
- 中文界面
- 尚未实测 待核验
- 国内最后核验时间
- 尚未实测
许可与国内使用
仓库 LICENSE 文件为 MIT License,版权声明为 2026 agent-express contributors,允许使用、修改、再分发,需保留版权与许可声明。该许可仅覆盖本仓库代码,不覆盖第三方模型、搜索 API、向量数据库或官网托管服务。官网域名不代表服务部署地域,国内访问官网与 npm 包的稳定性、是否需要镜像源,均需待核验。
项目资料与来源
字段依据与待核验事项
access:来源确认 · npm install agent-express
project_type:来源确认 · Minimalist middleware framework for building AI agents in TypeScript.
原始 README(折叠技术参考)
# agent-express
Minimalist middleware framework for building AI agents in TypeScript.
[](https://www.npmjs.com/package/agent-express)
[](https://github.com/agent-express-ai/agent-express/actions)
[](https://github.com/agent-express-ai/agent-express)
[](LICENSE)
[](https://www.typescriptlang.org/)
**[Documentation](https://agent-express.ai)** · **[Getting Started](https://agent-express.ai/getting-started/)** · **[API Reference](https://agent-express.ai/reference/api/readme/)**
## Why agent-express
Three concepts: `Agent`, `Session`, and `Middleware`. That's the entire framework.
Every backend developer knows `use()`. Agent Express applies the Express.js middleware pattern to AI agents. One `(ctx, next)` interface replaces the 15-20 concepts you'll find in alternatives. If you've built an Express app, you already know the mental model.
## Quick Start
```bash
npm install agent-express
```
```typescript
import { Agent, tools } from "agent-express"
import { z } from "zod"
const agent = new Agent({
model: "anthropic/claude-sonnet-4-6",
instructions: "You are a helpful assistant.",
})
agent.use(tools.function({
name: "greet",
description: "Greet someone by name",
schema: z.object({ name: z.string() }),
execute: async ({ name }) => `Hello, ${name}!`,
}))
const { text } = await agent.run({ input: "Greet Alice" })
console.log(text)
```
## Features
- **Middleware architecture** -- 5 onion hooks (`agent`, `session`, `turn`, `model`, `tool`), one `(ctx, next)` pattern
- **Built-in guards** -- budget caps, input/output validation, timeouts, iteration limits, HITL approval
- **Observability** -- structured logging, OpenTelemetry metrics and traces, token tracking, tool recording
- **12+ model providers** -- any AI SDK provider via `"provider/model"` string (Anthropic, OpenAI, Google, Mistral, Groq, and more)
- **Model routing** -- complexity-based model selection across providers
- **Memory management** -- context window compaction with 5 strategies
- **Testing toolkit** -- TestModel, FunctionModel, capture, record/replay, snapshots
- **MCP integration** -- connect to MCP servers as tool sources
- **HTTP adapter** -- SSE streaming out of the box
- **CLI** -- `agent-express dev` with hot reload, `agent-express test` with CI output
- **Structured output** -- Zod schema validation on model responses
## Middleware Namespaces
Compose capabilities by stacking middleware:
```typescript
import { Agent, guard, observe, model, memory, dev } from "agent-express"
const agent = new Agent({ model: "anthropic/claude-sonnet-4-6" })
agent
.use(guard.budget({ limit: 1.00 }))
.use(guard.approve({ approve: myApprovalFn }))
.use(observe.usage())
.use(model.retry())
.use(memory.compaction({ maxTokens: 8192 }))
.use(dev.console())
```
| Namespace | Middleware | Description |
|---|---|---|
| `guard` | `budget`, `input`, `output`, `maxIterations`, `timeout`, `approve`, `piiRedact`, `rateLimit` | Safety, cost, and compliance |
| `observe` | `usage`, `tools`, `duration`, `log`, `metrics`, `traces` | Monitoring, metrics, and tracing |
| `search` | `file`, `web` | Document search (RAG) and web search |
| `model` | `retry`, `router` | LLM call management |
| `memory` | `compaction`, `store` | Context window and session persistence |
| `tools` | `function`, `mcp` | Tool registration |
| `dev` | `console` | Development utilities |
**Presets** (separate packages):
| Package | Preset | Description |
|---|---|---|
| `@agent-express/preset-support` | `supportBot()` | Production support bot with RAG, PII, escalation, tone |
## Writing Custom Middleware
A plain function passed to `.use()` becomes a `turn` hook:
```typescript
agent.use(async (ctx, next) => {
console.log(`Turn ${ctx.turnIndex}: ${ctx.input[0]?.content}`)
await next()
console.log(`Response: ${ctx.output}`)
})
```
For multiple hooks, return a `Middleware` object:
```typescript
import type { Middleware } from "agent-express"
const analytics: Middleware = {
name: "analytics",
state: {
"analytics:turns": { default: 0 },
"analytics:cost": { default: 0, reducer: (prev, delta) => prev + delta },
},
turn: async (ctx, next) => {
ctx.state["analytics:turns"] = ctx.turnIndex + 1
await next()
},
model: async (ctx, next) => {
const response = await next()
ctx.state["analytics:cost"] = response.usage.inputTokens * 0.000003
return response
},
}
agent.use(analytics)
```
The 5 hooks form an onion — code before `next()` runs on the way in, code after runs on the way out:
```
agent → session → turn → model → [LLM call]
→ tool → [tool execution]
```
See built-in middleware for real-world examples:
[guard.budget](src/middleware/guard/budget.ts),
[observe.usage](src/middleware/observe/usage.ts),
[model.retry](src/middleware/model/retry.ts),
[memory.compaction](src/middleware/memory/compaction.ts)
## Sessions and Streaming
Multi-turn conversations with session state:
```typescript
await agent.init()
const session = agent.session()
const r1 = await session.run({ input: "My name is Alice" })
const r2 = await session.run({ input: "What's my name?" })
// r2.text → "Your name is Alice"
await agent.dispose()
```
Streaming typed events as they happen:
```typescript
for await (const event of agent.run({ input: "Hello" })) {
if (event.type === "model:chunk") process.stdout.write(event.payload.text)
if (event.type === "tool:call") console.log(`Calling ${event.payload.name}...`)
}
```
Same `Event` objects flow through the iterator and `session.events`, so
the streaming view and the persistent log are the same source of truth.
## Persistence
Sessions persist to SQLite, Redis, or Postgres via adapter packages.
Crash mid-turn, restart, the next session run resumes from the event log:
```typescript
import { memory } from "agent-express"
import { sqliteStore } from "@agent-express/session-sqlite"
agent.use(memory.store(sqliteStore({ path: ".agent-express/sessions.db" })))
```
See [`docs/design/event-log.md`](docs/design/event-log.md) for the full
substrate design.
## Testing
Mock LLM calls in tests with `agent-express/test`:
```typescript
import { TestModel, testAgent } from "agent-express/test"
const model = new TestModel([
{ text: "Hello! How can I help?" },
])
const result = await testAgent(agent, {
model,
input: "Hi",
})
expect(result.text).toContain("Hello")
```
Record and replay real API calls:
```typescript
import { RecordModel, ReplayModel } from "agent-express/test"
// Record once (hits real API)
const record = new RecordModel("anthropic/claude-sonnet-4-6")
await agent.run({ input: "test", model: record })
record.save("tests/cassettes/greeting.json")
// Replay forever (no API calls)
const replay = ReplayModel.load("tests/cassettes/greeting.json")
await agent.run({ input: "test", model: replay })
```
## Comparison
| Feature | agent-express | Mastra | Vercel AI SDK | LangChain.js |
|---|---|---|---|---|
| Core concepts | 3 | 15-20 | 5-8 | 30+ |
| Extension model | Middleware `(ctx, next)` | Processors, Tools, Workflows | Hooks, Providers | Chains, Agents, Tools, Memory |
| Built-in testing | Yes | No | No | No |
| Cost control | `guard.budget()` | Manual | Manual | Manual |
| TypeScript | Strict, ESM only | TypeScript | TypeScript | TypeScript |
## Packages
**Core:**
```
agent-express -- Agent, Session, middleware namespaces, errors
agent-express/http -- createHandler() SSE adapter
agent-express/test -- TestModel, FunctionModel, testAgent()
```
**Presets:**
| Package | Description |
|---|---|
| `@agent-express/preset-support` | Production support bot (RAG, PII, tone, escalation, rate limiting) |
**Adapter packages:**
| Package | Description |
|---|---|
| `@agent-express/embed-openai` | OpenAI text-embedding-3-small |
| `@agent-express/embed-cohere` | Cohere embed-v3 |
| `@agent-express/search-brave` | Brave Search API |
| `@agent-express/search-tavily` | Tavily Search API |
| `@agent-express/search-exa` | Exa semantic search |
| `@agent-express/search-llamaindex` | LlamaIndex.TS file ingestion + cosine similarity |
| `@agent-express/search-qdrant` | Qdrant vector DB retriever |
| `@agent-express/search-pinecone` | Pinecone vector DB retriever |
| `@agent-express/search-pgvector` | PostgreSQL pgvector retriever |
| `@agent-express/session-sqlite` | SQLite session store (better-sqlite3) |
| `@agent-express/session-redis` | Redis session store (ioredis) |
| `@agent-express/session-postgres` | PostgreSQL session store (pg) |
## CLI
```bash
npx create-agent-express # interactive wizard
npx create-agent-express --template support-bot # template scaffold
npx agent-express dev [entry] # terminal chat + hot reload
npx agent-express test # agent test runner
npx agent-express test --ci # JUnit XML output for CI
```
## Architecture & Design Docs
For new contributors, the recommended reading order:
1. [Concept](docs/design/agent-express-concept.md) — what we're building, the agent session primitive, why middleware beats graphs, 7-framework comparison
2. [Middleware Interface](docs/design/middleware-interface.md) — the single `Middleware` interface and `(ctx, next)` onion pattern
3. [Agent Loop](docs/design/agent-loop.md) — 5-level lifecycle (agent / session / turn / model / tool) and the model→tool→model loop
4. [Event Log](docs/design/event-log.md) — v0.4 substrate: typed events, durability, `SessionStore` contract
Reference docs for individual subsystems:
- [Providers](docs/design/providers.md) — `"provider/model"` resolution and security guards
- [Adapters](docs/design/adapters.md) — three adapter families (session / embed / search) and how to write a custom adapter
- [Observability](docs/design/observability.md) — six observability middlewares and OpenTelemetry integration
- [Testing](docs/design/testing.md) — `testAgent`, `FunctionModel`, recorder cassettes, real-request guard
See [`docs/design/`](docs/design/) for the full index and
[`docs/research/`](docs/research/) for reverse-engineering notes on
adjacent agent frameworks.
## Links
- [Contributing](CONTRIBUTING.md)
- [Changelog](CHANGELOG.md)
- [Security Policy](SECURITY.md)
- [Code of Conduct](CODE_OF_CONDUCT.md)
- [License](LICENSE)
历史前置条件说明(补充参考)
Node.js 环境(版本要求未在 README 说明,待核验);TypeScript 严格模式与 ESM;使用模型需自备 Anthropic、OpenAI、Google 等提供方 API Key;搜索与向量库适配器可能需要 Brave、Tavily、Exa、Qdrant、Pinecone 等第三方账号;模型及第三方服务费用待核验;国内网络可用性待核验;Windows 支持情况待核验。
项目来源与清单版权许可
https://github.com/agent-express-ai/agent-express
整理来源:https://github.com/slavakurilyak/awesome-ai-agents
清单版权与许可:
MIT License
Copyright (c) 2024 Slava Kurilyak
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.