会分工、会记忆、能把事情做完的智能体。

Astreus 是一个面向自主 AI 智能体的开源 TypeScript 框架:子智能体、图工作流、持久记忆和 MCP 工具,全部收在一套类型化 API 之后。

npm install @astreus-ai/astreus

它替你读凌晨三点你会看的仪表盘。

一个智能体接过告警和 Grafana 截图,告诉事故频道哪里坏了。

import { Agent, Graph } from '@astreus-ai/astreus';const oncall = await Agent.create({  name: 'OnCall',  model: 'gpt-6-astra',  systemPrompt: 'On-call engineer for the payments API',  vision: true,  memory: true});await oncall.ask('Checkout p95 alert. What broke?', {  attachments: [    { type: 'image', path: './grafana-checkout.png' }  ],  stream: true,  onChunk: (chunk) => process.stdout.write(chunk)});
智能体文档

然后它检查你会检查的东西。

最近一次部署看 GitHub,错误看 Sentry,负载看 Postgres。每一个都是模型自行调用的 MCP 服务器。

await oncall.addMCPServers([  {    name: 'github',    command: 'npx',    args: ['-y', '@modelcontextprotocol/server-github']  },  {    name: 'postgres',    command: 'npx',    args: [      '-y', '@modelcontextprotocol/server-postgres',      'postgresql://replica.internal/payments'    ]  },  { name: 'sentry', url: process.env.SENTRY_MCP_URL }]);await oncall.ask(  'What shipped in the last hour, and what broke after?');
MCP 文档

三项调查同时进行。

分诊智能体把日志、部署和数据库交给三位专家,并汇总他们的发现。

const logs = await Agent.create({  name: 'LogAnalyst', model: 'llama3.3',  systemPrompt: 'Find the first error in the logs.'});const deploys = await Agent.create({  name: 'DeployAuditor', model: 'gpt-6-astra',  systemPrompt: 'Audit what shipped in the last hour.'});const database = await Agent.create({  name: 'DbInspector', model: 'gpt-6-astra',  systemPrompt: 'Find slow queries and lock waits.'});const triage = await Agent.create({  name: 'Triage', model: 'claude-fable-5-1',  systemPrompt: 'Split the work, merge the findings.',  subAgents: [logs, deploys, database]});const cause = await triage.ask('Why is checkout slow?', {  useSubAgents: true,  delegation: 'auto',  coordination: 'parallel'});
子智能体文档

整个事故,一张图。

更新状态页的同时进行诊断,诊断之后才回滚,验证,然后撰写事后复盘。

const incident = new Graph({  name: 'Incident response',  maxConcurrency: 3,  retryAttempts: 2,  subAgentAware: true}, triage);const diagnose = incident.addTaskNode({  prompt: 'Find the root cause', useSubAgents: true});const status = incident.addTaskNode({  prompt: 'Post an update to the status page'});const rollback = incident.addTaskNode({  prompt: 'Roll back the deploy', dependencies: [diagnose]});const verify = incident.addTaskNode({  prompt: 'Confirm p95 < 400 ms', dependencies: [rollback]});incident.addTaskNode({  prompt: 'Write the postmortem',  dependencies: [verify, status]});await incident.run();
图文档

这个事故它以前见过。

运行手册是它的知识,过往事故是它的记忆,四小时的对话会被压缩而不是溢出。

const oncall = await Agent.create({  name: 'OnCall',  model: 'gpt-6-astra',  systemPrompt: 'On-call engineer for the payments API',  embeddingModel: 'text-embedding-3-small',  memory: true,  knowledge: true,  autoContextCompression: true,  preserveLastN: 5});await oncall.addKnowledgeFromDirectory('./runbooks');await oncall.addMemory(  'Incident 214: checkout latency, pool exhausted.');const seen = await oncall.searchMemoriesBySimilarity(  'checkout latency spike',  { similarityThreshold: 0.7, limit: 3 });
记忆文档

每项工作用合适的模型。

本地模型清洗日志,数据不出你的网络;更大的模型负责诊断,另一个负责写报告。

const rawLogs = await readFile('./checkout.log', 'utf8');// Scrub raw logs locally. Nothing leaves your network.const scrubbed = await oncall.ask(rawLogs, {  model: 'llama3.3'});// A larger model finds the causeconst cause = await oncall.ask(scrubbed, {  model: 'claude-fable-5-1'});// Another one writes it upconst report = await oncall.ask('Write the postmortem', {  model: 'gpt-6-astra'});
模型提供方文档

客户数据始终上锁。

一个设置即可用 AES-256-GCM 加密数据库中的每条记录、提示词和运行手册片段。

// .env// ENCRYPTION_ENABLED=true// ENCRYPTION_MASTER_KEY=<openssl rand -hex 32>// DB_URL=postgresql://...// KNOWLEDGE_DB_URL=postgresql://...const oncall = await Agent.create({  name: 'OnCall',  model: 'gpt-6-astra',  systemPrompt: 'On-call engineer for the payments API',  memory: true,  knowledge: true});// Stored encrypted: the prompt, the incident thread,// every memory and every runbook chunkawait oncall.ask('Which customers were affected?');
安全文档

安装之前。

Node.js 22 或更高版本、一个数据库和一个模型。Astreus 把智能体和记忆存储在 SQLite 或 PostgreSQL 中,并可对接 OpenAI、Claude、Gemini 或本地的 Ollama 模型。使用 npm install @astreus-ai/astreus 安装。

可以。给智能体指定一个 Ollama 模型,例如 llama3.3,它就会在你自己的机器上运行。智能体的代码不需要改动。

可以。子智能体就是普通的智能体,各自带有自己的模型、提示词和能力,再通过 subAgents 交给协调者。委派方式可以是自动、手动或顺序执行。

一个节点会在它依赖的所有节点完成后立即开始。在图上设置 maxConcurrency,相互独立的节点就能同时运行。默认情况下它们逐个执行。

任何可以通过命令和参数启动,或者可以通过 URL 访问的服务器。使用 addMCPServers 把它们添加到智能体,模型就能使用其中的工具。

可以。Astreus 采用 MIT 许可,你可以在商业项目中使用、修改和分发它。

© 2026 pzzaworks

© 2026 pzzaworks